Skip to content

Commit 123fbb7

Browse files
committed
fix for AttributeError exception raised when xHeight and CapHeight values are missing from OS/2 table in some fonts (#14) cc:@gingerbeardman
1 parent 3087bf9 commit 123fbb7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/fontline/commands.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ def get_font_report(fontpath):
1919
os2_win_ascent = tt['OS/2'].usWinAscent
2020
os2_win_descent = tt['OS/2'].usWinDescent
2121
os2_typo_linegap = tt['OS/2'].sTypoLineGap
22-
os2_x_height = tt['OS/2'].sxHeight
23-
os2_cap_height = tt['OS/2'].sCapHeight
22+
try:
23+
os2_x_height = tt['OS/2'].sxHeight
24+
except AttributeError as e:
25+
os2_x_height = "---- (OS/2 table does not contain sxHeight record)"
26+
try:
27+
os2_cap_height = tt['OS/2'].sCapHeight
28+
except AttributeError as e:
29+
os2_cap_height = "---- (OS/2 table does not contain sCapHeight record)"
2430
hhea_ascent = tt['hhea'].ascent
2531
hhea_descent = tt['hhea'].descent
2632
hhea_linegap = tt['hhea'].lineGap

0 commit comments

Comments
 (0)