Skip to content

Instantly share code, notes, and snippets.

@m4rc1e
Created July 12, 2023 14:44
Show Gist options
  • Save m4rc1e/999669c69fe8e7c16997bbdd21ed89af to your computer and use it in GitHub Desktop.
Save m4rc1e/999669c69fe8e7c16997bbdd21ed89af to your computer and use it in GitHub Desktop.
font = Glyphs.font
glyph_id_to_name = {g.id: g.name for g in font.glyphs}
# Find all kerns in the source file
seen = set()
for master_kerns in font.kerning:
for first in master_kerns.keys():
for second in master_kerns[first].keys():
first = glyph_id_to_name.get(first, first)
second = glyph_id_to_name.get(second, second)
seen.add((first, second))
print(len(seen))
# Add missing kerns to each master
for master in font.masters:
for first, second in seen:
try:
kern = font.kerningForPair(master.id, first, second)
if kern == None:
font.setKerningForPair(master.id, first, second, -1)
except:
all
print("Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment