@@ -14,17 +14,17 @@ def get_font_report(fontpath):
14
14
tt = ttLib .TTFont (fontpath )
15
15
16
16
# Vertical metrics values as integers
17
- os2_typo_ascender = tt ['OS/2' ].__dict__ [ ' sTypoAscender' ]
18
- os2_typo_descender = tt ['OS/2' ].__dict__ [ ' sTypoDescender' ]
19
- os2_win_ascent = tt ['OS/2' ].__dict__ [ ' usWinAscent' ]
20
- os2_win_descent = tt ['OS/2' ].__dict__ [ ' usWinDescent' ]
21
- os2_typo_linegap = tt ['OS/2' ].__dict__ [ ' sTypoLineGap' ]
22
- hhea_ascent = tt ['hhea' ].__dict__ [ ' ascent' ]
23
- hhea_descent = tt ['hhea' ].__dict__ [ ' descent' ]
24
- hhea_linegap = tt ['hhea' ].__dict__ [ ' lineGap' ]
25
- ymax = tt ['head' ].__dict__ [ ' yMax' ]
26
- ymin = tt ['head' ].__dict__ [ ' yMin' ]
27
- units_per_em = tt ['head' ].__dict__ [ ' unitsPerEm' ]
17
+ os2_typo_ascender = tt ['OS/2' ].sTypoAscender
18
+ os2_typo_descender = tt ['OS/2' ].sTypoDescender
19
+ os2_win_ascent = tt ['OS/2' ].usWinAscent
20
+ os2_win_descent = tt ['OS/2' ].usWinDescent
21
+ os2_typo_linegap = tt ['OS/2' ].sTypoLineGap
22
+ hhea_ascent = tt ['hhea' ].ascent
23
+ hhea_descent = tt ['hhea' ].descent
24
+ hhea_linegap = tt ['hhea' ].lineGap
25
+ ymax = tt ['head' ].yMax
26
+ ymin = tt ['head' ].yMin
27
+ units_per_em = tt ['head' ].unitsPerEm
28
28
29
29
# Calculated values
30
30
os2_typo_total_height = os2_typo_ascender + - (os2_typo_descender )
@@ -37,11 +37,11 @@ def get_font_report(fontpath):
37
37
# The file path header
38
38
report_string = " \n "
39
39
report_string = report_string + "=== " + fontpath + " ===\n "
40
- namerecord_list = tt ['name' ].__dict__ [ ' names' ]
40
+ namerecord_list = tt ['name' ].names
41
41
# The version string
42
42
for needle in namerecord_list :
43
- if needle .__dict__ [ ' langID' ] == 0 and needle .__dict__ [ ' nameID' ] == 5 :
44
- report_string = report_string + str (needle .__dict__ [ ' string' ] ) + "\n "
43
+ if needle .langID == 0 and needle .nameID == 5 :
44
+ report_string = report_string + str (needle .string ) + "\n "
45
45
# The SHA1 string
46
46
report_string = report_string + "SHA1: " + get_sha1 (fontpath ) + "\n \n "
47
47
# The vertical metrics strings
@@ -79,12 +79,12 @@ def modify_linegap_percent(fontpath, percent):
79
79
tt = ttLib .TTFont (fontpath )
80
80
81
81
# get observed start values from the font
82
- os2_typo_ascender = tt ['OS/2' ].__dict__ [ ' sTypoAscender' ]
83
- os2_typo_descender = tt ['OS/2' ].__dict__ [ ' sTypoDescender' ]
84
- os2_typo_linegap = tt ['OS/2' ].__dict__ [ ' sTypoLineGap' ]
85
- hhea_ascent = tt ['hhea' ].__dict__ [ ' ascent' ]
86
- hhea_descent = tt ['hhea' ].__dict__ [ ' descent' ]
87
- units_per_em = tt ['head' ].__dict__ [ ' unitsPerEm' ]
82
+ os2_typo_ascender = tt ['OS/2' ].sTypoAscender
83
+ os2_typo_descender = tt ['OS/2' ].sTypoDescender
84
+ os2_typo_linegap = tt ['OS/2' ].sTypoLineGap
85
+ hhea_ascent = tt ['hhea' ].ascent
86
+ hhea_descent = tt ['hhea' ].descent
87
+ units_per_em = tt ['head' ].unitsPerEm
88
88
89
89
# calculate necessary delta values
90
90
os2_typo_ascdesc_delta = os2_typo_ascender + - (os2_typo_descender )
@@ -130,14 +130,14 @@ def modify_linegap_percent(fontpath, percent):
130
130
os2_win_descent = - hhea_descent
131
131
132
132
# define updated values from above calculations
133
- tt ['hhea' ].__dict__ [ ' lineGap' ] = hhea_linegap
134
- tt ['OS/2' ].__dict__ [ ' sTypoAscender' ] = os2_typo_ascender
135
- tt ['OS/2' ].__dict__ [ ' sTypoDescender' ] = os2_typo_descender
136
- tt ['OS/2' ].__dict__ [ ' sTypoLineGap' ] = os2_typo_linegap
137
- tt ['OS/2' ].__dict__ [ ' usWinAscent' ] = os2_win_ascent
138
- tt ['OS/2' ].__dict__ [ ' usWinDescent' ] = os2_win_descent
139
- tt ['hhea' ].__dict__ [ ' ascent' ] = hhea_ascent
140
- tt ['hhea' ].__dict__ [ ' descent' ] = hhea_descent
133
+ tt ['hhea' ].lineGap = hhea_linegap
134
+ tt ['OS/2' ].sTypoAscender = os2_typo_ascender
135
+ tt ['OS/2' ].sTypoDescender = os2_typo_descender
136
+ tt ['OS/2' ].sTypoLineGap = os2_typo_linegap
137
+ tt ['OS/2' ].usWinAscent = os2_win_ascent
138
+ tt ['OS/2' ].usWinDescent = os2_win_descent
139
+ tt ['hhea' ].ascent = hhea_ascent
140
+ tt ['hhea' ].descent = hhea_descent
141
141
142
142
tt .save (get_linegap_percent_filepath (fontpath , percent ))
143
143
return True
0 commit comments