File: gen_classes.py

package info (click to toggle)
fonts-chomsky 2.3%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,060 kB
  • sloc: python: 224; sh: 20; makefile: 4
file content (37 lines) | stat: -rwxr-xr-x 846 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import fontforge
import unicodedata

font = fontforge.open("Chomsky.sfd")
rarr = '→'
o = dict()

for g in font.glyphs():
    try:
        c = chr(g.unicode)
    except ValueError: continue

    nd = unicodedata.normalize('NFD', c)

    #print(g.glyphname, c, nd, rarr, list(c), list(nd))

    # i.e. if character can be decomposed into nd[0] (base) and nd[1] (mark)
    if len(list(nd)) == 2:
        if not nd[0] in o: o[nd[0]] = list()
        o[nd[0]].append(g.glyphname)

o['i'].append("dotlessi")
o['j'].append("dotlessj")
for g, e in sorted(o.items()):
    print("@{0} = [{0} {1}];".format(g, ' '.join(e)))


import string

consider = list(string.ascii_lowercase+string.ascii_uppercase)

if len(consider) != len(o.keys()):
    print("\n# Lonely letters")

for c in consider:
    if c not in o:
        print("@{0} = [{0}];".format(c))