diff --git a/dumpmetrics.py b/dumpmetrics.py new file mode 100644 index 0000000..2af1608 --- /dev/null +++ b/dumpmetrics.py @@ -0,0 +1,38 @@ +import sys +from zttf.ttfile import TTFile + + +if __name__ == '__main__': + if len(sys.argv) < 2: + print("Usage: {} ".format(sys.argv[0])) + sys.exit(0) + + t = TTFile(sys.argv[1]) + if not t.is_valid: + print("Invalid") + sys.exit(0) + + f = t.faces[0] + glyphs = {} + for c in range(0,65536): + try: + g = f.char_to_glyph(c) + if g: + glyphs[c] = g + except: + pass + chars = sorted(glyphs.keys()) + + print("Family "+f.font_family) + print("Name "+f.name) + print("Ascender "+str(f.ascender)) + print("Descender "+str(f.descender)) + print("Units "+str(f.units_per_em)) + for c in chars: + glyph = f.char_to_glyph(c) + print("Width %d %d" % (c, f.glyph_metrics[glyph][0])) + for c2 in chars: + r = f.char_to_glyph(c2) + if (glyph,r) in f.glyph_kern: + print("Kern %d %d %d" % (c, c2, f.glyph_kern[(glyph,r)])) + \ No newline at end of file