[subset] Truncate empty gids at the end in retain-gids mode.
This commit is contained in:
parent
2376867649
commit
6555f20958
|
@ -183,9 +183,11 @@ _create_old_gid_to_new_gid_map (const hb_face_t *face,
|
|||
| hb_sink (reverse_glyph_map)
|
||||
;
|
||||
|
||||
// TODO(grieger): Should we discard glyphs past the max glyph to keep?
|
||||
// *num_glyphs = + hb_iter (all_gids_to_retain) | hb_reduce (hb_max, 0);
|
||||
*num_glyphs = face->get_num_glyphs ();
|
||||
unsigned max_glyph =
|
||||
+ hb_iter (all_gids_to_retain)
|
||||
| hb_reduce (hb_max, 0)
|
||||
;
|
||||
*num_glyphs = max_glyph + 1;
|
||||
}
|
||||
|
||||
+ reverse_glyph_map->iter ()
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -305,6 +305,30 @@ test_subset_glyf_retain_gids (void)
|
|||
hb_face_destroy (face_ac);
|
||||
}
|
||||
|
||||
static void
|
||||
test_subset_glyf_retain_gids_truncates (void)
|
||||
{
|
||||
hb_face_t *face_abc = hb_test_open_font_file ("fonts/Roboto-Regular.abc.ttf");
|
||||
hb_face_t *face_a = hb_test_open_font_file ("fonts/Roboto-Regular.a.retaingids.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 97);
|
||||
|
||||
hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
|
||||
hb_subset_input_set_retain_gids (input, true);
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, input);
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_a, face_abc_subset, HB_TAG ('g','l','y','f'));
|
||||
hb_subset_test_check (face_a, face_abc_subset, HB_TAG ('l','o','c', 'a'));
|
||||
check_maxp_num_glyphs(face_abc_subset, 2, true);
|
||||
|
||||
hb_face_destroy (face_abc_subset);
|
||||
hb_face_destroy (face_abc);
|
||||
hb_face_destroy (face_a);
|
||||
}
|
||||
|
||||
// TODO(grieger): test for long loca generation.
|
||||
|
||||
int
|
||||
|
@ -322,6 +346,7 @@ main (int argc, char **argv)
|
|||
hb_test_add (test_subset_glyf_with_gsub);
|
||||
hb_test_add (test_subset_glyf_without_gsub);
|
||||
hb_test_add (test_subset_glyf_retain_gids);
|
||||
hb_test_add (test_subset_glyf_retain_gids_truncates);
|
||||
|
||||
return hb_test_run();
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue