Skip to content

Instantly share code, notes, and snippets.

@connordavenport
Created March 11, 2022 21:57
Show Gist options
  • Save connordavenport/9a1840eab5debc34bac360a43882371c to your computer and use it in GitHub Desktop.
Save connordavenport/9a1840eab5debc34bac360a43882371c to your computer and use it in GitHub Desktop.
A simply script to purge a font's groups of any glyphs that aren't in the font anymore.
for f in AllFonts():
fix = []
fixed = {}
todel = []
for name,contents in f.groups.items():
for gs in contents:
if gs not in f.keys():
fix.append(name)
for n in list(set(fix)):
cs = tuple([gs for gs in f.groups[n] if gs in f.keys()])
if cs:
fixed[n] = cs
else:
todel.append(n)
f.groups.update(fixed)
for gr in todel:
del f.groups[gr]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment