Rev 4680 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4680 | right-hear | 1 | #!/usr/bin/python |
2 | |||
3 | import sys |
||
4 | |||
5 | agl = [] |
||
6 | agltab = [] |
||
7 | aglmap = {} |
||
8 | |||
9 | print "/*" |
||
10 | |||
11 | f = open("glyphlist.txt", "r") |
||
12 | for line in f.readlines(): |
||
13 | if line[0] == '#': |
||
14 | print line.strip() |
||
15 | continue |
||
16 | line = line[:-1] |
||
17 | name, list = line.split(';') |
||
18 | list = map(lambda x: int(x, 16), list.split(' ')) |
||
19 | agl.append((name, list)) |
||
20 | |||
21 | for name, ucslist in agl: |
||
22 | num = len(ucslist) |
||
23 | ucs = ucslist[0] |
||
24 | agltab.append((name, ucs)) |
||
25 | if ucs not in aglmap: |
||
26 | aglmap[ucs] = [] |
||
27 | aglmap[ucs].append(name) |
||
28 | |||
29 | print "*/" |
||
30 | |||
31 | |||
32 | def dumplist(list): |
||
33 | n = 0; |
||
34 | for item in list: |
||
35 | n += len(item) + 1 |
||
36 | if n > 78: |
||
37 | sys.stdout.write("\n") |
||
38 | n = len(item) + 1 |
||
39 | sys.stdout.write(item) |
||
40 | sys.stdout.write(",") |
||
41 | sys.stdout.write("\n") |
||
42 | |||
43 | agltab.sort() |
||
44 | namelist = [] |
||
45 | codelist = [] |
||
46 | for name, ucs in agltab: |
||
47 | namelist.append("\"%s\"" % name) |
||
48 | codelist.append("%d" % ucs) |
||
49 | |||
50 | keys = aglmap.keys() |
||
51 | keys.sort() |
||
52 | dupoffsets = [] |
||
53 | dupnames = [] |
||
54 | for ucs in keys: |
||
55 | list = aglmap[ucs] |
||
56 | ofs = len(dupnames) |
||
57 | if len(list) > 1: |
||
58 | dupoffsets.append("%d,%d" % (ucs, ofs)) |
||
59 | for name in list: |
||
60 | dupnames.append("\"%s\"" % name) |
||
61 | dupnames.append("0") |
||
62 | |||
63 | print "static const char *agl_name_list[] = {" |
||
64 | dumplist(namelist) |
||
65 | print "};" |
||
66 | |||
67 | print "static const unsigned short agl_code_list[] = {" |
||
68 | dumplist(codelist) |
||
69 | print "};" |
||
70 | |||
71 | print "static const unsigned short agl_dup_offsets[] = {" |
||
72 | dumplist(dupoffsets) |
||
73 | print "};" |
||
74 | |||
75 | print "static const char *agl_dup_names[] = {" |
||
76 | dumplist(dupnames) |
||
77 | print "};" |