Make hb_subset_input_glyph_set () actually do something.

This commit is contained in:
Garret Rieger 2019-02-28 17:25:05 -08:00 committed by Michiharu Ariza
parent a842fdfbf0
commit d0b6d539f6
3 changed files with 37 additions and 1 deletions

View File

@ -96,6 +96,7 @@ _remove_invalid_gids (hb_set_t *glyphs,
static hb_set_t *
_populate_gids_to_retain (hb_face_t *face,
const hb_set_t *unicodes,
const hb_set_t *input_glyphs_to_retain,
bool close_over_gsub,
hb_set_t *unicodes_to_retain,
hb_map_t *codepoint_to_glyph,
@ -110,6 +111,7 @@ _populate_gids_to_retain (hb_face_t *face,
hb_set_t *initial_gids_to_retain = hb_set_create ();
initial_gids_to_retain->add (0); // Not-def
hb_set_union (initial_gids_to_retain, input_glyphs_to_retain);
hb_codepoint_t cp = HB_SET_VALUE_INVALID;
while (unicodes->next (&cp))
@ -213,6 +215,7 @@ hb_subset_plan_create (hb_face_t *face,
plan->reverse_glyph_map = hb_map_create();
plan->_glyphset = _populate_gids_to_retain (face,
input->unicodes,
input->glyphs,
!plan->drop_layout,
plan->unicodes,
plan->codepoint_to_glyph,

View File

@ -56,6 +56,15 @@ hb_subset_test_create_input(const hb_set_t *codepoints)
return input;
}
static inline hb_subset_input_t *
hb_subset_test_create_input_from_glyphs (const hb_set_t *glyphs)
{
hb_subset_input_t *input = hb_subset_input_create_or_fail ();
hb_set_t * input_glyphs = hb_subset_input_glyph_set (input);
hb_set_union (input_glyphs, glyphs);
return input;
}
static inline hb_face_t *
hb_subset_test_create_subset (hb_face_t *source,
hb_subset_input_t *input)

View File

@ -79,6 +79,29 @@ test_subset_glyf (void)
hb_face_destroy (face_ac);
}
static void
test_subset_glyf_with_input_glyphs (void)
{
hb_face_t *face_abc = hb_test_open_font_file ("fonts/Roboto-Regular.abc.ttf");
hb_face_t *face_ac = hb_test_open_font_file ("fonts/Roboto-Regular.ac.ttf");
hb_set_t *glyphs = hb_set_create();
hb_face_t *face_abc_subset;
hb_set_add (glyphs, 1);
hb_set_add (glyphs, 3);
face_abc_subset =
hb_subset_test_create_subset (face_abc, hb_subset_test_create_input_from_glyphs (glyphs));
hb_set_destroy (glyphs);
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('g','l','y','f'));
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('l','o','c', 'a'));
check_maxp_num_glyphs(face_abc_subset, 3, true);
hb_face_destroy (face_abc_subset);
hb_face_destroy (face_abc);
hb_face_destroy (face_ac);
}
static void
test_subset_glyf_with_components (void)
{
@ -291,6 +314,7 @@ main (int argc, char **argv)
hb_test_add (test_subset_glyf_noop);
hb_test_add (test_subset_glyf);
hb_test_add (test_subset_glyf_with_input_glyphs);
hb_test_add (test_subset_glyf_strip_hints_simple);
hb_test_add (test_subset_glyf_strip_hints_composite);
hb_test_add (test_subset_glyf_strip_hints_invalid);