diff options
author | James Godfrey-Kittle <jamesgk@google.com> | 2015-02-27 09:52:08 -0800 |
---|---|---|
committer | James Godfrey-Kittle <jamesgk@google.com> | 2015-04-16 12:16:31 -0700 |
commit | 526baf754060cc5a40e8f07a2ff4ae7fc571588c (patch) | |
tree | bc599afef0c3edbd8ab570c66490cac4e4f3c172 /scripts/lib | |
parent | 82a46da3a3f10e7ab2bc96747a66cbf3031b4c5e (diff) |
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).
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/fontbuild/Build.py | 16 |
1 files changed, 10 insertions, 6 deletions
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 |