diff options
author | James Godfrey-Kittle <jamesgk@google.com> | 2015-02-12 10:28:09 -0800 |
---|---|---|
committer | James Godfrey-Kittle <jamesgk@google.com> | 2015-04-16 12:16:29 -0700 |
commit | b07c28c166c41252047cfbbb44525bb9bd834c93 (patch) | |
tree | 3df1c2b392d1e4143e720d57bd3d0d3b08fda586 /scripts | |
parent | 9850fe60b4e87471e3c30ef6c1a07d66a9dfcc16 (diff) |
Add conversion to TTF.
We convert from OTF to TTF using the fontforge python module. If time permits we may want to create our own tool to convert straight from UFO to TTF.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/build-v2.py | 3 | ||||
-rw-r--r-- | scripts/lib/fontbuild/Build.py | 33 |
2 files changed, 20 insertions, 16 deletions
diff --git a/scripts/build-v2.py b/scripts/build-v2.py index d987116..c232ad3 100644 --- a/scripts/build-v2.py +++ b/scripts/build-v2.py @@ -61,7 +61,8 @@ FAMILYNAME = "Roboto" proj.buildOTF = True
#proj.checkOTFOutlines = True
#proj.autohintOTF = True
-#proj.buildFEA = True
+proj.buildTTF = True
+proj.buildFEA = True
proj.generateFont(th.font,"%s/Thin/Regular/Th"%FAMILYNAME)
proj.generateFont(Mix([th,rg], 0.45),"%s/Light/Regular/Lt"%FAMILYNAME)
diff --git a/scripts/lib/fontbuild/Build.py b/scripts/lib/fontbuild/Build.py index 72119e0..0f398ca 100644 --- a/scripts/lib/fontbuild/Build.py +++ b/scripts/lib/fontbuild/Build.py @@ -45,6 +45,7 @@ class FontProject: self.buildOTF = False self.checkOTFOutlines = False self.autohintOTF = False + self.buildTTF = False self.buildFEA = False @@ -66,6 +67,13 @@ class FontProject: else: raise Exception("Empty build number") + def generateOutputPath(self, font, ext): + family = font.info.familyName.replace(" ", "") + style = font.info.styleName.replace(" ", "") + path = "%s/%s/%s%s" % (self.basedir, self.builddir, family, ext.upper()) + if not os.path.exists(path): + os.makedirs(path) + return "%s/%s-%s.%s" % (path, family, style, ext.lower()) def generateFont(self, mix, names, italic=False, swapSuffixes=None, stemWidth=185, kern=True): @@ -146,36 +154,31 @@ class FontProject: log(">> Generating kern classes") readGlyphClasses(f, self.ot_kerningclasses, update=False) - directoryName = n[0].replace(" ", "") - fontName = "%s-%s" % (f.info.familyName.replace(" ", ""), - f.info.styleName.replace(" ", "")) - log(">> Generating font files") generateFeatureFile(f) - directoryPath = "%s/%s/%sUFO"%(self.basedir,self.builddir,directoryName) - if not os.path.exists(directoryPath): - os.makedirs(directoryPath) - ufoName = "%s/%s.ufo" % (directoryPath, fontName) + ufoName = self.generateOutputPath(f, "ufo") f.save(ufoName) if self.buildOTF: log(">> Generating OTF file") newFont = OpenFont(ufoName) conformToAGL(newFont, self.adobeGlyphList) - directoryPath = "%s/%s/%sOTF" % (self.basedir, self.builddir, - directoryName) - if not os.path.exists(directoryPath): - os.makedirs(directoryPath) - otfName = "%s/%s.otf" % (directoryPath, fontName) + otfName = self.generateOutputPath(f, "otf") saveOTF(newFont, otfName, checkOutlines=self.checkOTFOutlines, autohint=self.autohintOTF) + if self.buildTTF: + log(">> Generating TTF file") + import fontforge + ttfName = self.generateOutputPath(f, "ttf") + otFont = fontforge.open(otfName) + otFont.generate(ttfName) + if self.buildFEA: log(">> Generating FEA files") GenerateFeature_mark(f) GenerateFeature_mkmk(f) - feaName = "%s/%s.fea"%(directoryPath,fontName) - writeFeatureFile(f, feaName) + writeFeatureFile(f, self.generateOutputPath(f, "fea")) def transformGlyphMembers(g, m): |