[use-table] Add a main() to print categories

This commit is contained in:
Behdad Esfahbod 2022-07-27 13:58:44 -06:00
parent 9aaa835ac1
commit 0788f77371
2 changed files with 42 additions and 0 deletions

View File

@ -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 == */")

View File

@ -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 == */