diff --git a/dumpmetrics.py b/dumpmetrics.py index 9c79e24..a1ae67d 100644 --- a/dumpmetrics.py +++ b/dumpmetrics.py @@ -27,6 +27,7 @@ if __name__ == '__main__': print("Name "+f.name) print("Ascender "+str(f.ascender)) print("Descender "+str(f.descender)) + print("AdvanceWidthMax "+str(f.header.advance_width_max)) print("Units "+str(f.units_per_em)) print("MacStyle "+str(f.tables[b'head'].mac_style)) for c in chars: diff --git a/dumpscad.py b/dumpscad.py index f4407b1..14fb2ee 100644 --- a/dumpscad.py +++ b/dumpscad.py @@ -24,6 +24,7 @@ if __name__ == '__main__': pass chars = sorted(glyphs.keys()) + print(f.name) fontID = re.sub(r"[^0-9A-Za-z]", "_", f.name) if fontID[0].isdigit(): fontID = "_" + fontID @@ -34,7 +35,7 @@ if __name__ == '__main__': %d, // descender %f, // units_per_em [ -""" % (fontID, f.font_family, f.tables[b'head'].mac_style, f.ascender, f.descender, +""" % (fontID, f.font_family, f.tables[b'head'].mac_style, f.tables[b'os2'].sTypoAscender, f.tables[b'os2'].sTypoDescender, f.units_per_em)) for c in chars: glyph = f.char_to_glyph(c) diff --git a/go b/go new file mode 100644 index 0000000..20d7aeb --- /dev/null +++ b/go @@ -0,0 +1,3 @@ +for x in mst/* ; do echo $x ; (python dumpscad.py $x >> ~/3d/mstfonts.scad ) ; done +python makelist.py ~/3d/mstfonts.scad > list.scad +cat list.scad >> ~/3d/mstfonts.scad diff --git a/makelist.py b/makelist.py new file mode 100644 index 0000000..000114e --- /dev/null +++ b/makelist.py @@ -0,0 +1,9 @@ +from sys import argv +import re + +fonts = [] +with open(argv[1]) as f: + for line in f: + if line.startswith("FONT_"): + fonts.append(line.split()[0]) +print("FONTS = [ " + ','.join(fonts) + " ];\n") diff --git a/zttf/utils.py b/zttf/utils.py index f137a27..b1c02d0 100644 --- a/zttf/utils.py +++ b/zttf/utils.py @@ -91,7 +91,10 @@ def fixed_version(num): :param num: fixed 16:16 floating point number as a 32-bit unsigned integer :return: version number (float) """ - return float("{:04x}.{:04x}".format(num >> 16, num & 0x0000ffff)) + try: + return float("{:04x}.{:04x}".format(num >> 16, num & 0x0000ffff)) + except: + return 1.0 def binary_search_parameters(length):