Merge pull request #4696 from radarhere/harfbuzz
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
Tests/images/variation_adobe_older_harfbuzz.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
Tests/images/variation_adobe_older_harfbuzz_axes.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
Tests/images/variation_adobe_older_harfbuzz_name.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
|
@ -13,7 +13,6 @@ from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
assert_image_similar,
|
assert_image_similar,
|
||||||
assert_image_similar_tofile,
|
assert_image_similar_tofile,
|
||||||
is_mingw,
|
|
||||||
is_pypy,
|
is_pypy,
|
||||||
is_win32,
|
is_win32,
|
||||||
skip_unless_feature,
|
skip_unless_feature,
|
||||||
|
@ -661,7 +660,22 @@ class TestImageFont:
|
||||||
{"name": b"Size", "minimum": 0, "maximum": 300, "default": 0}
|
{"name": b"Size", "minimum": 0, "maximum": 300, "default": 0}
|
||||||
]
|
]
|
||||||
|
|
||||||
@pytest.mark.skipif(is_mingw(), reason="epsilon too high for meaningful test")
|
def _check_text(self, font, path, epsilon):
|
||||||
|
im = Image.new("RGB", (100, 75), "white")
|
||||||
|
d = ImageDraw.Draw(im)
|
||||||
|
d.text((10, 10), "Text", font=font, fill="black")
|
||||||
|
|
||||||
|
try:
|
||||||
|
with Image.open(path) as expected:
|
||||||
|
assert_image_similar(im, expected, epsilon)
|
||||||
|
except AssertionError:
|
||||||
|
if "_adobe" in path:
|
||||||
|
path = path.replace("_adobe", "_adobe_older_harfbuzz")
|
||||||
|
with Image.open(path) as expected:
|
||||||
|
assert_image_similar(im, expected, epsilon)
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
def test_variation_set_by_name(self):
|
def test_variation_set_by_name(self):
|
||||||
font = self.get_font()
|
font = self.get_font()
|
||||||
|
|
||||||
|
@ -674,27 +688,18 @@ class TestImageFont:
|
||||||
with pytest.raises(OSError):
|
with pytest.raises(OSError):
|
||||||
font.set_variation_by_name("Bold")
|
font.set_variation_by_name("Bold")
|
||||||
|
|
||||||
def _check_text(font, path, epsilon):
|
|
||||||
im = Image.new("RGB", (100, 75), "white")
|
|
||||||
d = ImageDraw.Draw(im)
|
|
||||||
d.text((10, 10), "Text", font=font, fill="black")
|
|
||||||
|
|
||||||
with Image.open(path) as expected:
|
|
||||||
assert_image_similar(im, expected, epsilon)
|
|
||||||
|
|
||||||
font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36)
|
font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36)
|
||||||
_check_text(font, "Tests/images/variation_adobe.png", 11)
|
self._check_text(font, "Tests/images/variation_adobe.png", 11)
|
||||||
for name in ["Bold", b"Bold"]:
|
for name in ["Bold", b"Bold"]:
|
||||||
font.set_variation_by_name(name)
|
font.set_variation_by_name(name)
|
||||||
_check_text(font, "Tests/images/variation_adobe_name.png", 11)
|
self._check_text(font, "Tests/images/variation_adobe_name.png", 11)
|
||||||
|
|
||||||
font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf", 36)
|
font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf", 36)
|
||||||
_check_text(font, "Tests/images/variation_tiny.png", 40)
|
self._check_text(font, "Tests/images/variation_tiny.png", 40)
|
||||||
for name in ["200", b"200"]:
|
for name in ["200", b"200"]:
|
||||||
font.set_variation_by_name(name)
|
font.set_variation_by_name(name)
|
||||||
_check_text(font, "Tests/images/variation_tiny_name.png", 40)
|
self._check_text(font, "Tests/images/variation_tiny_name.png", 40)
|
||||||
|
|
||||||
@pytest.mark.skipif(is_mingw(), reason="epsilon too high for meaningful test")
|
|
||||||
def test_variation_set_by_axes(self):
|
def test_variation_set_by_axes(self):
|
||||||
font = self.get_font()
|
font = self.get_font()
|
||||||
|
|
||||||
|
@ -707,21 +712,13 @@ class TestImageFont:
|
||||||
with pytest.raises(OSError):
|
with pytest.raises(OSError):
|
||||||
font.set_variation_by_axes([500, 50])
|
font.set_variation_by_axes([500, 50])
|
||||||
|
|
||||||
def _check_text(font, path, epsilon):
|
|
||||||
im = Image.new("RGB", (100, 75), "white")
|
|
||||||
d = ImageDraw.Draw(im)
|
|
||||||
d.text((10, 10), "Text", font=font, fill="black")
|
|
||||||
|
|
||||||
with Image.open(path) as expected:
|
|
||||||
assert_image_similar(im, expected, epsilon)
|
|
||||||
|
|
||||||
font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36)
|
font = ImageFont.truetype("Tests/fonts/AdobeVFPrototype.ttf", 36)
|
||||||
font.set_variation_by_axes([500, 50])
|
font.set_variation_by_axes([500, 50])
|
||||||
_check_text(font, "Tests/images/variation_adobe_axes.png", 5.1)
|
self._check_text(font, "Tests/images/variation_adobe_axes.png", 5.1)
|
||||||
|
|
||||||
font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf", 36)
|
font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf", 36)
|
||||||
font.set_variation_by_axes([100])
|
font.set_variation_by_axes([100])
|
||||||
_check_text(font, "Tests/images/variation_tiny_axes.png", 32.5)
|
self._check_text(font, "Tests/images/variation_tiny_axes.png", 32.5)
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("raqm")
|
@skip_unless_feature("raqm")
|
||||||
|
|
|
@ -251,9 +251,9 @@ deps = {
|
||||||
"libs": [r"*.lib"],
|
"libs": [r"*.lib"],
|
||||||
},
|
},
|
||||||
"harfbuzz": {
|
"harfbuzz": {
|
||||||
"url": "https://github.com/harfbuzz/harfbuzz/archive/2.6.4.zip",
|
"url": "https://github.com/harfbuzz/harfbuzz/archive/2.6.7.zip",
|
||||||
"filename": "harfbuzz-2.6.4.zip",
|
"filename": "harfbuzz-2.6.7.zip",
|
||||||
"dir": "harfbuzz-2.6.4",
|
"dir": "harfbuzz-2.6.7",
|
||||||
"build": [
|
"build": [
|
||||||
cmd_cmake("-DHB_HAVE_FREETYPE:BOOL=TRUE"),
|
cmd_cmake("-DHB_HAVE_FREETYPE:BOOL=TRUE"),
|
||||||
cmd_nmake(target="clean"),
|
cmd_nmake(target="clean"),
|
||||||
|
|