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 == */")
gc[i] = gc[i - 1] for i in range(len(gc) - 2, -1, -1): if ((i + 1) % 128) and gc[i] == 'Cn': gc[i] = gc[i + 1] for i in range(len(sc)): if (i % 128) and sc[i] == 'Zzzz': sc[i] = sc[i - 1] for i in range(len(sc) - 2, -1, -1): if ((i + 1) % 128) and sc[i] == 'Zzzz': sc[i] = sc[i + 1] code = packTab.Code('_hb_ucd') for name, data, default, mapping in datasets: sol = packTab.pack_table(data, default, mapping=mapping, compression=compression) logging.info(' Dataset=%-8s FullCost=%d' % (name, sol.fullCost)) sol.genCode(code, name) code.print_c(linkage='static inline') print() print('#endif') print() print() print("#endif /* HB_UCD_TABLE_HH */") print() print("/* == End of generated table == */")
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 == */")
# Output table 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}
dm1_16_array, _ = code.addArray('uint16_t', 'dm1_u16_map', dm1_u16_array) dm1_32_array, _ = code.addArray('uint32_t', 'dm1_u32_map', dm1_u32_array) dm2_array, _ = code.addArray('uint64_t', 'dm2_map', dm2_array) code.print_c(linkage='static inline') for compression in (DEFAULT, COMPACT): print() if compression == DEFAULT: print('#ifndef HB_OPTIMIZE_SIZE') else: print('#else') print() code = packTab.Code('_hb_ucd') packTab.pack_table(gc, 'Cn', mapping=gc_order, compression=compression).genCode(code, 'gc') packTab.pack_table(ccc, 0, compression=compression).genCode(code, 'ccc') packTab.pack_table(bmg, 0, compression=compression).genCode(code, 'bmg') packTab.pack_table(sc, 'Zzzz', mapping=sc_order, compression=compression).genCode(code, 'sc') packTab.pack_table(dm, None, mapping=dm_order, compression=compression).genCode(code, 'dm') code.print_c(linkage='static inline') if compression != DEFAULT: print() print('#endif') print() print()
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""" #ifdef HB_USE_TABLE_MAIN