Skip to content

Commit bdf627a

Browse files
authored
Rework segment_vf_collection
* better testing of italic/family relation, not just file names * Update ital_axis.py * fix error due to familyname in name space (PR #4966)
1 parent 4ad9252 commit bdf627a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Lib/fontbakery/checks/opentype/STAT/ital_axis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ def segment_vf_collection(fonts):
9797
for font in fonts:
9898
if "-Italic[" in font.file:
9999
italics.append(font)
100+
elif font.is_italic:
101+
italics.append(font)
100102
else:
101103
non_italics.append(font)
102104

@@ -109,6 +111,9 @@ def segment_vf_collection(fonts):
109111
if non_italic.file == suspected_roman:
110112
found_roman = non_italic
111113
break
114+
if non_italic.family == italic.family:
115+
found_roman = non_italic
116+
break
112117

113118
if found_roman:
114119
non_italics.remove(found_roman)

Lib/fontbakery/testable.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ def ttFont(self):
8686
font.ensureDecompiled()
8787
return font
8888

89+
@cached_property
90+
def family(self):
91+
from fontbakery.utils import get_name_entry_strings
92+
from fontbakery.constants import NameID
93+
94+
ttFont = self.ttFont
95+
familynames = get_name_entry_strings(ttFont, NameID.FONT_FAMILY_NAME)
96+
typo_familynames = get_name_entry_strings(
97+
ttFont, NameID.TYPOGRAPHIC_FAMILY_NAME
98+
)
99+
if not familynames:
100+
return None
101+
102+
family = typo_familynames[0] if typo_familynames else familynames[0]
103+
104+
return family
105+
89106
@cached_property
90107
def style(self):
91108
"""Determine font style from canonical filename."""

0 commit comments

Comments
 (0)