Skip to content

Commit 50f758f

Browse files
authored
Updated math_table_to_plist.py python script (#179)
The original python script was updated to work with modern python.
1 parent 50757e1 commit 50f758f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

fonts/math_table_to_plist.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/python
1+
#!/usr/local/bin/python3
22
import plistlib
33
import sys
44
from fontTools.ttLib import TTFont
55

66
def usage(code):
7-
print 'Usage math_table_to_plist.py <fontfile> <plistfile>'
7+
print('Usage math_table_to_plist.py <fontfile> <plistfile>')
88
sys.exit(code)
99

1010
def process_font(font_file, out_file):
@@ -24,7 +24,9 @@ def process_font(font_file, out_file):
2424
"italic" : italic_c,
2525
"accents" : accents,
2626
"v_assembly" : assembly }
27-
plistlib.writePlist(pl, out_file)
27+
ofile = open(out_file, 'w+b')
28+
plistlib.dump(pl, ofile)
29+
ofile.close()
2830

2931
def get_constants(math_table):
3032
constants = math_table.MathConstants
@@ -109,7 +111,7 @@ def get_italic_correction(math_table):
109111
count = italic.ItalicsCorrectionCount
110112
records = italic.ItalicsCorrection
111113
italic_dict = {}
112-
for i in xrange(count):
114+
for i in range(count):
113115
name = glyphs[i]
114116
record = records[i]
115117
if record.DeviceTable is not None:
@@ -129,7 +131,7 @@ def get_accent_attachments(math_table):
129131
count = attach.TopAccentAttachmentCount
130132
records = attach.TopAccentAttachment
131133
attach_dict = {}
132-
for i in xrange(count):
134+
for i in range(count):
133135
name = glyphs[i]
134136
record = records[i]
135137
if record.DeviceTable is not None:
@@ -143,7 +145,7 @@ def get_v_variants(math_table):
143145
vconstruction = variants.VertGlyphConstruction
144146
count = variants.VertGlyphCount
145147
variant_dict = {}
146-
for i in xrange(count):
148+
for i in range(count):
147149
name = vglyphs[i]
148150
record = vconstruction[i]
149151
glyph_variants = [x.VariantGlyph for x in
@@ -157,7 +159,7 @@ def get_h_variants(math_table):
157159
hconstruction = variants.HorizGlyphConstruction
158160
count = variants.HorizGlyphCount
159161
variant_dict = {}
160-
for i in xrange(count):
162+
for i in range(count):
161163
name = hglyphs[i]
162164
record = hconstruction[i]
163165
glyph_variants = [x.VariantGlyph for x in
@@ -171,7 +173,7 @@ def get_v_assembly(math_table):
171173
vconstruction = variants.VertGlyphConstruction
172174
count = variants.VertGlyphCount
173175
assembly_dict = {}
174-
for i in xrange(count):
176+
for i in range(count):
175177
name = vglyphs[i]
176178
record = vconstruction[i]
177179
assembly = record.GlyphAssembly

0 commit comments

Comments
 (0)