conv_glyphlist.py 613 Bytes
Newer Older
1
#!/usr/bin/env python
2

3 4 5 6 7 8 9 10 11 12
import sys
import fileinput

def main(argv):
    state = 0
    for line in fileinput.input():
        line = line.strip()
        if not line or line.startswith('#'):
            if state == 1:
                state = 2
13 14
                print ('}\n')
            print (line)
15 16
            continue
        if state == 0:
17
            print ('\nglyphname2unicode = {')
18 19 20
            state = 1
        (name,x) = line.split(';')
        codes = x.split(' ')
21
        print (' %r: u\'%s\',' % (name, ''.join( '\\u%s' % code for code in codes )))
22 23

if __name__ == '__main__': sys.exit(main(sys.argv))