Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mekkablue/4ec8bf951ec1666e75772ffcd60d1e03 to your computer and use it in GitHub Desktop.
Save mekkablue/4ec8bf951ec1666e75772ffcd60d1e03 to your computer and use it in GitHub Desktop.
Put in Macro Window and run after copying Excel columns (oldname, newname) in clipboard
from AppKit import NSPateboard, NSStringPboardType
myClipboard = NSPasteboard.generalPasteboard()
renameString = myClipboard.stringForType_(NSStringPboardType)
renameCount = 0
print "Processing: %s" % Font.familyName
print
for renameLine in renameString.strip().splitlines():
renameLine = renameLine.strip()
if "\t" in renameLine:
while "\t\t" in renameLine:
renameLine = renameLine.replace("\t\t","\t")
oldName,newName = renameLine.split("\t")[:]
glyph = Font.glyphs[oldName]
if not glyph:
print "WARNING: '%s' not found (->'%s')" % (oldName,newName)
else:
glyph.name = newName
renameCount += 1
print
print "Done. Renamed %i glyphs." % renameCount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment