def extract_encoding(ufo_path, enc_path=None):
    # get glyph names from ufo
    try:
        ufo = OpenFont(ufo_path, showUI=False)
    except:
        ufo = OpenFont(ufo_path)
    enc = ''
    for glyph_name in ufo.glyphOrder:
        enc += '%s\n' % glyph_name
    ufo.close()
    # save to .enc file
    if enc_path is not None:
        enc_file = open(enc_path, 'w')
        enc_file.write(enc)
        enc_file.close()
    # done
    return enc
Extract encoding data from an ufo's glyphOrder attribute.
dataset/ETHPy150Open gferreira/hTools2/Lib/hTools2/modules/encoding.py/extract_encoding