Merge pull request #95 from m4rc1e/sibling-fallbacks
build_stat: improve elided axisvalues
diff --git a/Lib/axisregistry/__init__.py b/Lib/axisregistry/__init__.py
index 7617da0..7d2ccf6 100644
--- a/Lib/axisregistry/__init__.py
+++ b/Lib/axisregistry/__init__.py
@@ -234,14 +234,17 @@
for axis, fallback in fallbacks_in_siblings:
if axis in seen_axes:
continue
- value = 0.0
+ elided_value = axis_registry[axis].default_value
+ elided_fallback = axis_registry.fallback_for_value(axis, elided_value)
a = {
"tag": axis,
"name": axis_registry[axis].display_name,
- "values": [{"name": "Normal", "value": value, "flags": 0x2}],
+ "values": [
+ {"name": elided_fallback.name, "value": elided_value, "flags": 0x2}
+ ],
}
- if axis in LINKED_VALUES and value in LINKED_VALUES[axis]:
- a["values"][0]["linkedValue"] = LINKED_VALUES[axis][value]
+ if axis in LINKED_VALUES and elided_value in LINKED_VALUES[axis]:
+ a["values"][0]["linkedValue"] = LINKED_VALUES[axis][elided_value]
res.append(a)
buildStatTable(ttFont, res, macNames=False)
diff --git "a/tests/data/OpenSans-Italic\133wdth,wght\135_STAT.ttx" "b/tests/data/OpenSans-Italic\133wdth,wght\135_STAT.ttx"
index 6b82b0f..0cd2433 100644
--- "a/tests/data/OpenSans-Italic\133wdth,wght\135_STAT.ttx"
+++ "b/tests/data/OpenSans-Italic\133wdth,wght\135_STAT.ttx"
@@ -89,7 +89,7 @@
<AxisValue index="10" Format="3">
<AxisIndex value="3"/>
<Flags value="2"/> <!-- ElidableAxisValueName -->
- <ValueNameID value="288"/> <!-- Normal -->
+ <ValueNameID value="289"/> <!-- Roman -->
<Value value="0.0"/>
<LinkedValue value="1.0"/>
</AxisValue>
diff --git "a/tests/data/OpenSansCondensed-Italic\133wght\135_STAT.ttx" "b/tests/data/OpenSansCondensed-Italic\133wght\135_STAT.ttx"
index d0e9f35..8c3c2b9 100644
--- "a/tests/data/OpenSansCondensed-Italic\133wght\135_STAT.ttx"
+++ "b/tests/data/OpenSansCondensed-Italic\133wght\135_STAT.ttx"
@@ -94,15 +94,15 @@
<AxisValue index="10" Format="3">
<AxisIndex value="3"/>
<Flags value="2"/> <!-- ElidableAxisValueName -->
- <ValueNameID value="529"/> <!-- Normal -->
+ <ValueNameID value="529"/> <!-- Roman -->
<Value value="0.0"/>
<LinkedValue value="1.0"/>
</AxisValue>
<AxisValue index="11" Format="1">
<AxisIndex value="4"/>
<Flags value="2"/> <!-- ElidableAxisValueName -->
- <ValueNameID value="529"/> <!-- Normal -->
- <Value value="0.0"/>
+ <ValueNameID value="530"/> <!-- Normal -->
+ <Value value="100.0"/>
</AxisValue>
</AxisValueArray>
<ElidedFallbackNameID value="2"/> <!-- Italic -->
\ No newline at end of file
diff --git "a/tests/data/OpenSansCondensed\133wght\135_STAT.ttx" "b/tests/data/OpenSansCondensed\133wght\135_STAT.ttx"
index db4d34c..465a86c 100644
--- "a/tests/data/OpenSansCondensed\133wght\135_STAT.ttx"
+++ "b/tests/data/OpenSansCondensed\133wght\135_STAT.ttx"
@@ -88,7 +88,7 @@
<AxisValue index="9" Format="3">
<AxisIndex value="2"/>
<Flags value="2"/> <!-- ElidableAxisValueName -->
- <ValueNameID value="280"/> <!-- Normal -->
+ <ValueNameID value="466"/> <!-- Roman -->
<Value value="0.0"/>
<LinkedValue value="1.0"/>
</AxisValue>
@@ -96,12 +96,12 @@
<AxisIndex value="3"/>
<Flags value="2"/> <!-- ElidableAxisValueName -->
<ValueNameID value="280"/> <!-- Normal -->
- <Value value="0.0"/>
+ <Value value="100.0"/>
</AxisValue>
<AxisValue index="11" Format="3">
<AxisIndex value="4"/>
<Flags value="2"/> <!-- ElidableAxisValueName -->
- <ValueNameID value="280"/> <!-- Normal -->
+ <ValueNameID value="466"/> <!-- Roman -->
<Value value="0.0"/>
<LinkedValue value="1.0"/>
</AxisValue>
diff --git "a/tests/data/OpenSans\133wdth,wght\135_STAT.ttx" "b/tests/data/OpenSans\133wdth,wght\135_STAT.ttx"
index 7ab8b63..d41cf38 100644
--- "a/tests/data/OpenSans\133wdth,wght\135_STAT.ttx"
+++ "b/tests/data/OpenSans\133wdth,wght\135_STAT.ttx"
@@ -83,14 +83,14 @@
<AxisValue index="9" Format="3">
<AxisIndex value="2"/>
<Flags value="2"/> <!-- ElidableAxisValueName -->
- <ValueNameID value="283"/> <!-- Normal -->
+ <ValueNameID value="285"/> <!-- Roman -->
<Value value="0.0"/>
<LinkedValue value="1.0"/>
</AxisValue>
<AxisValue index="10" Format="3">
<AxisIndex value="3"/>
<Flags value="2"/> <!-- ElidableAxisValueName -->
- <ValueNameID value="283"/> <!-- Normal -->
+ <ValueNameID value="285"/> <!-- Roman -->
<Value value="0.0"/>
<LinkedValue value="1.0"/>
</AxisValue>
diff --git a/tests/test_names.py b/tests/test_names.py
index 1a90796..18543a3 100644
--- a/tests/test_names.py
+++ b/tests/test_names.py
@@ -448,7 +448,7 @@
build_stat(font, siblings)
stat_fp = fp.replace(".ttf", "_STAT.ttx")
- ### output good files
+ ## output good files
# with open(stat_fp, "w") as doc:
# got = dump(font["STAT"], font)
# doc.write(got)