Created
February 16, 2024 15:36
-
-
Save moyogo/2aa8cb90401e1e1cca6fb5f00101b815 to your computer and use it in GitHub Desktop.
Generate a text file with oldname=newname for Glyphs.app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a file with "oldname=newname" per glyph to rename with nice names. | |
# To use with https://github.com/mekkablue/Glyphs-Scripts to rename glyphs | |
for font in Glyphs.fonts: | |
renames = dict() | |
for glyph in font.glyphs: | |
new = Glyphs.niceGlyphName(glyph.name) | |
if new != glyph.name and new not in font.glyphs: | |
renames[glyph.name] = new | |
print(len(renames)) | |
dirname = "/".join(font.filepath.split("/")[:-1]) | |
filename = font.filepath.split("/")[-1] | |
with open(dirname + "/" + filename + ".txt", "w") as fp: | |
fp.write("\n".join(f"{k}={v}" for k, v in renames.items())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment