Fixed set_variation_by_name offset

This commit is contained in:
Andrew Murray 2022-07-18 08:39:23 +10:00
parent 2258f23781
commit dea30e4c80
4 changed files with 4 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -769,12 +769,14 @@ class TestImageFont:
self._check_text(font, "Tests/images/variation_adobe.png", 11)
for name in ["Bold", b"Bold"]:
font.set_variation_by_name(name)
self._check_text(font, "Tests/images/variation_adobe_name.png", 11)
assert font.getname()[1] == "Bold"
self._check_text(font, "Tests/images/variation_adobe_name.png", 16)
font = ImageFont.truetype("Tests/fonts/TINY5x3GX.ttf", 36)
self._check_text(font, "Tests/images/variation_tiny.png", 40)
for name in ["200", b"200"]:
font.set_variation_by_name(name)
assert font.getname()[1] == "200"
self._check_text(font, "Tests/images/variation_tiny_name.png", 40)
def test_variation_set_by_axes(self):

View File

@ -795,7 +795,7 @@ class FreeTypeFont:
names = self.get_variation_names()
if not isinstance(name, bytes):
name = name.encode()
index = names.index(name)
index = names.index(name) + 1
if index == getattr(self, "_last_variation_index", None):
# When the same name is set twice in a row,