Skip to content

Commit

Permalink
Rework segment_vf_collection
Browse files Browse the repository at this point in the history
* better testing of italic/family relation, not just file names
* Update ital_axis.py
* fix error due to familyname in name space

(PR #4966)
  • Loading branch information
benkiel authored Jan 22, 2025
1 parent 4ad9252 commit bdf627a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Lib/fontbakery/checks/opentype/STAT/ital_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def segment_vf_collection(fonts):
for font in fonts:
if "-Italic[" in font.file:
italics.append(font)
elif font.is_italic:
italics.append(font)
else:
non_italics.append(font)

Expand All @@ -109,6 +111,9 @@ def segment_vf_collection(fonts):
if non_italic.file == suspected_roman:
found_roman = non_italic
break
if non_italic.family == italic.family:
found_roman = non_italic
break

if found_roman:
non_italics.remove(found_roman)
Expand Down
17 changes: 17 additions & 0 deletions Lib/fontbakery/testable.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ def ttFont(self):
font.ensureDecompiled()
return font

@cached_property
def family(self):
from fontbakery.utils import get_name_entry_strings
from fontbakery.constants import NameID

ttFont = self.ttFont
familynames = get_name_entry_strings(ttFont, NameID.FONT_FAMILY_NAME)
typo_familynames = get_name_entry_strings(
ttFont, NameID.TYPOGRAPHIC_FAMILY_NAME
)
if not familynames:
return None

family = typo_familynames[0] if typo_familynames else familynames[0]

return family

@cached_property
def style(self):
"""Determine font style from canonical filename."""
Expand Down

0 comments on commit bdf627a

Please sign in to comment.