Skip to content

Instantly share code, notes, and snippets.

@gferreira
Created June 12, 2013 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gferreira/5764612 to your computer and use it in GitHub Desktop.
Save gferreira/5764612 to your computer and use it in GitHub Desktop.
simple accent builder
# [h] simple accent builder
# functions
def build_glyph(font, glyph_name, accents_dict, verbose=True):
if accents_dict.has_key(glyph_name):
if verbose:
print 'building %s...' % glyph_name
base_glyph, accents = accents_dict[glyph_name]
font.removeGlyph(glyph_name)
font.compileGlyph(glyph_name, base_glyph, accents)
font[glyph_name].update()
else:
if verbose:
print '# no entry for %s' % glyph_name
# accents data
accents_dict = {
# add your glyph composition recipes here.
# composed_glyph : [ base_glyph, ( (accent1, anchor1), (accent2, anchor2), ... ) ],
'aogonek' : [ 'a', ( ('ogonek', 'bottom'), ) ],
'agrave' : [ 'a', ( ('grave', 'top'), ) ],
'ccedilla' : [ 'c', ( ('cedilla', 'bottom'), ) ],
}
# build accents
f = CurrentFont()
for glyph_name in f.selection:
build_glyph(f, glyph_name, accents_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment