normalized, coords_length);
_hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
}
+
/**
* hb_font_set_var_coords_design:
*
hb_ot_var_normalize_coords (font->face, coords_length, coords, normalized);
_hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
}
+
+/**
+ * hb_font_set_var_named_instance:
+ * @font: a font.
+ * @instance_index: named instance index.
+ *
+ * Sets design coords of a font from a named instance index.
+ *
+ * Since: REPLACEME
+ */
+void
+hb_font_set_var_named_instance (hb_font_t *font,
+ unsigned instance_index)
+{
+ if (hb_object_is_immutable (font))
+ return;
+
+ unsigned int coords_length = hb_ot_var_named_instance_get_design_coords (font->face, instance_index, nullptr, nullptr);
+
+ float *coords = coords_length ? (float *) calloc (coords_length, sizeof (float)) : nullptr;
+ if (unlikely (coords_length && !coords))
+ return;
+
+ hb_ot_var_named_instance_get_design_coords (font->face, instance_index, &coords_length, coords);
+ hb_font_set_var_coords_design (font, coords, coords_length);
+ free (coords);
+}
#endif
/**
hb_font_destroy (font);
}
+static void
+test_extents_cff2_vsindex_named_instance (void)
+{
+ hb_face_t *face = hb_test_open_font_file ("fonts/AdobeVFPrototype_vsindex.otf");
+ g_assert (face);
+ hb_font_t *font = hb_font_create (face);
+ hb_face_destroy (face);
+ g_assert (font);
+ hb_ot_font_set_funcs (font);
+
+ hb_font_set_var_named_instance (font, 6); // 6 (BlackMediumContrast): 900, 50
+ hb_glyph_extents_t extents;
+ hb_bool_t result = hb_font_get_glyph_extents (font, 1, &extents);
+ g_assert (result);
+
+ g_assert_cmpint (extents.x_bearing, ==, 12);
+ g_assert_cmpint (extents.y_bearing, ==, 652);
+ g_assert_cmpint (extents.width, ==, 653);
+ g_assert_cmpint (extents.height, ==, -652);
+
+ result = hb_font_get_glyph_extents (font, 2, &extents);
+ g_assert (result);
+
+ g_assert_cmpint (extents.x_bearing, ==, 6);
+ g_assert_cmpint (extents.y_bearing, ==, 675);
+ g_assert_cmpint (extents.width, ==, 647);
+ g_assert_cmpint (extents.height, ==, -675);
+
+ hb_font_destroy (font);
+}
+
int
main (int argc, char **argv)
{
hb_test_add (test_extents_cff1_seac);
hb_test_add (test_extents_cff2);
hb_test_add (test_extents_cff2_vsindex);
+ hb_test_add (test_extents_cff2_vsindex_named_instance);
return hb_test_run ();
}