Skip to content

Instantly share code, notes, and snippets.

@typemytype
Created February 2, 2021 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typemytype/6cb71086f80db1df4ce8ac4c5fea32db to your computer and use it in GitHub Desktop.
Save typemytype/6cb71086f80db1df4ce8ac4c5fea32db to your computer and use it in GitHub Desktop.
# get the current glyph
glyph = CurrentGlyph()
# get the point pen
pointPen = glyph.getPointPen()
# loop over all contours
# convert the glyph to a list first
# so we can remove the contour and alter the glyph
for contour in list(glyph):
# get all the points
points = contour.points
# remove the contour
glyph.removeContour(contour)
# use a point pen to add all points
# start a new contour
pointPen.beginPath()
# loop over all points
for point in points:
# add the point
pointPen.addPoint((point.x, point.y), "line")
# end the contour
pointPen.endPath()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment