From f1d20d9b4dcbeead3757650b9286393918b4be8a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 2 Jul 2019 14:18:38 -0700 Subject: [PATCH] Add ucd-table make target --- src/Makefile.am | 23 +++++++++++++++-------- src/gen-ucd-table.py | 8 +++++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index d4ba39a..e7b279d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -253,31 +253,38 @@ GENERATORS = \ $(NULL) EXTRA_DIST += $(GENERATORS) -unicode-tables: arabic-table indic-table tag-table use-table emoji-table +unicode-tables: \ + arabic-table \ + emoji-table \ + indic-table \ + tag-table \ + ucd-table \ + use-table \ + emoji-table \ + $(NULL) arabic-table: gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-shape-complex-arabic-table.hh \ || ($(RM) $(srcdir)/hb-ot-shape-complex-arabic-table.hh; false) - +emoji-table: gen-emoji-table.py emoji-data.txt + $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-unicode-emoji-table.hh \ + || ($(RM) $(srcdir)/hb-unicode-emoji-table.hh; false) indic-table: gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-shape-complex-indic-table.cc \ || ($(RM) $(srcdir)/hb-ot-shape-complex-indic-table.cc; false) - tag-table: gen-tag-table.py languagetags language-subtag-registry $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-tag-table.hh \ || ($(RM) $(srcdir)/hb-ot-tag-table.hh; false) - +ucd-table: gen-ucd-table.py ucd.nounihan.grouped.zip hb-common.h + $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ucd-table.hh \ + || ($(RM) $(srcdir)/hb-ucd-table.hh; false) use-table: gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-shape-complex-use-table.cc \ || ($(RM) $(srcdir)/hb-ot-shape-complex-use-table.cc; false) - vowel-constraints: gen-vowel-constraints.py HBIndicVowelConstraints.txt Scripts.txt $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-shape-complex-vowel-constraints.cc \ || ($(RM) $(srcdir)/hb-ot-shape-complex-vowel-constraints.cc; false) -emoji-table: gen-emoji-table.py emoji-data.txt - $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-unicode-emoji-table.hh \ - || ($(RM) $(srcdir)/hb-unicode-emoji-table.hh; false) built-sources: $(BUILT_SOURCES) diff --git a/src/gen-ucd-table.py b/src/gen-ucd-table.py index a152375..552c3c6 100755 --- a/src/gen-ucd-table.py +++ b/src/gen-ucd-table.py @@ -6,8 +6,8 @@ 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.nounihan.grouped.xml", file=sys.stderr) +if len (sys.argv) not in (2, 3): + print("usage: ./gen-ucd-table ucd.nounihan.grouped.xml [/path/to/hb-common.h]", file=sys.stderr) sys.exit(1) # https://github.com/harfbuzz/packtab @@ -18,6 +18,8 @@ logging.info('Loading UCDXML...') ucdxml = packTab.ucdxml.load_ucdxml(sys.argv[1]) ucd = packTab.ucdxml.ucdxml_get_repertoire(ucdxml) +hb_common_h = 'hb-common.h' if len (sys.argv) < 3 else sys.argv[2] + logging.info('Preparing data tables...') gc = [u['gc'] for u in ucd] @@ -68,7 +70,7 @@ for i,v in enumerate(('Cc', 'Cf', 'Cn', 'Co', 'Cs', 'Ll', 'Lm', 'Lo', 'Lt', 'Lu' sc_order = dict() sc_array = [] sc_re = re.compile(r"\b(HB_SCRIPT_[_A-Z]*).*HB_TAG [(]'(.)','(.)','(.)','(.)'[)]") -for line in open('hb-common.h'): +for line in open(hb_common_h): m = sc_re.search (line) if not m: continue name = m.group(1) -- 2.7.4