]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
do not elide opsz particles
authorMarc Foley <m.foley.88@gmail.com>
Fri, 14 Apr 2023 09:00:11 +0000 (10:00 +0100)
committerMarc Foley <m.foley.88@gmail.com>
Fri, 14 Apr 2023 09:00:25 +0000 (10:00 +0100)
Lib/axisregistry/__init__.py
tests/data/Playfair[opsz,wdth,wght].ttf [new file with mode: 0644]
tests/test_names.py

index d1baecd2d2ab5cad71b7b5b9c49197f73291646c..bade5a79fc602c05ebffadf28df33ebd8bb240ba 100644 (file)
@@ -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 (file)
index 0000000..1692b40
Binary files /dev/null and b/tests/data/Playfair[opsz,wdth,wght].ttf differ
index bfc3b38ab3b5504c7980a3fe45a036ec9fd23304..af65b5bb19bc1a8200f245856033ecc86f6c624f 100644 (file)
@@ -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):