summaryrefslogtreecommitdiff
path: root/scripts/lib
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-02-12 16:32:01 -0800
committerJames Godfrey-Kittle <jamesgk@google.com>2015-04-16 12:16:29 -0700
commit0d2e8746cf7cc98efd117f2a462211bd6ceddc94 (patch)
treeda0f8c3cb110a022fda9a41975e1e2e7409ef434 /scripts/lib
parentb07c28c166c41252047cfbbb44525bb9bd834c93 (diff)
Use FontForge for overlap removal.
This is an alternative to the closed source AFDKO checkOutlines tool. Again, we could potentially do our own overlap removal if time permits.
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/fontbuild/Build.py17
-rw-r--r--scripts/lib/fontbuild/saveOTF.py7
2 files changed, 13 insertions, 11 deletions
diff --git a/scripts/lib/fontbuild/Build.py b/scripts/lib/fontbuild/Build.py
index 0f398ca..7cb4963 100644
--- a/scripts/lib/fontbuild/Build.py
+++ b/scripts/lib/fontbuild/Build.py
@@ -164,15 +164,20 @@ class FontProject:
newFont = OpenFont(ufoName)
conformToAGL(newFont, self.adobeGlyphList)
otfName = self.generateOutputPath(f, "otf")
- saveOTF(newFont, otfName, checkOutlines=self.checkOTFOutlines,
- autohint=self.autohintOTF)
+ saveOTF(newFont, otfName, autohint=self.autohintOTF)
- if self.buildTTF:
- log(">> Generating TTF file")
+ if self.checkOTFOutlines or self.buildTTF:
import fontforge
- ttfName = self.generateOutputPath(f, "ttf")
otFont = fontforge.open(otfName)
- otFont.generate(ttfName)
+
+ if self.checkOTFOutlines:
+ for glyphName in otFont:
+ otFont[glyphName].removeOverlap()
+ otFont.generate(otfName)
+
+ if self.buildTTF:
+ log(">> Generating TTF file")
+ otFont.generate(self.generateOutputPath(f, "ttf"))
if self.buildFEA:
log(">> Generating FEA files")
diff --git a/scripts/lib/fontbuild/saveOTF.py b/scripts/lib/fontbuild/saveOTF.py
index d150f51..3f03127 100644
--- a/scripts/lib/fontbuild/saveOTF.py
+++ b/scripts/lib/fontbuild/saveOTF.py
@@ -6,15 +6,12 @@ from ufo2fdk.makeotfParts import MakeOTFPartsCompiler
from ufo2fdk.outlineOTF import OutlineOTFCompiler
-def saveOTF(font, destFile, checkOutlines=False, autohint=False):
+def saveOTF(font, destFile, autohint=False):
"""Save a RoboFab font as an OTF binary using ufo2fdk."""
compiler = OTFCompiler(partsCompilerClass=_PartsCompilerCustomGlyphOrder,
outlineCompilerClass=_OutlineCompilerFormat12)
- reports = compiler.compile(font, destFile, checkOutlines=checkOutlines,
- autohint=autohint)
- if checkOutlines:
- print reports["checkOutlines"]
+ reports = compiler.compile(font, destFile, autohint=autohint)
if autohint:
print reports["autohint"]
print reports["makeotf"]