[hb-info] Add --show-family

This commit is contained in:
Behdad Esfahbod 2023-01-19 15:05:00 -07:00
parent f25c03162b
commit fecb2eeca0
1 changed files with 27 additions and 0 deletions

View File

@ -41,6 +41,7 @@ struct info_t
{"all", 'a', 0, G_OPTION_ARG_NONE, &this->all, "Show everything", nullptr}, {"all", 'a', 0, G_OPTION_ARG_NONE, &this->all, "Show everything", nullptr},
{"show-all", 0, 0, G_OPTION_ARG_NONE, &this->show_all, "Show all short information", nullptr}, {"show-all", 0, 0, G_OPTION_ARG_NONE, &this->show_all, "Show all short information", nullptr},
{"show-family", 0, 0, G_OPTION_ARG_NONE, &this->show_family, "Show family name", nullptr},
{"show-upem", 0, 0, G_OPTION_ARG_NONE, &this->show_upem, "Show Units-Per-EM", nullptr}, {"show-upem", 0, 0, G_OPTION_ARG_NONE, &this->show_upem, "Show Units-Per-EM", nullptr},
{"show-unicode-count",0, 0, G_OPTION_ARG_NONE, &this->show_unicode_count, "Show Unicode count", nullptr}, {"show-unicode-count",0, 0, G_OPTION_ARG_NONE, &this->show_unicode_count, "Show Unicode count", nullptr},
{"show-glyph-count",0, 0, G_OPTION_ARG_NONE, &this->show_glyph_count, "Show glyph count", nullptr}, {"show-glyph-count",0, 0, G_OPTION_ARG_NONE, &this->show_glyph_count, "Show glyph count", nullptr},
@ -75,6 +76,7 @@ struct info_t
hb_bool_t all = false; hb_bool_t all = false;
hb_bool_t show_all = false; hb_bool_t show_all = false;
hb_bool_t show_family = false;
hb_bool_t show_upem = false; hb_bool_t show_upem = false;
hb_bool_t show_unicode_count = false; hb_bool_t show_unicode_count = false;
hb_bool_t show_glyph_count = false; hb_bool_t show_glyph_count = false;
@ -108,6 +110,7 @@ struct info_t
if (show_all) if (show_all)
{ {
show_family =
show_upem = show_upem =
show_unicode_count = show_unicode_count =
show_glyph_count = show_glyph_count =
@ -129,6 +132,7 @@ struct info_t
true; true;
} }
if (show_family) _show_family ();
if (show_upem) _show_upem (); if (show_upem) _show_upem ();
if (show_unicode_count) _show_unicode_count (); if (show_unicode_count) _show_unicode_count ();
if (show_glyph_count) _show_glyph_count (); if (show_glyph_count) _show_glyph_count ();
@ -159,6 +163,29 @@ struct info_t
printf ("\n===\n\n"); printf ("\n===\n\n");
} }
void _show_name (const char *label, hb_ot_name_id_t name_id)
{
if (verbose)
{
printf ("%s: ", label);
}
auto language = hb_language_get_default ();
char name[128];
unsigned name_len = sizeof name;
hb_ot_name_get_utf8 (face, name_id,
language,
&name_len, name);
printf ("%s\n", name);
}
void _show_family ()
{
_show_name ("Family", 1);
}
void _show_upem () void _show_upem ()
{ {
if (verbose) if (verbose)