From: Marc Foley Date: Fri, 14 Apr 2023 09:29:21 +0000 (+0100) Subject: build_stat: do not include linkedValues if they are outside of the axis range X-Git-Tag: v0.4.2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd212a015a522ba44c8bc2795a92127ca56a8fde;p=thirdparty%2Fgoogle%2Ffonts.git build_stat: do not include linkedValues if they are outside of the axis range --- diff --git a/Lib/axisregistry/__init__.py b/Lib/axisregistry/__init__.py index bade5a79fc..30278fa915 100644 --- a/Lib/axisregistry/__init__.py +++ b/Lib/axisregistry/__init__.py @@ -219,7 +219,9 @@ def build_stat(ttFont, sibling_ttFonts=[]): } ) if axis in LINKED_VALUES and fallback.value in LINKED_VALUES[axis]: - a["values"][-1]["linkedValue"] = LINKED_VALUES[axis][fallback.value] + linked_value = LINKED_VALUES[axis][fallback.value] + if any(f.value == linked_value for f in fallbacks): + a["values"][-1]["linkedValue"] = linked_value res.append(a) for axis, fallback in fallbacks_in_names: @@ -231,7 +233,8 @@ def build_stat(ttFont, sibling_ttFonts=[]): "values": [{"name": fallback.name, "value": fallback.value, "flags": 0x0}], } if axis in LINKED_VALUES and fallback.value in LINKED_VALUES[axis]: - a["values"][0]["linkedValue"] = LINKED_VALUES[axis][fallback.value] + linked_value = LINKED_VALUES[axis][fallback.value] + a["values"][0]["linkedValue"] = linked_value res.append(a) for axis, fallback in fallbacks_in_siblings: diff --git a/tests/data/Wavefont[ROND,YALN,wght].ttf b/tests/data/Wavefont[ROND,YALN,wght].ttf new file mode 100644 index 0000000000..b04e28047d Binary files /dev/null and b/tests/data/Wavefont[ROND,YALN,wght].ttf differ diff --git a/tests/data/Wavefont[ROND,YALN,wght]_STAT.ttx b/tests/data/Wavefont[ROND,YALN,wght]_STAT.ttx new file mode 100644 index 0000000000..22645ba481 --- /dev/null +++ b/tests/data/Wavefont[ROND,YALN,wght]_STAT.ttx @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/test_names.py b/tests/test_names.py index af65b5bb19..d196b283dd 100644 --- a/tests/test_names.py +++ b/tests/test_names.py @@ -26,6 +26,7 @@ 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") +wavefont_fp = os.path.join(DATA_DIR, "Wavefont[ROND,YALN,wght].ttf") @pytest.fixture @@ -294,7 +295,8 @@ def _test_names(ttFont, expected): (17, 3, 1, 0x409): None, }, ), - # Test opsz particle is kept + # Test opsz particle is kept. + # Fixes https://github.com/googlefonts/axisregistry/issues/130 ( playfair_fp, "Playfair", @@ -457,6 +459,9 @@ def dump(table, ttFont=None): [opensans_roman_fp, opensans_italic_fp, opensans_cond_roman_fp], ), (wonky_fp, []), + # don't add a linkedValue for Regular to Bold since Bold doensn't exist + # Fixes https://github.com/googlefonts/axisregistry/issues/104 + (wavefont_fp, []), ], ) def test_stat(fp, sibling_fps):