mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Added size argument to load_default()
This commit is contained in:
parent
1e5aa21fa8
commit
eccef36948
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.6 KiB |
|
@ -459,6 +459,9 @@ def test_default_font():
|
||||||
default_font = ImageFont.load_default()
|
default_font = ImageFont.load_default()
|
||||||
draw.text((10, 10), txt, font=default_font)
|
draw.text((10, 10), txt, font=default_font)
|
||||||
|
|
||||||
|
larger_default_font = ImageFont.load_default(size=14)
|
||||||
|
draw.text((10, 60), txt, font=larger_default_font)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert_image_equal_tofile(im, "Tests/images/default_font_freetype.png")
|
assert_image_equal_tofile(im, "Tests/images/default_font_freetype.png")
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ import pytest
|
||||||
|
|
||||||
from PIL import Image, ImageDraw, ImageFont, features
|
from PIL import Image, ImageDraw, ImageFont, features
|
||||||
|
|
||||||
|
from .helper import assert_image_equal_tofile
|
||||||
|
|
||||||
pytestmark = pytest.mark.skipif(
|
pytestmark = pytest.mark.skipif(
|
||||||
features.check_module("freetype2"),
|
features.check_module("freetype2"),
|
||||||
reason="PILfont superseded if FreeType is supported",
|
reason="PILfont superseded if FreeType is supported",
|
||||||
|
@ -22,6 +24,11 @@ def test_default_font():
|
||||||
assert_image_equal_tofile(im, "Tests/images/default_font.png")
|
assert_image_equal_tofile(im, "Tests/images/default_font.png")
|
||||||
|
|
||||||
|
|
||||||
|
def test_size_without_freetype():
|
||||||
|
with pytest.raises(ImportError):
|
||||||
|
ImageFont.load_default(size=14)
|
||||||
|
|
||||||
|
|
||||||
def test_unicode():
|
def test_unicode():
|
||||||
# should not segfault, should return UnicodeDecodeError
|
# should not segfault, should return UnicodeDecodeError
|
||||||
# issue #2826
|
# issue #2826
|
||||||
|
|
|
@ -855,7 +855,7 @@ def load_path(filename):
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
|
|
||||||
|
|
||||||
def load_default():
|
def load_default(size=None):
|
||||||
"""If FreeType support is available, load a version of Aileron Regular,
|
"""If FreeType support is available, load a version of Aileron Regular,
|
||||||
https://dotcolon.net/font/aileron, with a more limited character set.
|
https://dotcolon.net/font/aileron, with a more limited character set.
|
||||||
|
|
||||||
|
@ -865,7 +865,7 @@ def load_default():
|
||||||
|
|
||||||
:return: A font object.
|
:return: A font object.
|
||||||
"""
|
"""
|
||||||
if core.__class__.__name__ == "module":
|
if core.__class__.__name__ == "module" or size is not None:
|
||||||
f = truetype(
|
f = truetype(
|
||||||
BytesIO(
|
BytesIO(
|
||||||
base64.b64decode(
|
base64.b64decode(
|
||||||
|
@ -1093,6 +1093,7 @@ AAAAAAQAAAADa3tfFAAAAANAan9kAAAAA4QodoQ==
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
10 if size is None else size,
|
||||||
layout_engine=Layout.BASIC,
|
layout_engine=Layout.BASIC,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user