[hb-info] Add --list-style

This commit is contained in:
Behdad Esfahbod 2023-01-22 15:00:10 -07:00
parent 090a6d0dde
commit 0b7d3952ba
1 changed files with 28 additions and 1 deletions

View File

@ -105,6 +105,7 @@ struct info_t
{"list-all", 0, 0, G_OPTION_ARG_NONE, &this->list_all, "List all long information", nullptr}, {"list-all", 0, 0, G_OPTION_ARG_NONE, &this->list_all, "List all long information", nullptr},
{"list-names", 0, 0, G_OPTION_ARG_NONE, &this->list_names, "List names", nullptr}, {"list-names", 0, 0, G_OPTION_ARG_NONE, &this->list_names, "List names", nullptr},
#ifdef HB_HAS_GOBJECT #ifdef HB_HAS_GOBJECT
{"list-style", 0, 0, G_OPTION_ARG_NONE, &this->list_style, "List style", nullptr},
{"list-metrics", 0, 0, G_OPTION_ARG_NONE, &this->list_metrics, "List metrics", nullptr}, {"list-metrics", 0, 0, G_OPTION_ARG_NONE, &this->list_metrics, "List metrics", nullptr},
#endif #endif
{"list-tables", 'l', 0, G_OPTION_ARG_NONE, &this->list_tables, "List tables", nullptr}, {"list-tables", 'l', 0, G_OPTION_ARG_NONE, &this->list_tables, "List tables", nullptr},
@ -169,6 +170,7 @@ struct info_t
hb_bool_t list_all = false; hb_bool_t list_all = false;
hb_bool_t list_names = false; hb_bool_t list_names = false;
#ifdef HB_HAS_GOBJECT #ifdef HB_HAS_GOBJECT
hb_bool_t list_style = false;
hb_bool_t list_metrics = false; hb_bool_t list_metrics = false;
#endif #endif
hb_bool_t list_tables = false; hb_bool_t list_tables = false;
@ -232,6 +234,7 @@ struct info_t
{ {
list_names = list_names =
#ifdef HB_HAS_GOBJECT #ifdef HB_HAS_GOBJECT
list_style =
list_metrics = list_metrics =
#endif #endif
list_tables = list_tables =
@ -267,6 +270,7 @@ struct info_t
if (list_names) _list_names (); if (list_names) _list_names ();
#ifdef HB_HAS_GOBJECT #ifdef HB_HAS_GOBJECT
if (list_style) _list_style ();
if (list_metrics) _list_metrics (); if (list_metrics) _list_metrics ();
#endif #endif
if (list_tables) _list_tables (); if (list_tables) _list_tables ();
@ -575,12 +579,35 @@ struct info_t
} }
#ifdef HB_HAS_GOBJECT #ifdef HB_HAS_GOBJECT
void _list_style ()
{
if (verbose)
{
separator ();
printf ("Style information:\n\n");
printf ("Tag: Name Value\n---------------------------------------------\n");
}
GEnumClass *enum_class = (GEnumClass *) g_type_class_ref ((GType) HB_GOBJECT_TYPE_STYLE_TAG);
unsigned count = enum_class->n_values;
const auto *entries = enum_class->values;
for (unsigned i = 0; i < count; i++)
{
float v = hb_style_get_value (font, (hb_style_tag_t) entries[i].value);
printf ("%c%c%c%c", HB_UNTAG(entries[i].value));
if (verbose)
printf (": %-33s", entries[i].value_nick);
printf (" %g\n", (double) v);
}
}
void _list_metrics () void _list_metrics ()
{ {
if (verbose) if (verbose)
{ {
separator (); separator ();
printf ("Metric information:\n\n"); printf ("Metrics information:\n\n");
printf ("Tag: Name Value\n---------------------------------------------\n"); printf ("Tag: Name Value\n---------------------------------------------\n");
} }