Fixes an issue where some overlapping contours would not be flattened during compilation. This increases build time by about 50% (29s -> 43s on my machine for regular) and increases the size of the unhinted regular OTF file by about 20 kB
This commit is contained in:
parent
0d7d370104
commit
57238c6c82
1 changed files with 24 additions and 15 deletions
|
|
@ -278,11 +278,18 @@ def generateGlyphs(f, glyphNames, glyphList={}):
|
||||||
for glyphName in glyphNames:
|
for glyphName in glyphNames:
|
||||||
generateGlyph(f, glyphName, glyphList)
|
generateGlyph(f, glyphName, glyphList)
|
||||||
|
|
||||||
|
|
||||||
|
def deleteGlyphs(f, deleteList):
|
||||||
|
for name in deleteList:
|
||||||
|
if f.has_key(name):
|
||||||
|
f.removeGlyph(name)
|
||||||
|
|
||||||
|
|
||||||
def cleanCurves(f):
|
def cleanCurves(f):
|
||||||
log(">> Removing overlaps")
|
log(">> Removing overlaps")
|
||||||
for g in f:
|
for g in f:
|
||||||
# if len(g.components) > 0:
|
if len(g.components) > 0:
|
||||||
# decomposeGlyph(f, g)
|
decomposeGlyph(f, g)
|
||||||
removeGlyphOverlap(g)
|
removeGlyphOverlap(g)
|
||||||
|
|
||||||
# log(">> Mitring sharp corners")
|
# log(">> Mitring sharp corners")
|
||||||
|
|
@ -294,20 +301,22 @@ def cleanCurves(f):
|
||||||
# glyphCurvesToQuadratic(g)
|
# glyphCurvesToQuadratic(g)
|
||||||
|
|
||||||
|
|
||||||
def deleteGlyphs(f, deleteList):
|
def removeGlyphOverlap(g):
|
||||||
for name in deleteList:
|
|
||||||
if f.has_key(name):
|
|
||||||
f.removeGlyph(name)
|
|
||||||
|
|
||||||
|
|
||||||
def removeGlyphOverlap(glyph):
|
|
||||||
"""Remove overlaps in contours from a glyph."""
|
"""Remove overlaps in contours from a glyph."""
|
||||||
#TODO(jamesgk) verify overlaps exist first, as per library's recommendation
|
# Note: Although it theoretically would be more efficient to first check
|
||||||
contours = glyph.contours
|
# if contours has overlap before applying clipping, boolean ops and
|
||||||
if len(contours) > 1:
|
# re-drawing the shapes, the booleanOperations library's getIntersections
|
||||||
manager = BooleanOperationManager()
|
# function adds more overhead in the real world, compared to bluntly
|
||||||
glyph.clearContours()
|
# computing the union for every single glyph.
|
||||||
manager.union(contours, glyph.getPointPen())
|
#
|
||||||
|
# If we can find a really cheap/efficient way to check if there's any
|
||||||
|
# overlap, then we should do that before going ahead and computing the
|
||||||
|
# union. Keep in mind that some glyphs have just a single contour that
|
||||||
|
# intersects itself, for instance "e".
|
||||||
|
|
||||||
|
contours = g.contours
|
||||||
|
g.clearContours()
|
||||||
|
BooleanOperationManager.union(contours, g.getPointPen())
|
||||||
|
|
||||||
|
|
||||||
def saveOTF(font, destFile, glyphOrder, truetype=False):
|
def saveOTF(font, destFile, glyphOrder, truetype=False):
|
||||||
|
|
|
||||||
Reference in a new issue