Skip to content

Instantly share code, notes, and snippets.

@benkiel
Created June 11, 2015 22:04
Show Gist options
  • Save benkiel/1dd89c4781f0a2ca060b to your computer and use it in GitHub Desktop.
Save benkiel/1dd89c4781f0a2ca060b to your computer and use it in GitHub Desktop.
Walks all open fonts and looks for a component that is a reference of another component. Is dumb and assumes that there is only one component the reference. Good for quickly cleaning up UFOs before importing into FontLab, where this sort of thing isn't allowed.
fonts = AllFonts()
for font in fonts:
for g in font:
if len(g.components) != 0:
for c in g.components:
b = font[c.baseGlyph]
if len(b.components) != 0:
e = b.components[0]
eb = e.baseGlyph
bx, by = c.offset
ex, ey = e.offset
g.removeComponent(c)
nx = ex + bx
ny = ey + by
g.appendComponent(eb, (nx, ny))
g.mark = (1,0,0,1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment