summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-03-09 13:09:55 -0700
committerJames Godfrey-Kittle <jamesgk@google.com>2015-04-16 12:16:32 -0700
commit55dccaf63fbbc6ebf2dfc0a6681ce43c841f6f05 (patch)
treeecc65110ba6b18312dda5c0943f0e25d8cb3f093
parent960e9133de3102c8de784fd55bad8670f06ff31a (diff)
Use booleanOperations for overlap removal.
-rw-r--r--scripts/build-v2.py1
-rw-r--r--scripts/lib/fontbuild/Build.py23
-rw-r--r--scripts/lib/fontbuild/removeGlyphOverlap.py11
3 files changed, 15 insertions, 20 deletions
diff --git a/scripts/build-v2.py b/scripts/build-v2.py
index 05bae66..0c9bfe0 100644
--- a/scripts/build-v2.py
+++ b/scripts/build-v2.py
@@ -61,7 +61,6 @@ proj = FontProject(rg.font, BASEDIR, "res/roboto.cfg", th.ffont)
FAMILYNAME = "Roboto"
proj.buildOTF = True
-#proj.checkOTFOutlines = True
#proj.autohintOTF = True
proj.buildTTF = True
proj.buildFEA = True
diff --git a/scripts/lib/fontbuild/Build.py b/scripts/lib/fontbuild/Build.py
index c524e7a..b02ae8b 100644
--- a/scripts/lib/fontbuild/Build.py
+++ b/scripts/lib/fontbuild/Build.py
@@ -48,7 +48,6 @@ class FontProject:
self.buildnumber = self.loadBuildNumber()
self.buildOTF = False
- self.checkOTFOutlines = False
self.autohintOTF = False
self.buildTTF = False
self.buildFEA = False
@@ -167,19 +166,11 @@ class FontProject:
otfName = self.generateOutputPath(f, "otf")
saveOTF(newFont, otfName, autohint=self.autohintOTF)
- if self.checkOTFOutlines or self.buildTTF:
+ if self.buildTTF:
+ log(">> Generating TTF file")
import fontforge
otFont = fontforge.open(otfName)
-
- if self.checkOTFOutlines:
- log(">> Removing overlaps")
- for glyphName in otFont:
- otFont[glyphName].removeOverlap()
- otFont.generate(otfName)
-
- if self.buildTTF:
- log(">> Generating TTF file")
- otFont.generate(self.generateOutputPath(f, "ttf"))
+ otFont.generate(self.generateOutputPath(f, "ttf"))
if self.buildFEA:
log(">> Generating FEA files")
@@ -242,10 +233,9 @@ def generateGlyphs(f, glyphNames, glyphList={}):
generateGlyph(f, glyphName, glyphList)
def cleanCurves(f):
- #TODO(jamesgk) remove calls to removeGlyphOverlap if we use FDK or FontForge
- # log(">> Removing overlaps")
- # for g in f:
- # removeGlyphOverlap(g)
+ log(">> Removing overlaps")
+ for g in f:
+ removeGlyphOverlap(g)
# log(">> Mitring sharp corners")
# for g in f:
@@ -254,7 +244,6 @@ def cleanCurves(f):
# log(">> Converting curves to quadratic")
# for g in f:
# glyphCurvesToQuadratic(g)
- pass
def deleteGlyphs(f, deleteList):
diff --git a/scripts/lib/fontbuild/removeGlyphOverlap.py b/scripts/lib/fontbuild/removeGlyphOverlap.py
index 02e3a93..844f041 100644
--- a/scripts/lib/fontbuild/removeGlyphOverlap.py
+++ b/scripts/lib/fontbuild/removeGlyphOverlap.py
@@ -1,3 +1,10 @@
+from booleanOperations import BooleanOperationManager
+
+
def removeGlyphOverlap(glyph):
- #TODO(jamesgk@google.com)
- pass
+ """Remove overlaps in contours from a glyph."""
+ #TODO(jamesgk) verify overlaps exist first, as per library's recommendation
+ manager = BooleanOperationManager()
+ contours = glyph.contours
+ glyph.clearContours()
+ manager.union(contours, glyph.getPointPen())