diff options
author | James Godfrey-Kittle <jamesgk@google.com> | 2015-03-09 13:09:55 -0700 |
---|---|---|
committer | James Godfrey-Kittle <jamesgk@google.com> | 2015-04-16 12:16:32 -0700 |
commit | 55dccaf63fbbc6ebf2dfc0a6681ce43c841f6f05 (patch) | |
tree | ecc65110ba6b18312dda5c0943f0e25d8cb3f093 /scripts/lib | |
parent | 960e9133de3102c8de784fd55bad8670f06ff31a (diff) |
Use booleanOperations for overlap removal.
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/fontbuild/Build.py | 23 | ||||
-rw-r--r-- | scripts/lib/fontbuild/removeGlyphOverlap.py | 11 |
2 files changed, 15 insertions, 19 deletions
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()) |