print (" * on file with this header:")
print (" *")
for l in header:
	print (" * %s" % (l.strip()))
print (" */")
print ()
print ("#ifndef HB_UNICODE_EMOJI_TABLE_HH")
print ("#define HB_UNICODE_EMOJI_TABLE_HH")
print ()
print ('#include "hb-unicode.hh"')
print ()

for typ, s in ranges.items():
	if typ != "Extended_Pictographic": continue

	arr = dict()
	for start,end in s:
		for i in range(start,end):
			arr[i] = 1

	sol = packTab.pack_table(arr, 0, compression=3)
	code = packTab.Code('_hb_emoji')
	sol.genCode(code, 'is_'+typ)
	code.print_c(linkage='static inline')
	print()

print ()
print ("#endif /* HB_UNICODE_EMOJI_TABLE_HH */")
print ()
print ("/* == End of generated table == */")
Пример #2
0
print("/* == Start of generated table == */")
print("/*")
print(" * The following table is generated by running:")
print(" *")
print(" *   ./gen-ucd-table.py ucd.nounihan.grouped.xml")
print(" *")
print(" * on file with this description:", ucdxml.description)
print(" */")
print()
print("#ifndef HB_UCD_TABLE_HH")
print("#define HB_UCD_TABLE_HH")
print()
print('#include "hb.hh"')
print()

code = packTab.Code('_hb_ucd')
sc_array, _ = code.addArray('hb_script_t', 'sc_map', sc_array)
dm1_p0_array, _ = code.addArray('uint16_t', 'dm1_p0_map', dm1_p0_array)
dm1_p2_array, _ = code.addArray('uint16_t', 'dm1_p2_map', dm1_p2_array)
dm2_u32_array, _ = code.addArray('uint32_t', 'dm2_u32_map', dm2_u32_array)
dm2_u64_array, _ = code.addArray('uint64_t', 'dm2_u64_map', dm2_u64_array)
code.print_c(linkage='static inline')

datasets = [
    ('gc', gc, 'Cn', gc_order),
    ('ccc', ccc, 0, None),
    ('bmg', bmg, 0, None),
    ('sc', sc, 'Zzzz', sc_order),
    ('dm', dm, None, dm_order),
]
Пример #3
0
    print()

    print("extern const ucdb_entry UCDB_TABLE[] = {")
    for script, bclass, lbreak, zspace, cbreak, paired in records:
        print(
            f"    {{ UCDB_SCRIPT_{script.upper()}, UCDB_BIDI_{bclass}, UCDB_LBREAK_{lbreak}, {'true' if zspace else 'false'}, UCDB_CBREAK_{cbreak.upper()}, {'true' if paired else 'false'} }},"
        )
    print("};")
    print()

    # Use packTab to build an index mapping a character to a record.

    solutions = packTab.pack_table(data, 0, None)
    solution = packTab.pick_solution(solutions, compression=1)
    code = packTab.Code('ucdb')
    expr = solution.genCode(code, 'index')
    code.print_c()
    print()

else:

    # Build enums

    cbreak_enum = {record[4] for record in records}

    print()

    bclass_enum = {record[1].upper() for record in records}
    bclass_enum.remove("L")
    bclass_enum.remove("R")
Пример #4
0
import packTab

print("/* == Start of generated table == */")
print("/*")
print(" * The following table is generated by running:")
print(" *")
print(" *   ./gen-arabic-pua.py")
print(" *")
print(" */")
print()
print("#ifndef HB_OT_SHAPER_ARABIC_PUA_HH")
print("#define HB_OT_SHAPER_ARABIC_PUA_HH")
print()

code = packTab.Code('_hb_arabic')

for p in ("ArabicPUASimplified.txt", "ArabicPUATraditional.txt"):
    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, f'pua_{p[9:13].lower()}_map')

code.print_c(linkage='static inline')

print()
print("#endif /* HB_OT_SHAPER_ARABIC_PUA_HH */")
print()
print("/* == End of generated table == */")
Пример #5
0
print('#pragma GCC diagnostic push')
print('#pragma GCC diagnostic ignored "-Wunused-macros"')
for k, v in sorted(use_mapping.items()):
    if k in use_positions and use_positions[k]: continue
    print("#define %s	USE(%s)	/* %s */" % (k, k, v.__name__[3:]))
for k, v in sorted(use_positions.items()):
    if not v: continue
    for suf in v.keys():
        tag = k + suf
        print("#define %s	USE(%s)" % (tag, tag))
print('#pragma GCC diagnostic pop')
print("")

import packTab
data = {u: v[0] for u, v in use_data.items()}
code = packTab.Code('hb_use')
sol = packTab.pack_table(data, compression=5, default='O')
sol.genCode(code, f'get_category')
code.print_c(linkage='static inline')

print()
for k in sorted(use_mapping.keys()):
    if k in use_positions and use_positions[k]: continue
    print("#undef %s" % k)
for k, v in sorted(use_positions.items()):
    if not v: continue
    for suf in v.keys():
        tag = k + suf
        print("#undef %s" % tag)
print()
print(r"""