1
1
mirror of https://github.com/rsms/inter.git synced 2024-12-27 09:33:19 +03:00

Fix minor bug in fontbuild where certain glyphs composed of multiple shapes would not be expanded & flattened

This commit is contained in:
Rasmus Andersson 2018-01-18 22:47:59 -08:00
parent 2ad426b1e7
commit f7868ac620
2 changed files with 17 additions and 5 deletions

View File

@ -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):

View File

@ -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