Skip to content

Commit 91e64b7

Browse files
committed
added new data types to the metrics report
1 parent 426174f commit 91e64b7

File tree

4 files changed

+48
-14
lines changed

4 files changed

+48
-14
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
## Changelog
22

3+
### v0.5.3
4+
5+
- added [head] yMax to report
6+
- added [head] yMin to report
7+
- added [OS/2] (TypoAscender + TypoDescender + TypoLineGap) / UPM to report
8+
- added [OS/2] (winAsc + winDesc) / UPM to report
9+
- added [OS/2] (hhea Asc + Desc) / UPM to report
10+
- removed [OS/2] TypoLineGap / UPM from the report
11+
312
### v0.5.2
413

514
- percent command: now forces entry of a percent integer value > 0, reports error & exits with attempts to enter values <= 0

coverage.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ coverage run --source fontline -m py.test
44
coverage report -m
55
coverage html
66

7-
coverage xml
8-
codecov --token=$CODECOV_FONTLINE
7+
#coverage xml
8+
#codecov --token=$CODECOV_FONTLINE

lib/fontline/commands.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ def get_font_report(fontpath):
2121
hhea_ascent = tt['hhea'].__dict__['ascent']
2222
hhea_descent = tt['hhea'].__dict__['descent']
2323
hhea_linegap = tt['hhea'].__dict__['lineGap']
24+
ymax = tt['head'].__dict__['yMax']
25+
ymin = tt['head'].__dict__['yMin']
2426
units_per_em = tt['head'].__dict__['unitsPerEm']
2527

26-
linegap_to_upm = 1.0 * os2_typo_linegap / units_per_em
27-
2828
# Calculated values
2929
os2_typo_total_height = os2_typo_ascender + -(os2_typo_descender)
3030
os2_win_total_height = os2_win_ascent + os2_win_descent
3131
hhea_total_height = hhea_ascent + -(hhea_descent)
32+
typo_to_upm = 1.0 * (os2_typo_linegap + os2_typo_total_height) / units_per_em
33+
winascdesc_to_upm = 1.0 * os2_win_total_height / units_per_em
34+
hheaascdesc_to_upm = 1.0 * hhea_total_height / units_per_em
3235

3336
# The file path header
3437
report_string = " \n"
@@ -41,7 +44,10 @@ def get_font_report(fontpath):
4144
# The SHA1 string
4245
report_string = report_string + "SHA1: " + get_sha1(fontpath) + "\n\n"
4346
# The vertical metrics strings
47+
report_string = report_string + "--- Metrics ---" + "\n"
4448
report_string = report_string + "[head] Units per Em: \t" + str(units_per_em) + "\n"
49+
report_string = report_string + "[head] yMax: \t\t" + str(ymax) + "\n"
50+
report_string = report_string + "[head] yMin: \t\t" + str(ymin) + "\n"
4551
report_string = report_string + "[OS/2] TypoAscender: \t" + str(os2_typo_ascender) + "\n"
4652
report_string = report_string + "[OS/2] TypoDescender: \t" + str(os2_typo_descender) + "\n"
4753
report_string = report_string + "[OS/2] WinAscent: \t" + str(os2_win_ascent) + "\n"
@@ -59,8 +65,10 @@ def get_font_report(fontpath):
5965
report_string = report_string + "Ascent to TypoAscender: \t" + str(hhea_ascent - os2_typo_ascender) + "\n"
6066
report_string = report_string + "WinDescent to TypoDescender: \t" + str(os2_win_descent - -(os2_typo_descender)) + "\n"
6167
report_string = report_string + "Descent to TypoDescender: \t" + str(os2_typo_descender - hhea_descent) + "\n\n"
62-
report_string = report_string + "--- Ratio of TypoLineGap to UPM ---" + "\n"
63-
report_string = report_string + "TypoLineGap / UPM: \t" + str('{0:.3g}'.format(linegap_to_upm))
68+
report_string = report_string + "--- Ratios ---" + "\n"
69+
report_string = report_string + "(Typo Asc + Desc + Linegap) / UPM: \t" + str('{0:.3g}'.format(typo_to_upm)) + "\n"
70+
report_string = report_string + "(winAsc + winDesc) / UPM: \t\t" + str('{0:.3g}'.format(winascdesc_to_upm)) + "\n"
71+
report_string = report_string + "(hhea Asc + Desc) / UPM: \t\t" + str('{0:.3g}'.format(hheaascdesc_to_upm))
6472

