3 """usage: ./gen-arabic-joining-table.py ArabicShaping.txt Scripts.txt
6 * https://unicode.org/Public/UCD/latest/ucd/ArabicShaping.txt
7 * https://unicode.org/Public/UCD/latest/ucd/Scripts.txt
12 if len (sys.argv) != 3:
15 files = [open (x, encoding='utf-8') for x in sys.argv[1:]]
17 headers = [[f.readline (), f.readline ()] for f in files]
18 while files[0].readline ().find ('##################') < 0:
29 fields = [x.strip () for x in line.split (';')]
33 uu = fields[0].split ('..')
34 start = int (uu[0], 16)
42 for u in range (start, end + 1):
47 def read_joining_uu (f):
54 fields = [x.strip () for x in line.split (';')]
57 if fields[2] in {'T', 'U'}:
60 values.add (int (fields[0], 16))
62 return sorted (values)
64 def print_has_arabic_joining (scripts, joining_uu):
67 print ("has_arabic_joining (hb_script_t script)")
69 print (" /* List of scripts that have data in arabic-table. */")
70 print (" switch ((int) script)")
73 for script in sorted ({scripts[u] for u in joining_uu if scripts[u] not in {'Common', 'Inherited'}}):
74 print (" case HB_SCRIPT_{}:".format (script.upper ()))
76 print (" return true;")
79 print (" return false;")
84 print ("/* == Start of generated function == */")
86 print (" * The following function is generated by running:")
88 print (" * ./gen-arabic-joining-list.py ArabicShaping.txt Scripts.txt")
90 print (" * on files with these headers:")
94 print (" * %s" % (l.strip ()))
97 print ("#ifndef HB_OT_SHAPER_ARABIC_JOINING_LIST_HH")
98 print ("#define HB_OT_SHAPER_ARABIC_JOINING_LIST_HH")
101 print_has_arabic_joining (read (files[1]), read_joining_uu (files[0]))
104 print ("#endif /* HB_OT_SHAPER_ARABIC_JOINING_LIST_HH */")
106 print ("/* == End of generated function == */")