From 0788f7737183d6a309798da7a5e3bcce8b7c8fa6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 27 Jul 2022 13:58:44 -0600 Subject: [PATCH] [use-table] Add a main() to print categories --- src/gen-use-table.py | 20 ++++++++++++++++++++ src/hb-ot-shaper-use-table.hh | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/gen-use-table.py b/src/gen-use-table.py index 5e6a3b02f..2e27cd960 100755 --- a/src/gen-use-table.py +++ b/src/gen-use-table.py @@ -497,6 +497,26 @@ for k,v in sorted(use_positions.items()): tag = k + suf print ("#undef %s" % tag) print () +print (""" +#ifdef HB_USE_TABLE_MAIN +int main (int argc, char **argv) +{ + if (argc != 2) + { + printf ("usage: %s hex-char\n", argv[0]); + return 1; + } + + hb_codepoint_t u; + sscanf (argv[1], "%x", &u); + + printf ("%d\n", hb_use_get_category (u)); + + return 0; +} + +#endif +""") print () print ("#endif /* HB_OT_SHAPER_USE_TABLE_HH */") print ("/* == End of generated table == */") diff --git a/src/hb-ot-shaper-use-table.hh b/src/hb-ot-shaper-use-table.hh index 63614d653..cde150e7c 100644 --- a/src/hb-ot-shaper-use-table.hh +++ b/src/hb-ot-shaper-use-table.hh @@ -393,5 +393,27 @@ hb_use_get_category (unsigned u) #undef VMPre +#ifdef HB_USE_TABLE_MAIN +int main (int argc, char **argv) +{ + if (argc != 2) + { + printf ("usage: %s hex-char +", argv[0]); + return 1; + } + + hb_codepoint_t u; + sscanf (argv[1], "%x", &u); + + printf ("%d +", hb_use_get_category (u)); + + return 0; +} + +#endif + + #endif /* HB_OT_SHAPER_USE_TABLE_HH */ /* == End of generated table == */