From: Marc Foley Date: Fri, 14 Apr 2023 09:00:11 +0000 (+0100) Subject: do not elide opsz particles X-Git-Tag: v0.4.2^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2be8ea4566b90d873cc3d1d3a9c8d0b3a25c3aaa;p=thirdparty%2Fgoogle%2Ffonts.git do not elide opsz particles --- diff --git a/Lib/axisregistry/__init__.py b/Lib/axisregistry/__init__.py index d1baecd2d2..bade5a79fc 100644 --- a/Lib/axisregistry/__init__.py +++ b/Lib/axisregistry/__init__.py @@ -154,7 +154,10 @@ def _fvar_dflts(ttFont): name = fallback.name elided = fallback.value == axis_registry[ a.axisTag - ].default_value and name not in ["Regular", "Italic"] + ].default_value and name not in ["Regular", "Italic", "14pt"] + elif a.axisTag == "opsz": + name = f"{int(a.defaultValue)}pt" + elided = False else: name = None elided = True # since we can't find a name for it, keep it elided diff --git a/tests/data/Playfair[opsz,wdth,wght].ttf b/tests/data/Playfair[opsz,wdth,wght].ttf new file mode 100644 index 0000000000..1692b405a1 Binary files /dev/null and b/tests/data/Playfair[opsz,wdth,wght].ttf differ diff --git a/tests/test_names.py b/tests/test_names.py index bfc3b38ab3..af65b5bb19 100644 --- a/tests/test_names.py +++ b/tests/test_names.py @@ -25,6 +25,7 @@ opensans_italic_fp = os.path.join(DATA_DIR, "OpenSans-Italic[wdth,wght].ttf") opensans_cond_roman_fp = os.path.join(DATA_DIR, "OpenSansCondensed[wght].ttf") opensans_cond_italic_fp = os.path.join(DATA_DIR, "OpenSansCondensed-Italic[wght].ttf") wonky_fp = os.path.join(DATA_DIR, "Wonky[wdth,wght].ttf") +playfair_fp = os.path.join(DATA_DIR, "Playfair[opsz,wdth,wght].ttf") @pytest.fixture @@ -293,6 +294,22 @@ def _test_names(ttFont, expected): (17, 3, 1, 0x409): None, }, ), + # Test opsz particle is kept + ( + playfair_fp, + "Playfair", + None, + [], + { + (1, 3, 1, 0x409): "Playfair 5pt SemiExpanded Light", + (2, 3, 1, 0x409): "Regular", + (3, 3, 1, 0x409): "2.000;FTH;Playfair-5ptSemiExpandedLight", + (4, 3, 1, 0x409): "Playfair 5pt SemiExpanded Light", + (6, 3, 1, 0x409): "Playfair-5ptSemiExpandedLight", + (16, 3, 1, 0x409): "Playfair", + (17, 3, 1, 0x409): "5pt SemiExpanded Light", + } + ) ], ) def test_name_table(fp, family_name, style_name, siblings, expected):