From f7868ac6205e9d3388059179a472365835a8fd9b Mon Sep 17 00:00:00 2001 From: Rasmus Andersson Date: Thu, 18 Jan 2018 22:47:59 -0800 Subject: [PATCH] Fix minor bug in fontbuild where certain glyphs composed of multiple shapes would not be expanded & flattened --- misc/pylib/fontbuild/Build.pyx | 19 +++++++++++++++---- src/fontbuild.cfg | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/misc/pylib/fontbuild/Build.pyx b/misc/pylib/fontbuild/Build.pyx index d2629b337..8e028ef74 100644 --- a/misc/pylib/fontbuild/Build.pyx +++ b/misc/pylib/fontbuild/Build.pyx @@ -61,7 +61,8 @@ class FontProject: self.builddir = "out" self.decompose = self.config.get("glyphs","decompose").split() - self.predecompose = self.config.get("glyphs","predecompose").split() + self.predecompose = set(self.config.get("glyphs","predecompose").split()) + self.predecompose_auto = 1 # unless 0, automatically populate predecompose self.lessItalic = set(self.config.get("glyphs","lessitalic").split()) self.deleteList = set(self.config.get("glyphs","delete").split()) self.noItalic = set(self.config.get("glyphs","noitalic").split()) @@ -128,6 +129,13 @@ class FontProject: for gname in swapList: print gname swapContours(f, gname.replace(swap,""), gname) + + if self.predecompose_auto == 1: + self.predecompose_auto = 2 + for g in self.basefont: + if len(g.components) > 0: + self.predecompose.add(g.name) + for gname in self.predecompose: if f.has_key(gname): decomposeGlyph(f, f[gname]) @@ -273,6 +281,8 @@ def generateGlyphs(f, glyphNames, glyphList={}): def cleanCurves(f): log(">> Removing overlaps") for g in f: + # if len(g.components) > 0: + # decomposeGlyph(f, g) removeGlyphOverlap(g) # log(">> Mitring sharp corners") @@ -293,10 +303,11 @@ def deleteGlyphs(f, deleteList): def removeGlyphOverlap(glyph): """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()) + if len(contours) > 1: + manager = BooleanOperationManager() + glyph.clearContours() + manager.union(contours, glyph.getPointPen()) def saveOTF(font, destFile, glyphOrder, truetype=False): diff --git a/src/fontbuild.cfg b/src/fontbuild.cfg index af44aa8aa..b50a03b26 100644 --- a/src/fontbuild.cfg +++ b/src/fontbuild.cfg @@ -35,7 +35,8 @@ decompose: integral product florin Tbar tbar Hbar hbar Eng eng notequal mu aster iota lambda ohorn omega phi psi rho sigma sigma1 tau theta uhorn upsilon xi zeta Aogonek aogonek Eogonek eogonek Uogonek uogonek uni052F Hdesc hdesc Ndesc ndesc nbspace uni202F uni205F erev uni2050 -predecompose: uni04B4 uni04B5 dcroat uni040F uni045F uni0490 uni0491 OE oe Oslash oslash +predecompose: uni04B4 uni04B5 dcroat uni040F uni045F uni0490 uni0491 + OE oe Oslash oslash uni04A6 uni04A7 uni0492 uni0493 uni04BC uni04BD gamma Ohorn ohorn Uhorn uhorn uni0472 uni0473 pi uni046C uni046D gravesubnosp acutesubnosp tackleftsubnosp tackrightsubnosp ringlefthalfsubnosp tackupsubnosp tackdownsubnosp plussubnosp