Always allocate new ligature id
[framework/uifw/harfbuzz.git] / src / gen-arabic-joining-table.py
1 #!/usr/bin/python
2
3 import sys
4
5 header = sys.stdin.readline(), sys.stdin.readline()
6 dic = dict()
7 for line in sys.stdin:
8         if line[:1] != '0':
9                 continue
10
11         fields = [x.strip() for x in line.split(';')]
12         u = int(fields[0], 16)
13
14         if u < 0x0600 or (u > 0x07FF and u != 0x200C and u != 0x200D):
15                 raise Exception ("Ooops, unexpected unicode character: ", fields)
16         dic[u] = fields
17
18 print "  /*"
19 print "   * The following table is generated by running:"
20 print "   *"
21 print "   *   ./gen-arabic-joining-table.py < ArabicShaping.txt"
22 print "   *"
23 print "   * on the ArabicShaping.txt file with the header:"
24 print "   *"
25 for line in header:
26         print "   * %s" % (line.strip())
27 print "   */"
28 print "  /* == Start of generated table == */"
29 for i in range(0x0600, 0x0800):
30         if i not in dic:
31                 print "  JOINING_TYPE_X, /* %04X */" % i
32         else:
33                 entry = dic[i]
34                 if entry[3] in ["ALAPH", "DALATH RISH"]:
35                         value = "JOINING_GROUP_" + entry[3].replace(' ', '_')
36                 else:
37                         value = "JOINING_TYPE_" + entry[2]
38                 print "  %s, /* %s */" % (value, '; '.join(entry))
39 print "  /* == End of generated table == */"