Skip to content

Commit 4a2f518

Browse files
committed
commands.py: replace obj.__dict__[attr] with obj.attr
1 parent 18e7e06 commit 4a2f518

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

lib/fontline/commands.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ def get_font_report(fontpath):
1414
tt = ttLib.TTFont(fontpath)
1515

1616
# 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
2828

2929
# Calculated values
3030
os2_typo_total_height = os2_typo_ascender + -(os2_typo_descender)
@@ -37,11 +37,11 @@ def get_font_report(fontpath):
3737
# The file path header
3838
report_string = " \n"
3939
report_string = report_string + "=== " + fontpath + " ===\n"
40-
namerecord_list = tt['name'].__dict__['names']
40+
namerecord_list = tt['name'].names
4141
# The version string
4242
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"
4545
# The SHA1 string
4646
report_string = report_string + "SHA1: " + get_sha1(fontpath) + "\n\n"
4747
# The vertical metrics strings
@@ -79,12 +79,12 @@ def modify_linegap_percent(fontpath, percent):
7979
tt = ttLib.TTFont(fontpath)
8080

8181
# 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
8888

8989
# calculate necessary delta values
9090
os2_typo_ascdesc_delta = os2_typo_ascender + -(os2_typo_descender)
@@ -130,14 +130,14 @@ def modify_linegap_percent(fontpath, percent):
130130
os2_win_descent = -hhea_descent
131131

132132
# 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
141141

142142
tt.save(get_linegap_percent_filepath(fontpath, percent))
143143
return True

0 commit comments

Comments
 (0)