Skip to content

Instantly share code, notes, and snippets.

@cjdunn
Created March 12, 2020 19:43
Show Gist options
  • Save cjdunn/5f7a1fca6aaab4526255d41a7f74ebe3 to your computer and use it in GitHub Desktop.
Save cjdunn/5f7a1fca6aaab4526255d41a7f74ebe3 to your computer and use it in GitHub Desktop.
removes selected off-curve points for AllFonts() so they are still VF compatible
# removes selected off-curve points for AllFonts() so they are still VF compatible
def segment2line(glyph, index, ):
c, s = index
contour = glyph[c]
segment = contour[s]
segment.type = "line"
glyph = CurrentGlyph()
selection = glyph.selection
deleteList = []
#get contour and segment index for selected points and add to list
for contour in glyph:
for segment in contour:
for p in selection:
if p in segment:
deleteList.append( ( glyph.name, (segment.contour.index, segment.index) ) )
#remove duplicates in list
deleteList = list ( set( deleteList ) )
fonts = AllFonts()
for f in fonts:
for gname, index in deleteList:
glyph = f[gname]
segment2line(glyph, index,)
f.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment