def draw_pen_data(layer, pen_data):
for path in pen_data:
pen = layer.getPen()
pen.moveTo(path[0])
for segment in path[1:]:
if len(segment) == 2:
pen.lineTo(segment)
elif len(segment) == 3:
pen.curveTo(*segment)
pen.closePath()
pen.endPath()
layer.cleanUpPaths()
layer.correctPathDirection()
I think I yoinked this function from the BuildGlyphs.py script by Rainer. A year or so ago I wrote my own adaptation for different paths, but can’t for the life of me remember how I collected the pen data. Any pointers?
Or any other way to encapsulate paths in a script efficiently so that I can draw them again?
GSPathSegments is not useful, because objects() doesn’t return all nodes, only the first and last (not the offcurve nodes), which is exactly what I’ve complained about a few times, for exactly this reason
If you have any other idea how to easily store (and redraw) path data in a script, I’m also very open to changing my method.
Hello again. How can I extract these descriptions from a GSPathSegment? There’s always the “obj:2” at the end. Just using .replace("obj:2", "") feels wrong. Is there a more proper way?