6573
return report_string
6674

tests/test_report_cmd.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_report_cmd_reportstring_typolinegap(capsys):
147147
assert "[OS/2] TypoLineGap: \t410" in out
148148

149149

150-
def test_report_cmd_reportstring_typoA_typoD(capsys):
150+
def test_report_cmd_reportstring_typoA_typodesc(capsys):
151151
from fontline.app import main
152152
filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
153153
sys.argv = ['font-line', 'report', filepath]
@@ -156,7 +156,7 @@ def test_report_cmd_reportstring_typoA_typoD(capsys):
156156
assert "[OS/2] TypoAscender to TypoDescender: \t2048" in out
157157

158158

159-
def test_report_cmd_reportstring_winA_winD(capsys):
159+
def test_report_cmd_reportstring_winA_windesc(capsys):
160160
from fontline.app import main
161161
filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
162162
sys.argv = ['font-line', 'report', filepath]
@@ -174,7 +174,7 @@ def test_report_cmd_reportstring_ascent_descent(capsys):
174174
assert "[hhea] Ascent to Descent: \t\t2384" in out
175175

176176

177-
def test_report_cmd_reportstring_winA_typoA(capsys):
177+
def test_report_cmd_reportstring_winA_typoasc(capsys):
178178
from fontline.app import main
179179
filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
180180
sys.argv = ['font-line', 'report', filepath]
@@ -183,7 +183,7 @@ def test_report_cmd_reportstring_winA_typoA(capsys):
183183
assert "WinAscent to TypoAscender: \t345" in out
184184

185185

186-
def test_report_cmd_reportstring_ascent_typoA(capsys):
186+
def test_report_cmd_reportstring_ascent_typoasc(capsys):
187187
from fontline.app import main
188188
filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
189189
sys.argv = ['font-line', 'report', filepath]
@@ -192,7 +192,7 @@ def test_report_cmd_reportstring_ascent_typoA(capsys):
192192
assert "Ascent to TypoAscender: \t345" in out
193193

194194

195-
def test_report_cmd_reportstring_winD_typoD(capsys):
195+
def test_report_cmd_reportstring_winD_typodesc(capsys):
196196
from fontline.app import main
197197
filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
198198
sys.argv = ['font-line', 'report', filepath]
@@ -201,7 +201,7 @@ def test_report_cmd_reportstring_winD_typoD(capsys):
201201
assert "WinDescent to TypoDescender: \t-9" in out
202202

203203

204-
def test_report_cmd_reportstring_descent_typoD(capsys):
204+
def test_report_cmd_reportstring_descent_typodesc(capsys):
205205
from fontline.app import main
206206
filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
207207
sys.argv = ['font-line', 'report', filepath]
@@ -210,11 +210,28 @@ def test_report_cmd_reportstring_descent_typoD(capsys):
210210
assert "Descent to TypoDescender: \t-9" in out
211211

212212

213-
def test_report_cmd_reportstring_typolinegap_to_upm(capsys):
213+
def test_report_cmd_reportstring_typo_to_upm(capsys):
214214
from fontline.app import main
215215
filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
216216
sys.argv = ['font-line', 'report', filepath]
217217
main()
218218
out, err = capsys.readouterr()
219-
assert "TypoLineGap / UPM: \t0.2" in out
219+
assert "(Typo Asc + Desc + Linegap) / UPM: \t1.2" in out
220220

221+
222+
def test_report_cmd_reportstring_win_to_upm(capsys):
223+
from fontline.app import main
224+
filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
225+
sys.argv = ['font-line', 'report', filepath]
226+
main()
227+
out, err = capsys.readouterr()
228+
assert "(winAsc + winDesc) / UPM: \t\t1.16" in out
229+
230+
231+
def test_report_cmd_reportstring_hhea_to_upm(capsys):
232+
from fontline.app import main
233+
filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
234+
sys.argv = ['font-line', 'report', filepath]
235+
main()
236+
out, err = capsys.readouterr()
237+
assert "(hhea Asc + Desc) / UPM: \t\t1.16" in out

0 commit comments

Comments
 (0)