]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
fix_stat do not drop nameids <= 25
authorMarc Foley <m.foley.88@gmail.com>
Mon, 10 Oct 2022 14:25:16 +0000 (15:25 +0100)
committerMarc Foley <m.foley.88@gmail.com>
Mon, 10 Oct 2022 14:25:16 +0000 (15:25 +0100)
Lib/axisregistry/__init__.py
tests/data/OpenSansCondensed-Italic[wght]_STAT.ttx
tests/data/OpenSansCondensed[wght]_STAT.ttx

index 162240c88aeedc4d65e1261180fa03c0690f1ccb..7617da0554b7cae555d7a8b555a860dd0e90067b 100644 (file)
@@ -179,17 +179,21 @@ def build_stat(ttFont, sibling_ttFonts=[]):
     fvar_instance_nameids = set(i.subfamilyNameID for i in fvar.instances)
     fvar_axis_nameids = set(a.axisNameID for a in fvar.axes)
     fvar_nameids = fvar_axis_nameids | fvar_instance_nameids
+    # These NameIDs are required for applications to work correctly so
+    # they cannot be deleted.
+    # https://learn.microsoft.com/en-us/typography/opentype/spec/name
+    keep_nameids = set(range(26)) | fvar_nameids
     if "STAT" in ttFont:
         stat = ttFont["STAT"]
         if stat.table.AxisValueCount > 0:
             axis_values = stat.table.AxisValueArray.AxisValue
             for ax in axis_values:
-                if ax.ValueNameID not in fvar_nameids:
+                if ax.ValueNameID not in keep_nameids:
                     nametable.removeNames(nameID=ax.ValueNameID)
         if stat.table.DesignAxisCount > 0:
             axes = stat.table.DesignAxisRecord.Axis
             for ax in axes:
-                if ax.AxisNameID not in fvar_nameids:
+                if ax.AxisNameID not in keep_nameids:
                     nametable.removeNames(nameID=ax.AxisNameID)
         del ttFont["STAT"]
 
index bd39b5cc82a475f828f9f0632748a3c765bbbc45..d0e9f35ca31a3ce8a6f1753307ebbc3a918ce83b 100644 (file)
@@ -88,7 +88,7 @@
   <AxisValue index="9" Format="1">
     <AxisIndex value="2"/>
     <Flags value="0"/>
-    <ValueNameID value="17"/>  <!-- Italic -->
+    <ValueNameID value="2"/>  <!-- Italic -->
     <Value value="1.0"/>
   </AxisValue>
   <AxisValue index="10" Format="3">
     <Value value="0.0"/>
   </AxisValue>
 </AxisValueArray>
-<ElidedFallbackNameID value="2"/>  <!-- missing from name table -->
\ No newline at end of file
+<ElidedFallbackNameID value="2"/>  <!-- Italic -->
\ No newline at end of file
index 503f3a4d3438140f82bef72d33e053d3cb12604b..db4d34c738523e1e12152a6a763214a5a3a9eea9 100644 (file)
@@ -51,7 +51,7 @@
   <AxisValue index="3" Format="3">
     <AxisIndex value="0"/>
     <Flags value="2"/>  <!-- ElidableAxisValueName -->
-    <ValueNameID value="260"/>  <!-- Regular -->
+    <ValueNameID value="2"/>  <!-- Regular -->
     <Value value="400.0"/>
     <LinkedValue value="700.0"/>
   </AxisValue>
     <LinkedValue value="1.0"/>
   </AxisValue>
 </AxisValueArray>
-<ElidedFallbackNameID value="2"/>  <!-- missing from name table -->
\ No newline at end of file
+<ElidedFallbackNameID value="2"/>  <!-- Regular -->
\ No newline at end of file