From b3790a65a18e8402b2b09dfc24aaea40a51de569 Mon Sep 17 00:00:00 2001 From: Rod Sheeter Date: Tue, 27 Feb 2018 17:23:30 -0800 Subject: [PATCH] [subset] add a (failing for now) test for composite glyf hint dropping --- src/hb-ot-glyf-table.hh | 8 ++++---- test/api/test-subset-glyf.c | 27 +++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index 441d4b9ec..533601826 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -402,14 +402,14 @@ struct glyf int16_t num_contours = (int16_t) glyph_header.numberOfContours; if (num_contours < 0) { - CompositeGlyphHeader::Iterator *composite_it; + CompositeGlyphHeader::Iterator composite_it; if (unlikely (!CompositeGlyphHeader::get_iterator ( (const char*) this->glyf_table + start_offset, - end_offset - start_offset, composite_it))) return false; + end_offset - start_offset, &composite_it))) return false; const CompositeGlyphHeader *last; do { - last = composite_it->current; - } while (composite_it->move_to_next()); + last = composite_it.current; + } while (composite_it.move_to_next()); if ( (uint16_t) last->flags & CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS) *instruction_start = start_offset + ((char *) last - (char *) glyf_table->dataX) + last->get_size(); diff --git a/test/api/test-subset-glyf.c b/test/api/test-subset-glyf.c index f5fdf32d0..54665162e 100644 --- a/test/api/test-subset-glyf.c +++ b/test/api/test-subset-glyf.c @@ -105,7 +105,7 @@ test_subset_glyf_noop (void) } static void -test_subset_glyf_strip_hints (void) +test_subset_glyf_strip_hints_simple (void) { hb_face_t *face_abc = hb_subset_test_open_font ("fonts/Roboto-Regular.abc.ttf"); hb_face_t *face_ac = hb_subset_test_open_font ("fonts/Roboto-Regular.ac.nohints.ttf"); @@ -128,6 +128,28 @@ test_subset_glyf_strip_hints (void) } // TODO(rsheeter): test strip hints from composite +static void +test_subset_glyf_strip_hints_composite (void) +{ + hb_face_t *face_components = hb_subset_test_open_font ("fonts/Roboto-Regular.components.ttf"); + hb_face_t *face_subset = hb_subset_test_open_font ("fonts/Roboto-Regular.components.subset.ttf"); + + hb_set_t *codepoints = hb_set_create(); + hb_set_add (codepoints, 0x1fc); + hb_subset_input_t *input = hb_subset_test_create_input (codepoints); + *hb_subset_input_drop_hints(input) = true; + + hb_face_t *face_generated_subset = hb_subset_test_create_subset (face_components, input); + hb_set_destroy (codepoints); + + hb_subset_test_check (face_subset, face_generated_subset, HB_TAG ('g','l','y','f')); + hb_subset_test_check (face_subset, face_generated_subset, HB_TAG ('l','o','c', 'a')); + check_maxp_num_glyphs(face_generated_subset, 4); + + hb_face_destroy (face_generated_subset); + hb_face_destroy (face_subset); + hb_face_destroy (face_components); +} // TODO(grieger): test for long loca generation. @@ -138,7 +160,8 @@ main (int argc, char **argv) hb_test_add (test_subset_glyf_noop); hb_test_add (test_subset_glyf); - hb_test_add (test_subset_glyf_strip_hints); + hb_test_add (test_subset_glyf_strip_hints_simple); + hb_test_add (test_subset_glyf_strip_hints_composite); hb_test_add (test_subset_glyf_with_components); return hb_test_run();