mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 00:11:14 +01:00
[subset] Use CFF1 Encoding format 1 for more than 255 codes (#6460)
A format 1 Encoding can give codes to more than 255 glyphs, since codes may repeat across ranges. When the subset keeps more than 255 of those glyphs, as with retain-gids, plan_subset_encoding() hit assert (subset_enc_num_codes <= 0xFF). Choose format 0 only when it can hold the codes, and fail cleanly in the format 1 serializer instead of truncating nRanges past 255. Add a test font whose format 1 Encoding covers 768 glyphs, and the reporter's font to the fuzzing corpus. Fixes: https://github.com/harfbuzz/harfbuzz/issues/6031 Assisted-by: Claude Assisted-by: OpenAI Codex
This commit is contained in:
1 parent
c305720f01
commit
4868fd314f
6 files changed
+29
-2
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -339,6 +339,30 @@ test_subset_cff1_retaingids (void)
|
||||
hb_face_destroy (face_ac);
|
||||
}
|
||||
|
||||
static void
|
||||
test_subset_cff1_encoding_many_codes_retaingids (void)
|
||||
{
|
||||
/* A format 1 encoding gives codes to 768 glyphs; with retain-gids
|
||||
* the subset keeps more than 255 of them, too many for format 0. */
|
||||
hb_face_t *face = hb_test_open_font_file ("fonts/cff1_encoding_many_codes.otf");
|
||||
hb_face_t *face_expected = hb_test_open_font_file ("fonts/cff1_encoding_many_codes.300.retaingids.otf");
|
||||
|
||||
hb_set_t *glyphs = hb_set_create ();
|
||||
hb_subset_input_t *input;
|
||||
hb_face_t *face_subset;
|
||||
hb_set_add (glyphs, 300);
|
||||
input = hb_subset_test_create_input_from_glyphs (glyphs);
|
||||
hb_subset_input_set_flags (input, HB_SUBSET_FLAGS_RETAIN_GIDS);
|
||||
face_subset = hb_subset_test_create_subset (face, input);
|
||||
hb_set_destroy (glyphs);
|
||||
|
||||
hb_subset_test_check (face_expected, face_subset, HB_TAG ('C','F','F',' '));
|
||||
|
||||
hb_face_destroy (face_subset);
|
||||
hb_face_destroy (face);
|
||||
hb_face_destroy (face_expected);
|
||||
}
|
||||
|
||||
static void
|
||||
test_subset_cff1_j_retaingids (void)
|
||||
{
|
||||
@@ -489,6 +513,7 @@ main (int argc, char **argv)
|
||||
hb_test_add (test_subset_cff1_dotsection);
|
||||
hb_test_add (test_subset_cff1_retaingids);
|
||||
hb_test_add (test_subset_cff1_j_retaingids);
|
||||
hb_test_add (test_subset_cff1_encoding_many_codes_retaingids);
|
||||
hb_test_add (test_subset_cff1_identity_charset);
|
||||
hb_test_add (test_subset_cff1_j_identity_charset);
|
||||
|
||||
|
||||
Reference in new issue
Block a user