64 lines
1.6 KiB
Python
Executable file
64 lines
1.6 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
"""usage: ./gen-arabic-pua.py [--rust] ArabicPUASimplified.txt ArabicPUATraditional.txt
|
|
"""
|
|
|
|
import sys
|
|
|
|
import packTab
|
|
|
|
if len(sys.argv) > 1 and sys.argv[1] == "--rust":
|
|
del sys.argv[1]
|
|
language = packTab.languages["rust"]
|
|
else:
|
|
language = packTab.languages["c"]
|
|
|
|
if len(sys.argv) != 3:
|
|
sys.exit(__doc__)
|
|
|
|
paths = sys.argv[1:]
|
|
|
|
print ("/* == Start of generated table == */")
|
|
print ("/*")
|
|
print (" * The following table is generated by running:")
|
|
print (" *")
|
|
print (" * ./gen-arabic-pua.py%s ArabicPUASimplified.txt ArabicPUATraditional.txt" %
|
|
(" --rust" if language.name == "rust" else ""))
|
|
print (" *")
|
|
print (" */")
|
|
print ()
|
|
if language.name == "c":
|
|
print ("#ifndef HB_OT_SHAPER_ARABIC_PUA_HH")
|
|
print ("#define HB_OT_SHAPER_ARABIC_PUA_HH")
|
|
print ()
|
|
print ('#include "hb.hh"')
|
|
print ()
|
|
else:
|
|
print ("#![allow(clippy::unreadable_literal)]")
|
|
print ()
|
|
|
|
code = packTab.Code('_hb_arabic_pua')
|
|
|
|
for p, name in zip(paths, ("simp_map", "trad_map")):
|
|
with open (p, encoding='utf-8') as f:
|
|
fields = [l.split('\t') for l in f if l[:1] != '#']
|
|
data = {int(fs[1], 16):int(fs[0], 16) for fs in fields}
|
|
sol = packTab.pack_table(data, compression=9)
|
|
sol.genCode(
|
|
code,
|
|
name,
|
|
language=language,
|
|
private=language.name == "c",
|
|
)
|
|
|
|
code.print_code(
|
|
file=sys.stdout,
|
|
language=language,
|
|
private=language.name == "c",
|
|
)
|
|
|
|
if language.name == "c":
|
|
print ()
|
|
print ("#endif /* HB_OT_SHAPER_ARABIC_PUA_HH */")
|
|
print ()
|
|
print ("/* == End of generated table == */")
|