Skip to content

Commit

Permalink
Adding code-tests for com.google.fonts/check/STAT/gf-axisregistry
Browse files Browse the repository at this point in the history
(issue #3022)
  • Loading branch information
felipesanches committed Oct 15, 2020
1 parent 469be4f commit 963bcbf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Lib/fontbakery/profiles/googlefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions tests/profiles/googlefonts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 963bcbf

Please sign in to comment.