This commit is contained in:
arpruss
2018-07-14 18:19:37 -05:00
parent 9d9a55153a
commit edfa4cb674
5 changed files with 19 additions and 2 deletions

View File

@@ -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:

View File

@@ -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)

3
go Normal file
View File

@@ -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

9
makelist.py Normal file
View File

@@ -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")

View File

@@ -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):