[hb-info] Add --list-meta

This commit is contained in:
Behdad Esfahbod 2023-01-25 12:47:16 -07:00
parent 2fec4f1c3d
commit 42ed6abb6a
1 changed files with 37 additions and 0 deletions

View File

@ -125,6 +125,7 @@ struct info_t :
{"list-variations",0, 0, G_OPTION_ARG_NONE, &this->list_variations, "List variations", nullptr}, {"list-variations",0, 0, G_OPTION_ARG_NONE, &this->list_variations, "List variations", nullptr},
#endif #endif
{"list-palettes", 0, 0, G_OPTION_ARG_NONE, &this->list_palettes, "List color palettes", nullptr}, {"list-palettes", 0, 0, G_OPTION_ARG_NONE, &this->list_palettes, "List color palettes", nullptr},
{"list-meta", 0, 0, G_OPTION_ARG_NONE, &this->list_meta, "List meta information", nullptr},
{nullptr} {nullptr}
}; };
@ -219,6 +220,7 @@ struct info_t :
hb_bool_t list_variations = false; hb_bool_t list_variations = false;
#endif #endif
hb_bool_t list_palettes = false; hb_bool_t list_palettes = false;
hb_bool_t list_meta = false;
public: public:
@ -286,6 +288,7 @@ struct info_t :
list_variations = list_variations =
#endif #endif
list_palettes = list_palettes =
list_meta =
true; true;
} }
@ -323,6 +326,7 @@ struct info_t :
if (list_variations) _list_variations (); if (list_variations) _list_variations ();
#endif #endif
if (list_palettes) _list_palettes (); if (list_palettes) _list_palettes ();
if (list_meta) _list_meta ();
return 0; return 0;
} }
@ -1359,6 +1363,39 @@ struct info_t :
} }
} }
} }
void
_list_meta ()
{
if (verbose)
{
separator ();
printf ("Meta information:\n");
}
{
if (verbose)
{
printf ("Tag Data\n------------\n");
}
unsigned count = hb_ot_meta_get_entry_tags (face, 0, nullptr, nullptr);
for (unsigned i = 0; i < count; i++)
{
hb_ot_meta_tag_t tag;
unsigned len = 1;
hb_ot_meta_get_entry_tags (face, i, &len, &tag);
hb_blob_t *blob = hb_ot_meta_reference_entry (face, tag);
printf ("%c%c%c%c %.*s\n", HB_UNTAG (tag),
(int) hb_blob_get_length (blob),
hb_blob_get_data (blob, nullptr));
hb_blob_destroy (blob);
}
}
}
}; };