From fecb2eeca0120e4cf9d06f3164e38d4daa983bd0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 19 Jan 2023 15:05:00 -0700 Subject: [PATCH] [hb-info] Add --show-family --- util/hb-info.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/util/hb-info.cc b/util/hb-info.cc index b1724c7b8..4917b446b 100644 --- a/util/hb-info.cc +++ b/util/hb-info.cc @@ -41,6 +41,7 @@ struct info_t {"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-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-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}, @@ -75,6 +76,7 @@ struct info_t hb_bool_t all = false; hb_bool_t show_all = false; + hb_bool_t show_family = false; hb_bool_t show_upem = false; hb_bool_t show_unicode_count = false; hb_bool_t show_glyph_count = false; @@ -108,6 +110,7 @@ struct info_t if (show_all) { + show_family = show_upem = show_unicode_count = show_glyph_count = @@ -129,6 +132,7 @@ struct info_t true; } + if (show_family) _show_family (); if (show_upem) _show_upem (); if (show_unicode_count) _show_unicode_count (); if (show_glyph_count) _show_glyph_count (); @@ -159,6 +163,29 @@ struct info_t 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 () { if (verbose)