@@ -35,44 +35,49 @@ def get_font_report(fontpath):
35
35
hheaascdesc_to_upm = 1.0 * hhea_total_height / units_per_em
36
36
37
37
# The file path header
38
- report_string = " \n "
39
- report_string = report_string + "=== " + fontpath + " ===\n "
38
+ report = [ " " ]
39
+ report . append ( "=== " + fontpath + " ===" )
40
40
namerecord_list = tt ['name' ].names
41
41
# The version string
42
42
for needle in namerecord_list :
43
43
if needle .langID == 0 and needle .nameID == 5 :
44
- report_string += needle .toStr () + " \n "
44
+ report . append ( needle .toStr ())
45
45
break
46
46
# The SHA1 string
47
- report_string = report_string + "SHA1: " + get_sha1 (fontpath ) + "\n \n "
47
+ report .append ("SHA1: " + get_sha1 (fontpath ))
48
+ report .append ("" )
48
49
# The vertical metrics strings
49
- report_string = report_string + "--- Metrics ---" + "\n "
50
- report_string = report_string + "[head] Units per Em: \t " + str (units_per_em ) + "\n "
51
- report_string = report_string + "[head] yMax: \t \t " + str (ymax ) + "\n "
52
- report_string = report_string + "[head] yMin: \t \t " + str (ymin ) + "\n "
53
- report_string = report_string + "[OS/2] TypoAscender: \t " + str (os2_typo_ascender ) + "\n "
54
- report_string = report_string + "[OS/2] TypoDescender: \t " + str (os2_typo_descender ) + "\n "
55
- report_string = report_string + "[OS/2] WinAscent: \t " + str (os2_win_ascent ) + "\n "
56
- report_string = report_string + "[OS/2] WinDescent: \t " + str (os2_win_descent ) + "\n "
57
- report_string = report_string + "[hhea] Ascent: \t \t " + str (hhea_ascent ) + "\n "
58
- report_string = report_string + "[hhea] Descent: \t " + str (hhea_descent ) + "\n \n "
59
- report_string = report_string + "[hhea] LineGap: \t " + str (hhea_linegap ) + "\n "
60
- report_string = report_string + "[OS/2] TypoLineGap: \t " + str (os2_typo_linegap ) + "\n \n "
61
- report_string = report_string + "--- Height Calculations by Table Values ---" + "\n "
62
- report_string = report_string + "[OS/2] TypoAscender to TypoDescender: \t " + str (os2_typo_total_height ) + "\n "
63
- report_string = report_string + "[OS/2] WinAscent to WinDescent: \t " + str (os2_win_total_height ) + "\n "
64
- report_string = report_string + "[hhea] Ascent to Descent: \t \t " + str (hhea_total_height ) + "\n \n "
65
- report_string = report_string + "--- Delta Values ---" + "\n "
66
- report_string = report_string + "WinAscent to TypoAscender: \t " + str (os2_win_ascent - os2_typo_ascender ) + "\n "
67
- report_string = report_string + "Ascent to TypoAscender: \t " + str (hhea_ascent - os2_typo_ascender ) + "\n "
68
- report_string = report_string + "WinDescent to TypoDescender: \t " + str (os2_win_descent - - (os2_typo_descender )) + "\n "
69
- report_string = report_string + "Descent to TypoDescender: \t " + str (os2_typo_descender - hhea_descent ) + "\n \n "
70
- report_string = report_string + "--- Ratios ---" + "\n "
71
- report_string = report_string + "(Typo Asc + Desc + Linegap) / UPM: \t " + str ('{0:.3g}' .format (typo_to_upm )) + "\n "
72
- report_string = report_string + "(winAsc + winDesc) / UPM: \t \t " + str ('{0:.3g}' .format (winascdesc_to_upm )) + "\n "
73
- report_string = report_string + "(hhea Asc + Desc) / UPM: \t \t " + str ('{0:.3g}' .format (hheaascdesc_to_upm ))
74
-
75
- return report_string
50
+ report .append ("--- Metrics ---" )
51
+ report .append ("[head] Units per Em: \t {}" .format (units_per_em ))
52
+ report .append ("[head] yMax: \t \t {}" .format (ymax ))
53
+ report .append ("[head] yMin: \t \t {}" .format (ymin ))
54
+ report .append ("[OS/2] TypoAscender: \t {}" .format (os2_typo_ascender ))
55
+ report .append ("[OS/2] TypoDescender: \t {}" .format (os2_typo_descender ))
56
+ report .append ("[OS/2] WinAscent: \t {}" .format (os2_win_ascent ))
57
+ report .append ("[OS/2] WinDescent: \t {}" .format (os2_win_descent ))
58
+ report .append ("[hhea] Ascent: \t \t {}" .format (hhea_ascent ))
59
+ report .append ("[hhea] Descent: \t {}" .format (hhea_descent ))
60
+ report .append ("" )
61
+ report .append ("[hhea] LineGap: \t {}" .format (hhea_linegap ))
62
+ report .append ("[OS/2] TypoLineGap: \t {}" .format (os2_typo_linegap ))
63
+ report .append ("" )
64
+ report .append ("--- Height Calculations by Table Values ---" )
65
+ report .append ("[OS/2] TypoAscender to TypoDescender: \t {}" .format (os2_typo_total_height ))
66
+ report .append ("[OS/2] WinAscent to WinDescent: \t {}" .format (os2_win_total_height ))
67
+ report .append ("[hhea] Ascent to Descent: \t \t {}" .format (hhea_total_height ))
68
+ report .append ("" )
69
+ report .append ("--- Delta Values ---" )
70
+ report .append ("WinAscent to TypoAscender: \t {}" .format (os2_win_ascent - os2_typo_ascender ))
71
+ report .append ("Ascent to TypoAscender: \t {}" .format (hhea_ascent - os2_typo_ascender ))
72
+ report .append ("WinDescent to TypoDescender: \t {}" .format (os2_win_descent - - (os2_typo_descender )))
73
+ report .append ("Descent to TypoDescender: \t {}" .format (os2_typo_descender - hhea_descent ))
74
+ report .append ("" )
75
+ report .append ("--- Ratios ---" )
76
+ report .append ("(Typo Asc + Desc + Linegap) / UPM: \t {0:.3g}" .format (typo_to_upm ))
77
+ report .append ("(winAsc + winDesc) / UPM: \t \t {0:.3g}" .format (winascdesc_to_upm ))
78
+ report .append ("(hhea Asc + Desc) / UPM: \t \t {0:.3g}" .format (hheaascdesc_to_upm ))
79
+
80
+ return "\n " .join (report )
76
81
77
82
78
83
def modify_linegap_percent (fontpath , percent ):
0 commit comments