Skip to content

Instantly share code, notes, and snippets.

@line0
Created September 10, 2014 09:51
Show Gist options
  • Save line0/52514b260c78b35eae30 to your computer and use it in GitHub Desktop.
Save line0/52514b260c78b35eae30 to your computer and use it in GitHub Desktop.
Fontlab script: adds texture to selected glyphs by intersecting them with a glyph named "texture"
def process(f, g, t, index):
fl.SetUndo(index)
upm = f.upm
g.RemoveOverlap()
outlines = Glyph(g)
g.Distance(upm/100, upm/100, 1)
g.RemoveOverlap()
outlines.Bsubtract(t)
g.Bsubtract(outlines)
fl.UpdateGlyph(index)
return 1
texture = next(glyph for glyph in fl.font.glyphs if glyph.name == "texture")
glyphs = fl.font.glyphs
for index in range(len(glyphs)):
if fl.Selected(index) and index != fl.iglyph :
process(fl.font, glyphs[index], texture, index)
fl.UpdateGlyph(index)
process(fl.font, glyphs[fl.iglyph], texture, fl.iglyph)
fl.UpdateGlyph()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment