I’m trying to learn how to script Glyphs and comparing the tutorials and the API reference.
The goal is to be able to write scripts that do a set of actions, similar to how you’d run Photoshop “actions” on multiple images to create certain decorative letters.
I’ve managed to do the first step in one workflow, i.e. copy the glyph to a new component and make it an outline.
import copy print(Font.selection.name) for myGlyph in Font.selection: newGlyph = GSGlyph() newGlyph.name = myGlyph.name + ".0001" newGlyph.layers = copy.deepcopy(myGlyph.layers) for newPath in newGlyph.layers.paths: strokeWidth = 10 newPath.setAttribute_forKey_(strokeWidth, "strokeWidth") print(newPath.parent) newGlyph.layers.flattenOutlinesRemoveOverlap_origHints_secondaryPath_extraHandles_error_(False,None,None,None,None) Glyphs.font.glyphs[newGlyph.name] = newGlyph
I found out about the function “flattenOutlinesRemoveOverlap_origHints_secondaryPath_extraHandles_error_” through searching the forums, but the “intellisense” in the Glyphs macro editor shows no such function and I don’t know where I’d otherwise have found out about it. Is there some other reference I’m not aware of?
One of the problems I’m trying to solve is to get the “inner shape” that you’ll get if you expand a fairly wide stroke on a shape and remove the outermost and innermost paths, any tips on how to do that with code?