mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
add test using woff2 font with freetype
This commit is contained in:
parent
17e5f1eb3b
commit
2f95e49b36
|
@ -8,6 +8,7 @@ TINY5x3GX.ttf, from http://velvetyne.fr/fonts/tiny
|
|||
ArefRuqaa-Regular.ttf, from https://github.com/google/fonts/tree/master/ofl/arefruqaa
|
||||
ter-x20b.pcf, from http://terminus-font.sourceforge.net/
|
||||
BungeeColor-Regular_colr_Windows.ttf, from https://github.com/djrrb/bungee
|
||||
OpenSans.woff2, from https://fonts.googleapis.com/css?family=Open+Sans
|
||||
|
||||
All of the above fonts are published under the SIL Open Font License (OFL) v1.1 (http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL), which allows you to copy, modify, and redistribute them if you need to.
|
||||
|
||||
|
|
BIN
Tests/fonts/OpenSans.woff2
Normal file
BIN
Tests/fonts/OpenSans.woff2
Normal file
Binary file not shown.
BIN
Tests/images/test_woff2.png
Normal file
BIN
Tests/images/test_woff2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
|
@ -1064,6 +1064,24 @@ class TestImageFont:
|
|||
|
||||
assert_image_similar_tofile(im, "Tests/images/colr_bungee_mask.png", 22)
|
||||
|
||||
def test_woff2(self):
|
||||
try:
|
||||
font = ImageFont.truetype(
|
||||
"Tests/fonts/OpenSans.woff2",
|
||||
size=64,
|
||||
layout_engine=self.LAYOUT_ENGINE,
|
||||
)
|
||||
except OSError as e:
|
||||
assert str(e) in ("unimplemented feature", "unknown file format")
|
||||
pytest.skip("FreeType compiled without brotli or WOFF2 support")
|
||||
|
||||
im = Image.new("RGB", (350, 100), "white")
|
||||
d = ImageDraw.Draw(im)
|
||||
|
||||
d.text((15, 5), "OpenSans", "black", font=font)
|
||||
|
||||
assert_image_similar_tofile(im, "Tests/images/test_woff2.png", 5)
|
||||
|
||||
def test_fill_deprecation(self):
|
||||
font = self.get_font()
|
||||
with pytest.warns(DeprecationWarning):
|
||||
|
|
Loading…
Reference in New Issue
Block a user