[ucd] Print out table sizes
This commit is contained in:
parent
f4de0c7754
commit
b1a2384a52
@ -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]
|
||||
@ -71,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,8 +86,6 @@ print(" */")
|
||||
print()
|
||||
print("#ifndef HB_UCD_TABLE_HH")
|
||||
print("#define HB_UCD_TABLE_HH")
|
||||
print()
|
||||
|
||||
print()
|
||||
print('#include "hb.hh"')
|
||||
print()
|
||||
@ -95,7 +97,16 @@ 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')
|
||||
@ -105,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')
|
||||
|
||||
@ -123,3 +133,4 @@ print()
|
||||
print("#endif /* HB_UCD_TABLE_HH */")
|
||||
print()
|
||||
print("/* == End of generated table == */")
|
||||
logging.info('Done.')
|
||||
|
@ -10,7 +10,6 @@
|
||||
#ifndef HB_UCD_TABLE_HH
|
||||
#define HB_UCD_TABLE_HH
|
||||
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
static const hb_script_t
|
||||
|
Loading…
Reference in New Issue
Block a user