Skip to content

Commit

Permalink
better testing of italic/family relation, not just file names
Browse files Browse the repository at this point in the history
  • Loading branch information
benkiel committed Jan 12, 2025
1 parent 207e1b7 commit 1df308a
Show file tree
Hide file tree
Showing 2 changed files with 20 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
elif non_italic.familyname == italic.familyname:
found_roman = non_italic
break

if found_roman:
non_italics.remove(found_roman)
Expand Down
15 changes: 15 additions & 0 deletions Lib/fontbakery/testable.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,21 @@ def is_bold(self):
)
)

@cached_property
def familyname(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

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

return familyname


@dataclass
class TTCFont(Font):
Expand Down

0 comments on commit 1df308a

Please sign in to comment.