diff options
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/gen-ucd-table.py')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/gen-ucd-table.py | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-ucd-table.py b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-ucd-table.py index 3f821802d7d..c98c715e112 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-ucd-table.py +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-ucd-table.py @@ -3,19 +3,22 @@ from __future__ import print_function, division, absolute_import import io, os.path, sys, re +import logging +logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) if len (sys.argv) != 2: print("usage: ./gen-ucd-table ucd.nonunihan.grouped.xml", file=sys.stderr) sys.exit(1) - # https://github.com/harfbuzz/packtab import packTab import packTab.ucdxml +logging.info('Loading UCDXML...') ucdxml = packTab.ucdxml.load_ucdxml(sys.argv[1]) ucd = packTab.ucdxml.ucdxml_get_repertoire(ucdxml) +logging.info('Preparing data tables...') gc = [u['gc'] for u in ucd] ccc = [int(u['ccc']) for u in ucd] @@ -31,14 +34,15 @@ ce = {i for i,u in enumerate(ucd) if u['Comp_Ex'] == 'Y'} assert not any(v for v in dm.values() if len(v) not in (1,2)) dm1 = sorted(set(v for v in dm.values() if len(v) == 1)) -dm1_array = ['0x%04Xu' % v for v in dm1] +dm1_u16_array = ['0x%04Xu' % v for v in dm1 if v[0] <= 0xFFFF] +dm1_u32_array = ['0x%04Xu' % v for v in dm1 if v[0] > 0xFFFF] dm1_order = {v:i+1 for i,v in enumerate(dm1)} dm2 = sorted((v, i) for i,v in dm.items() if len(v) == 2) dm2 = [("HB_CODEPOINT_ENCODE3 (0x%04Xu, 0x%04Xu, 0x%04Xu)" % (v+(i if i not in ce and not ccc[i] else 0,)), v) for v,i in dm2] dm2_array = [s for s,v in dm2] -l = 1 + len(dm1_array) +l = 1 + len(dm1_u16_array) + len(dm1_u32_array) dm2_order = {v[1]:i+l for i,v in enumerate(dm2)} dm_order = {None: 0} dm_order.update(dm1_order) @@ -70,6 +74,7 @@ DEFAULT = 1 COMPACT = 3 +logging.info('Generating output...') print("/* == Start of generated table == */") print("/*") print(" * The following table is generated by running:") @@ -82,18 +87,26 @@ print() print("#ifndef HB_UCD_TABLE_HH") print("#define HB_UCD_TABLE_HH") print() - -print() print('#include "hb.hh"') print() code = packTab.Code('_hb_ucd') sc_array, _ = code.addArray('hb_script_t', 'sc_map', sc_array) -dm1_array, _ = code.addArray('hb_codepoint_t', 'dm1_map', dm1_array) +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') +datasets = [ + ('gc', gc, 'Cn', gc_order), + ('ccc', ccc, 0, None), + ('bmg', bmg, 0, None), + ('sc', sc, 'Zzzz', sc_order), + ('dm', dm, None, dm_order), +] + for compression in (DEFAULT, COMPACT): + logging.info(' Compression=%d:' % compression) print() if compression == DEFAULT: print('#ifndef HB_OPTIMIZE_SIZE') @@ -103,11 +116,10 @@ for compression in (DEFAULT, COMPACT): 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') + 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') @@ -121,3 +133,4 @@ print() print("#endif /* HB_UCD_TABLE_HH */") print() print("/* == End of generated table == */") +logging.info('Done.') |