Skip to content

Commit

Permalink
Deprecate opentype/STAT_has_axis_value_tables
Browse files Browse the repository at this point in the history
Because **inconsistencies_between_fvar_STAT** (now on `Universal`) potentially has a wider scope in the future, checking back from the fvar table to the STAT table.

(#4916 (comment))
  • Loading branch information
felipesanches committed Dec 21, 2024
1 parent b5398f9 commit d5cea96
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 213 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ A more detailed list of changes is available in the corresponding milestones for
#### On the Universal Profile
- **[kerning_for_non_ligated_sequences]**: "Is there kerning info for non-ligated sequences?" (issue #2954 / https://github.com/simoncozens/fontspector/commit/eaa52447ddc4a42e26b6430841a43026870d8a48)

#### On the OpenType Profile
- **[opentype/STAT_has_axis_value_tables]**: Because **inconsistencies_between_fvar_STAT** (now on `Universal`) potentially has a wider scope in the future, checking back from the fvar table to the STAT table. (https://github.com/fonttools/fontbakery/issues/4916#issuecomment-2507999113)

### Changes to existing checks
### On the Universal profile
- **[smallcaps_before_ligatures]:** This check works just fine on OTFs, no need for `conditions=["is_ttf"]` (issue #4920)
Expand Down
95 changes: 0 additions & 95 deletions Lib/fontbakery/checks/opentype/STAT_has_axis_value_tables.py

This file was deleted.

14 changes: 0 additions & 14 deletions Lib/fontbakery/profiles/adobefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,6 @@
"Fonts that do not meet these guidelines might behave inconsistently so please carefully consider trying to meet them.",
},
],
"opentype/STAT_has_axis_value_tables": [
{
"code": "missing-axis-value-table",
"status": "WARN",
"reason": "Adobe and the OpenType spec strongly recommend following these guidelines, but they are not hard requirements so we are relaxing this to WARN rather than FAIL.\n"
"Fonts that do not meet these guidelines might behave inconsistently so please carefully consider trying to meet them.",
},
{
"code": "format-4-axis-count",
"status": "WARN",
"reason": "Adobe and the OpenType spec strongly recommend following these guidelines, but they are not hard requirements so we are relaxing this to WARN rather than FAIL.\n"
"Fonts that do not meet these guidelines might behave inconsistently so please carefully consider trying to meet them.",
},
],
"inconsistencies_between_fvar_STAT": [
{
"code": "missing-fvar-instance-axis-value",
Expand Down
1 change: 0 additions & 1 deletion Lib/fontbakery/profiles/opentype.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"opentype/postscript_name",
"opentype/post_table_version",
"opentype/slant_direction",
"opentype/STAT_has_axis_value_tables",
"opentype/unitsperem",
"opentype/varfont/distinct_instance_records",
"opentype/varfont/family_axis_ranges",
Expand Down
32 changes: 0 additions & 32 deletions tests/test_checks_adobefonts_overrides.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from unittest.mock import patch

from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.otTables import AxisValueRecord
import requests

from conftest import check_id
Expand Down Expand Up @@ -189,37 +188,6 @@ def test_check_override_varfont_valid_default_instance_nameids(check):
assert "Overridden" in msg


@check_id("opentype/STAT_has_axis_value_tables", profile=adobefonts_profile)
def test_check_override_STAT_has_axis_value_tables(check):
"""Check that overridden tests yield the right result."""

# Our reference Cabin[wdth,wght].ttf variable font has Axis Value tables.
ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf"))
# Remove the 4th Axis Value table (index 3), belonging to 'Medium' weight.
# The overridden check should WARN.
ttFont["STAT"].table.AxisValueArray.AxisValue.pop(3)
msg = assert_results_contain(check(ttFont), WARN, "missing-axis-value-table")
assert "STAT table is missing Axis Value for 'wght' value '500.0'" in msg
assert "Overridden" in msg

# Add a format 4 AxisValue table with a single AxisValueRecord. This overriden check
# should WARN.
ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf"))
f4avt = type(ttFont["STAT"].table.AxisValueArray.AxisValue[0])()
f4avt.Format = 4
f4avt.Flags = 0
f4avt.ValueNameID = 2
avr0 = AxisValueRecord()
avr0.AxisIndex = 0
avr0.Value = 100
f4avt.AxisValueRecord = [avr0]
f4avt.AxisCount = len(f4avt.AxisValueRecord)
ttFont["STAT"].table.AxisValueArray.AxisValue.append(f4avt)
msg = assert_results_contain(check(ttFont), WARN, "format-4-axis-count")
assert "STAT Format 4 Axis Value table has axis count <= 1." in msg
assert "Overridden" in msg


@check_id("inconsistencies_between_fvar_STAT", profile=adobefonts_profile)
def test_check_override_inconsistencies_between_fvar_STAT(check):
"""Check that the overridden test yields WARN rather than FAIL"""
Expand Down
71 changes: 0 additions & 71 deletions tests/test_checks_opentype_stat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.otTables import AxisValueRecord

from conftest import check_id
from fontbakery.status import FAIL, SKIP, WARN
Expand Down Expand Up @@ -37,76 +36,6 @@ def test_check_varfont_STAT_axis_record_for_each_axis(check):
assert "Unfulfilled Conditions: is_variable_font" in msg


@check_id("opentype/STAT_has_axis_value_tables")
def test_check_STAT_has_axis_value_tables(check):
"""Check the STAT table has at least one Axis Value table."""

# Our reference Cabin[wdth,wght].ttf variable font has Axis Value tables.
# So the check must PASS.
ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf"))
assert_PASS(check(ttFont))

# Remove the 4th Axis Value table (index 3), belonging to 'Medium' weight.
# The check should FAIL.
ttFont["STAT"].table.AxisValueArray.AxisValue.pop(3)
msg = assert_results_contain(check(ttFont), FAIL, "missing-axis-value-table")
assert msg == "STAT table is missing Axis Value for 'wght' value '500.0'"

# Now remove all Axis Value tables by emptying the AxisValueArray.
# The check should FAIL.
ttFont["STAT"].table.AxisValueArray = None
ttFont["STAT"].table.AxisValueCount = 0
msg = assert_results_contain(check(ttFont), FAIL, "no-axis-value-tables")
assert msg == "STAT table has no Axis Value tables."

# Most of the Axis Value tables in Cabin[wdth,wght].ttf are format 1.
# Now test with SourceSansVariable-Italic.ttf whose tables are mostly format 2.
ttFont = TTFont(TEST_FILE("source-sans-pro/VAR/SourceSansVariable-Italic.ttf"))
assert_PASS(check(ttFont))

# Remove the 2nd Axis Value table (index 1), belonging to 'Light' weight.
# The check should FAIL.
ttFont["STAT"].table.AxisValueArray.AxisValue.pop(1)
msg = assert_results_contain(check(ttFont), FAIL, "missing-axis-value-table")
assert msg == "STAT table is missing Axis Value for 'wght' value '300.0'"

# Now use a font that has no STAT table.
# The check should be skipped due to an unfulfilled condition.
ttFont = TTFont(TEST_FILE("source-sans-pro/TTF/SourceSansPro-Black.ttf"))
msg = assert_results_contain(check(ttFont), SKIP, "unfulfilled-conditions")
assert "Unfulfilled Conditions: has_STAT_table" in msg

# Add a format 4 AxisValue table with 2 AxisValueRecords. This should PASS.
ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf"))
f4avt = type(ttFont["STAT"].table.AxisValueArray.AxisValue[0])()
f4avt.Format = 4
f4avt.Flags = 0
f4avt.ValueNameID = 2
avr0 = AxisValueRecord()
avr0.AxisIndex = 0
avr0.Value = 100
avr1 = AxisValueRecord()
avr1.AxisIndex = 1
avr1.Value = 400
f4avt.AxisValueRecord = [avr0, avr1]
f4avt.AxisCount = len(f4avt.AxisValueRecord)
ttFont["STAT"].table.AxisValueArray.AxisValue.append(f4avt)
assert_PASS(check(ttFont))

# Now delete one of the AxisValueRecords of the just-added format 4 AxisValue table.
# This should now FAIL since format 4 should contain at least 2 AxisValueRecords.
del ttFont["STAT"].table.AxisValueArray.AxisValue[7].AxisValueRecord[1]
ttFont["STAT"].table.AxisValueArray.AxisValue[7].AxisCount = 1
msg = assert_results_contain(check(ttFont), FAIL, "format-4-axis-count")
assert msg == "STAT Format 4 Axis Value table has axis count <= 1."

# An unknown AxisValue table Format should FAIL.
ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf"))
ttFont["STAT"].table.AxisValueArray.AxisValue[0].Format = 5
msg = assert_results_contain(check(ttFont), FAIL, "unknown-axis-value-format")
assert msg == "AxisValue format 5 is unknown."


@check_id("opentype/italic_axis_in_STAT")
def test_check_italic_axis_in_STAT(check):
"""Ensure VFs have 'ital' STAT axis."""
Expand Down

0 comments on commit d5cea96

Please sign in to comment.