mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-28 09:09:13 +01:00
[subset] Preserve LookupVariationRecord tables
Subset FeatureVariations 1.1 lookup records while remapping feature and lookup indices. Preserve all condition formats and remap variation indices used by value conditions. Keep features with lookup variations distinct during feature deduplication, since equal default lookup lists do not imply equal variable behavior. Tested with the full Meson test suite and a targeted HB_NO_VAR build. Assisted-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
1 parent
48d97c4ad1
commit
3d6677f05c
3 files changed
+185
-9
No files matched your search
@@ -92,6 +92,46 @@ test_subset_crash (void)
|
||||
hb_face_destroy (face);
|
||||
}
|
||||
|
||||
#ifndef HB_NO_VAR
|
||||
static void
|
||||
test_subset_lookup_variations (void)
|
||||
{
|
||||
hb_face_t *face = hb_test_open_font_file (
|
||||
"../shape/data/in-house/fonts/48b61f685ab1b3a3690fe4fea46ffc73dac3c301.ttf");
|
||||
hb_subset_input_t *input = hb_subset_input_create_or_fail ();
|
||||
|
||||
hb_set_add_range (hb_subset_input_unicode_set (input), 'A', 'F');
|
||||
hb_set_t *features = hb_subset_input_set (input, HB_SUBSET_SETS_LAYOUT_FEATURE_TAG);
|
||||
hb_set_clear (features);
|
||||
hb_set_add (features, HB_TAG ('l', 'i', 'g', 'a'));
|
||||
|
||||
hb_face_t *subset = hb_subset_or_fail (face, input);
|
||||
g_assert_nonnull (subset);
|
||||
|
||||
hb_font_t *font = hb_font_create (subset);
|
||||
int coords[] = {13107}; /* 0.8 */
|
||||
hb_font_set_var_coords_normalized (font, coords, 1);
|
||||
|
||||
hb_buffer_t *buffer = hb_buffer_create ();
|
||||
hb_buffer_add_utf8 (buffer, "ABCDEF", -1, 0, -1);
|
||||
hb_buffer_guess_segment_properties (buffer);
|
||||
hb_shape (font, buffer, NULL, 0);
|
||||
|
||||
unsigned length;
|
||||
const hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, &length);
|
||||
const hb_codepoint_t expected[] = {2, 4, 6, 8, 9, 10};
|
||||
g_assert_cmpuint (length, ==, G_N_ELEMENTS (expected));
|
||||
for (unsigned i = 0; i < length; i++)
|
||||
g_assert_cmpuint (info[i].codepoint, ==, expected[i]);
|
||||
|
||||
hb_buffer_destroy (buffer);
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (subset);
|
||||
hb_subset_input_destroy (input);
|
||||
hb_face_destroy (face);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_subset_set_flags (void)
|
||||
{
|
||||
@@ -640,6 +680,9 @@ main (int argc, char **argv)
|
||||
hb_test_add (test_subset_32_tables);
|
||||
hb_test_add (test_subset_no_inf_loop);
|
||||
hb_test_add (test_subset_crash);
|
||||
#ifndef HB_NO_VAR
|
||||
hb_test_add (test_subset_lookup_variations);
|
||||
#endif
|
||||
hb_test_add (test_subset_set_flags);
|
||||
hb_test_add (test_subset_sets);
|
||||
hb_test_add (test_subset_plan);
|
||||
|
||||
Reference in new issue
Block a user