diff options
author | Rasmus Andersson <rasmus@notion.se> | 2018-09-01 22:59:27 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2018-09-01 22:59:27 +0300 |
commit | 8c1a4c181ef12000179dfec541f1af87e9b03122 (patch) | |
tree | a9e5508e963230a34281d55b31f6dceb50726a60 /misc/pylib/fontbuild/Build.pyx | |
parent | 50ca3807f77eec9c01dcb5107da9348026e83c6c (diff) | |
download | inter-8c1a4c181ef12000179dfec541f1af87e9b03122.tar.xz |
adds --cufo flag to ufocompile for compiling UFO files instead of OTF and TTF files
Diffstat (limited to 'misc/pylib/fontbuild/Build.pyx')
-rw-r--r-- | misc/pylib/fontbuild/Build.pyx | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/misc/pylib/fontbuild/Build.pyx b/misc/pylib/fontbuild/Build.pyx index 807ed6991..d4fbd91d7 100644 --- a/misc/pylib/fontbuild/Build.pyx +++ b/misc/pylib/fontbuild/Build.pyx @@ -72,6 +72,7 @@ class FontProject: self.buildOTF = False self.compatible = False self.generatedFonts = [] + self.justCompileUFO = False def openResource(self, name): with open(os.path.join( @@ -98,7 +99,8 @@ class FontProject: f = mix.generateFont(self.basefont, self.deleteList) else: f = mix.copy() - deleteGlyphs(f, self.deleteList) + if not self.justCompileUFO: + deleteGlyphs(f, self.deleteList) if italic == True: log(">> Italicizing") @@ -137,12 +139,13 @@ class FontProject: if len(g.components) > 0: self.predecompose.add(g.name) - for gname in self.predecompose: - if f.has_key(gname): - decomposeGlyph(f, f[gname]) + if not self.justCompileUFO: + for gname in self.predecompose: + if f.has_key(gname): + decomposeGlyph(f, f[gname]) log(">> Generating glyphs") - generateGlyphs(f, self.diacriticList, self.adobeGlyphList) + self.generateGlyphs(f, self.diacriticList, self.adobeGlyphList) # log(">> Reading features") # readFeatureFile(f, f.features.text) @@ -163,13 +166,14 @@ class FontProject: g.leftMargin = newLeftMargin g.rightMargin = newRightMargin - log(">> Decomposing") - # for g in f: - # if len(g.components) > 0: - # decomposeGlyph(f, g) - for gname in self.decompose: - if f.has_key(gname): - decomposeGlyph(f, f[gname]) + if not self.justCompileUFO: + log(">> Decomposing") + # for g in f: + # if len(g.components) > 0: + # decomposeGlyph(f, g) + for gname in self.decompose: + if f.has_key(gname): + decomposeGlyph(f, f[gname]) copyrightHolderName = '' if self.config.has_option('main', 'copyrightHolderName'): @@ -193,7 +197,8 @@ class FontProject: 'italicAngle': float(getcfg('italicAngle', '-12')), }, panose) - if not self.compatible: + if not self.compatible and not self.justCompileUFO: + # Remove overlaps etc cleanCurves(f) # deleteGlyphs(f, self.deleteList) @@ -202,6 +207,10 @@ class FontProject: f.save(ufoName) self.generatedFonts.append(ufoName) + if self.justCompileUFO: + print("wrote %s" % ufoName) + return + # filter glyphorder -- only include glyphs that exists in font glyphOrder = [] seenGlyphNames = set() @@ -242,6 +251,12 @@ class FontProject: glyphOrder = [n for n in self.glyphOrder if n in font] saveOTF(font, ttfName, glyphOrder, truetype=True) + def generateGlyphs(self, f, glyphNames, glyphList={}): + log(">> Generating diacritics") + glyphnames = [gname for gname in glyphNames if not gname.startswith("#") and gname != ""] + for glyphName in glyphNames: + generateGlyph(f, glyphName, glyphList) + # def transformGlyphMembers(g, m): # g.width = int(g.width * m.a) @@ -290,14 +305,6 @@ def log(msg): print msg -def generateGlyphs(f, glyphNames, glyphList={}): - log(">> Generating diacritics") - glyphnames = [gname for gname in glyphNames if not gname.startswith("#") and gname != ""] - - for glyphName in glyphNames: - generateGlyph(f, glyphName, glyphList) - - def deleteGlyphs(f, deleteList): for name in deleteList: if f.has_key(name): |