mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Changed "font" to class variable
This commit is contained in:
parent
1b5abea043
commit
04d9761316
|
@ -1314,6 +1314,23 @@ def test_stroke_multiline():
|
|||
assert_image_similar_tofile(im, "Tests/images/imagedraw_stroke_multiline.png", 3.3)
|
||||
|
||||
|
||||
def test_setting_default_font():
|
||||
# Arrange
|
||||
im = Image.new("RGB", (100, 250))
|
||||
draw = ImageDraw.Draw(im)
|
||||
font = ImageFont.truetype("Tests/fonts/FreeMono.ttf", 120)
|
||||
|
||||
# Act
|
||||
ImageDraw.ImageDraw.font = font
|
||||
|
||||
# Assert
|
||||
try:
|
||||
assert draw.getfont() == font
|
||||
finally:
|
||||
ImageDraw.ImageDraw.font = None
|
||||
assert isinstance(draw.getfont(), ImageFont.ImageFont)
|
||||
|
||||
|
||||
def test_same_color_outline():
|
||||
# Prepare shape
|
||||
x0, y0 = 5, 5
|
||||
|
|
|
@ -46,6 +46,8 @@ directly.
|
|||
|
||||
|
||||
class ImageDraw:
|
||||
font = None
|
||||
|
||||
def __init__(self, im, mode=None):
|
||||
"""
|
||||
Create a drawing instance.
|
||||
|
@ -86,7 +88,6 @@ class ImageDraw:
|
|||
else:
|
||||
self.fontmode = "L" # aliasing is okay for other modes
|
||||
self.fill = 0
|
||||
self.font = None
|
||||
|
||||
def getfont(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user