summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2017-10-05 09:38:06 +0300
committerRasmus Andersson <rasmus@notion.se>2017-10-05 09:38:06 +0300
commit855258147e88b6023c8c6c4ecdb726fcb406c44a (patch)
treebbf58d7928b95a828a392f6f3be0e85e1628c670
parent0544b01dcf2ebf2fc8cdd48f1354949513773549 (diff)
downloadinter-855258147e88b6023c8c6c4ecdb726fcb406c44a.tar.xz
fontbuild: optimize glyphorder data per font and check for duplicates
-rw-r--r--misc/pylib/fontbuild/Build.pyx16
1 files changed, 14 insertions, 2 deletions
diff --git a/misc/pylib/fontbuild/Build.pyx b/misc/pylib/fontbuild/Build.pyx
index 939122658..554003b50 100644
--- a/misc/pylib/fontbuild/Build.pyx
+++ b/misc/pylib/fontbuild/Build.pyx
@@ -173,11 +173,22 @@ class FontProject:
f.save(ufoName)
self.generatedFonts.append(ufoName)
+ # filter glyphorder -- only include glyphs that exists in font
+ glyphOrder = []
+ seenGlyphNames = set()
+ missingGlyphs = []
+ for glyphName in self.glyphOrder:
+ if glyphName in f:
+ if glyphName in seenGlyphNames:
+ raise Exception('Duplicate glyphname %r in glyphorder' % glyphName)
+ seenGlyphNames.add(glyphName)
+ glyphOrder.append(glyphName)
+
if self.buildOTF:
log(">> Generating OTF file")
newFont = OpenFont(ufoName)
otfName = self.generateOutputPath(f, "otf")
- saveOTF(newFont, otfName, self.glyphOrder)
+ saveOTF(newFont, otfName, glyphOrder)
def generateTTFs(self):
"""Build TTF for each font generated since last call to generateTTFs."""
@@ -199,7 +210,8 @@ class FontProject:
for font in fonts:
ttfName = self.generateOutputPath(font, "ttf")
log(os.path.basename(ttfName))
- saveOTF(font, ttfName, self.glyphOrder, truetype=True)
+ glyphOrder = [n for n in self.glyphOrder if n in font]
+ saveOTF(font, ttfName, glyphOrder, truetype=True)
# def transformGlyphMembers(g, m):