diff --git a/src/hb-font.cc b/src/hb-font.cc index 29f69c8c1..b5c82a948 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -2536,15 +2536,16 @@ hb_font_set_variations (hb_font_t *font, } /* Initialize design coords. */ - if (font->instance_index == HB_FONT_NO_VAR_NAMED_INSTANCE) - for (unsigned int i = 0; i < coords_length; i++) - design_coords[i] = axes[i].get_default (); - else + for (unsigned int i = 0; i < coords_length; i++) + design_coords[i] = axes[i].get_default (); + if (font->instance_index != HB_FONT_NO_VAR_NAMED_INSTANCE) { unsigned count = coords_length; + /* This may fail if index is out-of-range; + * That's why we initialize design_coords from fvar above + * unconditionally. */ hb_ot_var_named_instance_get_design_coords (font->face, font->instance_index, &count, design_coords); - assert (count == coords_length); } for (unsigned int i = 0; i < variations_length; i++) diff --git a/util/font-options.hh b/util/font-options.hh index 9b0c2ab5d..64a462abe 100644 --- a/util/font-options.hh +++ b/util/font-options.hh @@ -71,6 +71,7 @@ struct font_options_t : face_options_t char *font_funcs = nullptr; int ft_load_flags = 2; unsigned int palette = 0; + unsigned int named_instance = 0; hb_font_t *font = nullptr; }; @@ -113,6 +114,7 @@ font_options_t::post_parse (GError **error) hb_font_set_scale (font, scale_x, scale_y); #ifndef HB_NO_VAR + hb_font_set_var_named_instance (font, named_instance); hb_font_set_variations (font, variations, num_variations); #endif @@ -395,6 +397,7 @@ font_options_t::add_options (option_parser_t *parser) GOptionEntry entries2[] = { {"list-variations", 0, 0, G_OPTION_ARG_NONE, &this->list_variations, "List available font variations and quit", nullptr}, + {"named-instance", 0, 0, G_OPTION_ARG_INT, &this->named_instance, "Set named-instance index (default: none)", "index"}, {"variations", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_variations, variations_help, "list"}, {nullptr} };