From e1a5448306a555a66cb337a419e275bb5d98d461 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 15 Jan 2023 10:00:26 -0700 Subject: [PATCH] [hb-shape/view] Print named-instances in --list-variations Might remove the coordinates. --- util/font-options.hh | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/util/font-options.hh b/util/font-options.hh index 1aa645d98..73268b6fd 100644 --- a/util/font-options.hh +++ b/util/font-options.hh @@ -181,7 +181,8 @@ _list_variations (hb_face_t *face) auto language = hb_language_get_default (); - printf ("tag: min default max name\n"); + printf ("Non-hidden varitation axes:\n"); + printf ("tag: min default max name\n\n"); for (const auto &axis : axes) { if (axis.flags & HB_OT_VAR_AXIS_FLAG_HIDDEN) @@ -202,6 +203,33 @@ _list_variations (hb_face_t *face) name); } + count = hb_ot_var_get_named_instance_count (face); + if (count) + { + printf ("\n\nNamed instances: \n\n"); + + for (unsigned i = 0; i < count; i++) + { + char name[64]; + unsigned name_len = sizeof name; + + hb_ot_name_id_t name_id = hb_ot_var_named_instance_get_subfamily_name_id (face, i); + hb_ot_name_get_utf8 (face, name_id, + language, + &name_len, name); + + unsigned coords_count = hb_ot_var_named_instance_get_design_coords (face, i, nullptr, nullptr); + hb_vector_t coords; + coords.resize (coords_count); + hb_ot_var_named_instance_get_design_coords (face, i, &coords_count, coords.arrayZ); + + printf ("%s ", name); + for (unsigned j = 0; j < coords.length; j++) + printf ("%g, ", (double) coords[j]); + printf ("\n"); + } + } + exit(0); }