From 2b231635361a99faa4971ca6f7e37f6fcc4d91e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 14 Oct 2020 20:46:30 -0300 Subject: [PATCH] Adding code-tests for com.google.fonts/check/STAT/gf-axisregistry (issue #3022) --- Lib/fontbakery/profiles/googlefonts.py | 5 +++-- tests/profiles/googlefonts_test.py | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Lib/fontbakery/profiles/googlefonts.py b/Lib/fontbakery/profiles/googlefonts.py index e17765b817..3b9c1e0ed9 100644 --- a/Lib/fontbakery/profiles/googlefonts.py +++ b/Lib/fontbakery/profiles/googlefonts.py @@ -4839,8 +4839,9 @@ def normalize_name(name): passed = False yield FAIL, \ Message("bad-coordinate", - (f"Axis Value for '{axis.AxisTag}':'{fb.name}' is expected to be 'fb.value'" - f" but this font has '{fb.name}'='{axis_value.Value}'.")) + (f"Axis Value for '{axis.AxisTag}':'{name_entry.toUnicode()}' is" + f" expected to be 'fallbacks[name_entry.toUnicode()]'" + f" but this font has '{name_entry.toUnicode()}'='{axis_value.Value}'.")) if passed: yield PASS, "OK" diff --git a/tests/profiles/googlefonts_test.py b/tests/profiles/googlefonts_test.py index 0c5e8808cd..0431db8e17 100644 --- a/tests/profiles/googlefonts_test.py +++ b/tests/profiles/googlefonts_test.py @@ -3408,3 +3408,25 @@ def test_check_gf_axisregistry_valid_tags(): assert_results_contain(check(ttFont, {"family_metadata": md}), FAIL, "bad-axis-tag") + +def test_check_STAT_gf_axisregistry(): + """Validate STAT particle names and values match the fallback names in GFAxisRegistry.""" + check = CheckTester(googlefonts_profile, + "com.google.fonts/check/STAT/gf-axisregistry") + # Our reference varfont, CabinVF, + # has "Regular", instead of "Roman" in its 'ital' axis on the STAT table: + ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf")) + assert_results_contain(check(ttFont), + FAIL, "invalid-name") + + # LibreCaslonText is good though: + ttFont = TTFont(TEST_FILE("librecaslontext/LibreCaslonText[wght].ttf")) + assert_PASS(check(ttFont)) + + # Finally, we'll break it by setting an invalid coordinate for "Bold": + assert ttFont['STAT'].table.AxisValueArray.AxisValue[3].ValueNameID == ttFont['name'].names[4].nameID + assert ttFont['name'].names[4].toUnicode() == "Bold" + ttFont['STAT'].table.AxisValueArray.AxisValue[3].Value = 800 # instead of the expected 700 + # Note: I know it is AxisValue[3] and names[4] because I inspected the font using ttx. + assert_results_contain(check(ttFont), + FAIL, "bad-coordinate")