summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-09-18 18:33:33 -0700
committerJames Godfrey-Kittle <jamesgk@google.com>2015-09-18 18:34:32 -0700
commita9ff306231162a2a62d1dec67ac09da2169679fc (patch)
tree5419aac679e835996326781c4fc819c9168e7c57 /scripts/lib/fontbuild
parent1234a9ce9738a65546b4500e9bc69ebfbd6a65c4 (diff)
Reduce code outside of decomposeGlyph's recursion.
Diffstat (limited to 'scripts/lib/fontbuild')
-rw-r--r--scripts/lib/fontbuild/decomposeGlyph.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/scripts/lib/fontbuild/decomposeGlyph.py b/scripts/lib/fontbuild/decomposeGlyph.py
index b3cc8ea..94b9404 100644
--- a/scripts/lib/fontbuild/decomposeGlyph.py
+++ b/scripts/lib/fontbuild/decomposeGlyph.py
@@ -2,23 +2,20 @@ def decomposeGlyph(font, glyphName):
"""Moves the components of a glyph to its outline."""
glyph = font[glyphName]
- for component in glyph.components:
- decompose(font, glyphName, component.baseGlyph,
- component.offset, component.scale)
- glyph.clear(contours=False, anchors=False, guides=False)
+ decompose(font, glyph, glyph, (0, 0), (1, 1))
+ glyph.clearComponents()
-def decompose(font, parentName, componentName, offset, scale):
+def decompose(font, parent, component, offset, scale):
"""Copy contours to parent from component, including nested components."""
- parent = font[parentName]
- component = font[componentName]
-
for nested in component.components:
- decompose(font, parentName, nested.baseGlyph,
+ decompose(font, parent, font[nested.baseGlyph],
(offset[0] + nested.offset[0], offset[1] + nested.offset[1]),
(scale[0] * nested.scale[0], scale[1] * nested.scale[1]))
+ if component == parent:
+ return
for contour in component:
contour = contour.copy()
contour.scale(scale)