1#!/usr/bin/env python3 2 3"""usage: ./gen-arabic-pua.py 4""" 5 6import packTab 7 8 9print ("/* == Start of generated table == */") 10print ("/*") 11print (" * The following table is generated by running:") 12print (" *") 13print (" * ./gen-arabic-pua.py") 14print (" *") 15print (" */") 16print () 17print ("#ifndef HB_OT_SHAPER_ARABIC_PUA_HH") 18print ("#define HB_OT_SHAPER_ARABIC_PUA_HH") 19print () 20 21code = packTab.Code('_hb_arabic') 22 23for p in ("ArabicPUASimplified.txt", "ArabicPUATraditional.txt"): 24 with open (p, encoding='utf-8') as f: 25 fields = [l.split('\t') for l in f if l[:1] != '#'] 26 data = {int(fs[1], 16):int(fs[0], 16) for fs in fields} 27 sol = packTab.pack_table(data, compression=9) 28 sol.genCode(code, f'pua_{p[9:13].lower()}_map') 29 30code.print_c(linkage='static inline') 31 32print () 33print ("#endif /* HB_OT_SHAPER_ARABIC_PUA_HH */") 34print () 35print ("/* == End of generated table == */") 36