[statisticsPen] Report font glyph-average weight/width

This commit is contained in:
Behdad Esfahbod 2023-07-19 19:54:55 -06:00
parent 159cc0c04e
commit 8707a1da58

View File

@ -77,6 +77,8 @@ def _test(glyphset, upem, glyphs):
print("upem", upem)
wght_sum = 0
wdth_sum = 0
for glyph_name in glyphs:
print()
print("glyph:", glyph_name)
@ -103,6 +105,13 @@ def _test(glyphset, upem, glyphs):
]:
print("%s: %g" % (item, getattr(pen, item)))
wght_sum += abs(pen.area)
wdth_sum += glyph.width
print()
print("weight: %g" % (wght_sum * upem / wdth_sum))
print("width: %g" % (wdth_sum / upem / len(glyphs)))
def main(args):
if not args: