mirror of
https://github.com/rsms/inter.git
synced 2024-12-26 00:54:14 +03:00
fontbuild: optimize glyphorder data per font and check for duplicates
This commit is contained in:
parent
0544b01dcf
commit
855258147e
@ -173,11 +173,22 @@ class FontProject:
|
|||||||
f.save(ufoName)
|
f.save(ufoName)
|
||||||
self.generatedFonts.append(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:
|
if self.buildOTF:
|
||||||
log(">> Generating OTF file")
|
log(">> Generating OTF file")
|
||||||
newFont = OpenFont(ufoName)
|
newFont = OpenFont(ufoName)
|
||||||
otfName = self.generateOutputPath(f, "otf")
|
otfName = self.generateOutputPath(f, "otf")
|
||||||
saveOTF(newFont, otfName, self.glyphOrder)
|
saveOTF(newFont, otfName, glyphOrder)
|
||||||
|
|
||||||
def generateTTFs(self):
|
def generateTTFs(self):
|
||||||
"""Build TTF for each font generated since last call to generateTTFs."""
|
"""Build TTF for each font generated since last call to generateTTFs."""
|
||||||
@ -199,7 +210,8 @@ class FontProject:
|
|||||||
for font in fonts:
|
for font in fonts:
|
||||||
ttfName = self.generateOutputPath(font, "ttf")
|
ttfName = self.generateOutputPath(font, "ttf")
|
||||||
log(os.path.basename(ttfName))
|
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):
|
# def transformGlyphMembers(g, m):
|
||||||
|
Loading…
Reference in New Issue
Block a user