Skip to content

Instantly share code, notes, and snippets.

@david-hodgetts
Created August 8, 2013 13:55
Show Gist options
  • Save david-hodgetts/6184788 to your computer and use it in GitHub Desktop.
Save david-hodgetts/6184788 to your computer and use it in GitHub Desktop.
robofont script function. creates a dictionary mapping unicode values to glyphNames
import vanilla
import mojo
from mojo.UI import getDefaultCharacterSet, getCharacterSets
def buildDictFromUnicodeToGlyphname():
"HACK: builds a dict from unicode to glyphnames"
defaultCharSet = getCharacterSets()[getDefaultCharacterSet()]
font = NewFont()
result = {}
for glyphName in defaultCharSet:
glyph = font.getGlyph(glyphName)
result[glyph.unicode] = glyphName
font.close(False)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment