From 526baf754060cc5a40e8f07a2ff4ae7fc571588c Mon Sep 17 00:00:00 2001 From: James Godfrey-Kittle Date: Fri, 27 Feb 2015 09:52:08 -0800 Subject: Change swapGlyphs to swapContours. This is the actual functionality of FontLab's Glyph.Insert() method. Calling RGlyph.appendGlyph() also swaps anchors, which is not what we want (*.cn glyphs don't have anchors). --- scripts/lib/fontbuild/Build.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'scripts/lib') diff --git a/scripts/lib/fontbuild/Build.py b/scripts/lib/fontbuild/Build.py index 90a2a6a..d4c9a0c 100644 --- a/scripts/lib/fontbuild/Build.py +++ b/scripts/lib/fontbuild/Build.py @@ -135,7 +135,7 @@ class FontProject: swapList = [g.name for g in f if g.name.endswith(swap)] for gname in swapList: print gname - swapGlyphs(f, gname.replace(swap,""), gname) + swapContours(f, gname.replace(swap,""), gname) for gname in self.predecompose: if f.has_key(gname): decomposeGlyph(f[gname]) @@ -210,7 +210,7 @@ def transformGlyphMembers(g, m): s.Transform(m) #c.scale = s -def swapGlyphs(f,gName1,gName2): +def swapContours(f,gName1,gName2): try: g1 = f[gName1] g2 = f[gName2] @@ -219,12 +219,16 @@ def swapGlyphs(f,gName1,gName2): return g3 = g1.copy() - g1.clear() - g1.appendGlyph(g2) + while g1.contours: + g1.removeContour(0) + for contour in g2.contours: + g1.appendContour(contour) g1.width = g2.width - g2.clear() - g2.appendGlyph(g3) + while g2.contours: + g2.removeContour(0) + for contour in g3.contours: + g2.appendContour(contour) g2.width = g3.width -- cgit v1.2.3