diff --git a/Lib/fontTools/pens/statisticsPen.py b/Lib/fontTools/pens/statisticsPen.py index 3468fc72e..9afa3b640 100644 --- a/Lib/fontTools/pens/statisticsPen.py +++ b/Lib/fontTools/pens/statisticsPen.py @@ -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: