added CFF1 Expert Encoding subset test & bug fixes

This commit is contained in:
Michiharu Ariza 2018-10-13 17:25:09 -07:00
parent b64ef69b9e
commit 9228db06f4
5 changed files with 36 additions and 3 deletions

View File

@ -1121,7 +1121,13 @@ struct cff1
const OT::cff1 *cff = this->blob->as<OT::cff1> (); const OT::cff1 *cff = this->blob->as<OT::cff1> ();
encoding = &Null(Encoding); encoding = &Null(Encoding);
if (is_predef_charset ())
charset = &Null(Charset);
else
{
charset = &StructAtOffsetOrNull<Charset> (cff, topDict.CharsetOffset); charset = &StructAtOffsetOrNull<Charset> (cff, topDict.CharsetOffset);
if (unlikely ((charset == &Null (Charset)) || !charset->sanitize (&sc))) { fini (); return; }
}
if (is_CID ()) if (is_CID ())
{ {
if (unlikely (charset == &Null(Charset))) { fini (); return; } if (unlikely (charset == &Null(Charset))) { fini (); return; }

View File

@ -615,11 +615,17 @@ struct cff_subset_plan {
final_size += offsets.globalSubrsInfo.size; final_size += offsets.globalSubrsInfo.size;
/* Encoding */ /* Encoding */
if (!subset_encoding && acc.is_predef_charset ())
offsets.encodingOffset = acc.topDict.EncodingOffset;
else
offsets.encodingOffset = final_size; offsets.encodingOffset = final_size;
if (subset_encoding) if (subset_encoding)
final_size += plan_subset_encoding (acc, plan); final_size += plan_subset_encoding (acc, plan);
/* Charset */ /* Charset */
if (!subset_charset && acc.is_predef_charset ())
offsets.charsetInfo.offset = acc.topDict.CharsetOffset;
else
offsets.charsetInfo.offset = final_size; offsets.charsetInfo.offset = final_size;
final_size += offsets.charsetInfo.size; final_size += offsets.charsetInfo.size;

Binary file not shown.

Binary file not shown.

View File

@ -111,6 +111,26 @@ test_subset_cff1_j (void)
hb_face_destroy (face_41_4c2e); hb_face_destroy (face_41_4c2e);
} }
static void
test_subset_cff1_expert (void)
{
hb_face_t *face = hb_subset_test_open_font ("fonts/cff1_expert.otf");
hb_face_t *face_subset = hb_subset_test_open_font ("fonts/cff1_expert.2D,F6E9,FB00.otf");
hb_set_t *codepoints = hb_set_create ();
hb_set_add (codepoints, 0x2D);
hb_set_add (codepoints, 0xF6E9);
hb_set_add (codepoints, 0xFB00);
hb_face_t *face_test = hb_subset_test_create_subset (face, hb_subset_test_create_input (codepoints));
hb_set_destroy (codepoints);
hb_subset_test_check (face_subset, face_test, HB_TAG ('C','F','F',' '));
hb_face_destroy (face_test);
hb_face_destroy (face_subset);
hb_face_destroy (face);
}
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
@ -120,6 +140,7 @@ main (int argc, char **argv)
hb_test_add (test_subset_cff1); hb_test_add (test_subset_cff1);
hb_test_add (test_subset_cff1_strip_hints); hb_test_add (test_subset_cff1_strip_hints);
hb_test_add (test_subset_cff1_j); hb_test_add (test_subset_cff1_j);
hb_test_add (test_subset_cff1_expert);
return hb_test_run (); return hb_test_run ();
} }