Skip to content

Commit

Permalink
splitting out checks into individual files
Browse files Browse the repository at this point in the history
  • Loading branch information
felipesanches committed Nov 22, 2024
1 parent c995480 commit 2a5225f
Show file tree
Hide file tree
Showing 155 changed files with 1,768 additions and 1,671 deletions.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
from fontbakery.prelude import FAIL, Message, check


def is_covered_in_stat(ttFont, axis_tag, value):
def is_covered_in_STAT(ttFont, axis_tag, value):
if "STAT" not in ttFont:
return False
stat_table = ttFont["STAT"].table
if stat_table.AxisValueCount == 0:
STAT_table = ttFont["STAT"].table
if STAT_table.AxisValueCount == 0:
return False
for ax_value in stat_table.AxisValueArray.AxisValue:
for ax_value in STAT_table.AxisValueArray.AxisValue:
ax_value_format = ax_value.Format
stat_value = []
STAT_value = []
if ax_value_format in (1, 2, 3):
axis_tag_stat = stat_table.DesignAxisRecord.Axis[ax_value.AxisIndex].AxisTag
if axis_tag != axis_tag_stat:
axis_tag_STAT = STAT_table.DesignAxisRecord.Axis[ax_value.AxisIndex].AxisTag
if axis_tag != axis_tag_STAT:
continue

if ax_value_format in (1, 3):
stat_value.append(ax_value.Value)
STAT_value.append(ax_value.Value)

if ax_value_format == 3:
stat_value.append(ax_value.LinkedValue)
STAT_value.append(ax_value.LinkedValue)

if ax_value_format == 2:
stat_value.append(ax_value.NominalValue)
STAT_value.append(ax_value.NominalValue)

if ax_value_format == 4:
# TODO: Need to implement
# locations check as well
pass

if value in stat_value:
if value in STAT_value:
return True

return False


@check(
id="inconsistencies_between_fvar_stat",
id="inconsistencies_between_fvar_STAT",
rationale="""
Check for inconsistencies in names and values between the fvar instances
and STAT table. Inconsistencies may cause issues in apps like Adobe InDesign.
""",
conditions=["is_variable_font"],
proposal="https://github.com/fonttools/fontbakery/pull/3636",
)
def check_inconsistencies_between_fvar_stat(ttFont):
def check_inconsistencies_between_fvar_STAT(ttFont):
"""Checking if STAT entries matches fvar and vice versa."""

if "STAT" not in ttFont:
return FAIL, Message(
"missing-stat-table", "Missing STAT table in variable font."
"missing-STAT-table", "Missing STAT table in variable font."
)
fvar = ttFont["fvar"]
name = ttFont["name"]
Expand All @@ -65,7 +65,7 @@ def check_inconsistencies_between_fvar_stat(ttFont):
continue

for axis_tag, value in ins.coordinates.items():
if not is_covered_in_stat(ttFont, axis_tag, value):
if not is_covered_in_STAT(ttFont, axis_tag, value):
yield FAIL, Message(
"missing-fvar-instance-axis-value",
f"{instance_name}: '{axis_tag}' axis value '{value}'"
Expand Down
Loading

0 comments on commit 2a5225f

Please sign in to comment.