diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index dfb0d42f3..90161c52f 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -254,18 +254,26 @@ _populate_gids_to_retain (hb_subset_plan_t* plan, #endif _remove_invalid_gids (plan->_glyphset_gsub, plan->source->get_num_glyphs ()); + // Collect all glyphs referenced by COLRv0 + hb_set_t* cur_glyphset = plan->_glyphset_gsub; + hb_set_t glyphset_colrv0; + if (colr.is_valid ()) + { + glyphset_colrv0.union_ (cur_glyphset); + for (hb_codepoint_t gid : cur_glyphset->iter ()) + colr.closure_glyphs (gid, &glyphset_colrv0); + cur_glyphset = &glyphset_colrv0; + } + // Populate a full set of glyphs to retain by adding all referenced // composite glyphs. - hb_codepoint_t gid = HB_SET_VALUE_INVALID; - while (plan->_glyphset_gsub->next (&gid)) + for (hb_codepoint_t gid : cur_glyphset->iter ()) { glyf.add_gid_and_children (gid, plan->_glyphset); #ifndef HB_NO_SUBSET_CFF if (cff.is_valid ()) _add_cff_seac_components (cff, gid, plan->_glyphset); #endif - if (colr.is_valid ()) - colr.closure_glyphs (gid, plan->_glyphset); } _remove_invalid_gids (plan->_glyphset, plan->source->get_num_glyphs ()); diff --git a/test/subset/data/Makefile.am b/test/subset/data/Makefile.am index 03c32baf4..1f96b80a7 100644 --- a/test/subset/data/Makefile.am +++ b/test/subset/data/Makefile.am @@ -36,6 +36,7 @@ EXTRA_DIST += \ expected/cmap14 \ expected/sbix \ expected/colr \ + expected/colr_with_components \ expected/cbdt \ expected/variable \ fonts \ diff --git a/test/subset/data/Makefile.sources b/test/subset/data/Makefile.sources index dd71a1101..b37872c9b 100644 --- a/test/subset/data/Makefile.sources +++ b/test/subset/data/Makefile.sources @@ -6,6 +6,7 @@ TESTS = \ tests/cmap.tests \ tests/cmap14.tests \ tests/colr.tests \ + tests/colr_with_components.tests \ tests/full-font.tests \ tests/japanese.tests \ tests/layout.context.tests \ diff --git a/test/subset/data/expected/colr_with_components/colr-table.default.6B.ttf b/test/subset/data/expected/colr_with_components/colr-table.default.6B.ttf new file mode 100644 index 000000000..a73bffb22 Binary files /dev/null and b/test/subset/data/expected/colr_with_components/colr-table.default.6B.ttf differ diff --git a/test/subset/data/expected/colr_with_components/colr-table.drop-hints-retain-gids.6B.ttf b/test/subset/data/expected/colr_with_components/colr-table.drop-hints-retain-gids.6B.ttf new file mode 100644 index 000000000..4a4784c76 Binary files /dev/null and b/test/subset/data/expected/colr_with_components/colr-table.drop-hints-retain-gids.6B.ttf differ diff --git a/test/subset/data/expected/colr_with_components/colr-table.drop-hints.6B.ttf b/test/subset/data/expected/colr_with_components/colr-table.drop-hints.6B.ttf new file mode 100644 index 000000000..a73bffb22 Binary files /dev/null and b/test/subset/data/expected/colr_with_components/colr-table.drop-hints.6B.ttf differ diff --git a/test/subset/data/expected/colr_with_components/colr-table.retain-gids.6B.ttf b/test/subset/data/expected/colr_with_components/colr-table.retain-gids.6B.ttf new file mode 100644 index 000000000..4a4784c76 Binary files /dev/null and b/test/subset/data/expected/colr_with_components/colr-table.retain-gids.6B.ttf differ diff --git a/test/subset/data/fonts/colr-table.ttf b/test/subset/data/fonts/colr-table.ttf new file mode 100644 index 000000000..c4b2a55a5 Binary files /dev/null and b/test/subset/data/fonts/colr-table.ttf differ diff --git a/test/subset/data/tests/colr_with_components.tests b/test/subset/data/tests/colr_with_components.tests new file mode 100644 index 000000000..5d7c66e4b --- /dev/null +++ b/test/subset/data/tests/colr_with_components.tests @@ -0,0 +1,11 @@ +FONTS: +colr-table.ttf + +PROFILES: +default.txt +drop-hints.txt +drop-hints-retain-gids.txt +retain-gids.txt + +SUBSETS: +k diff --git a/test/subset/meson.build b/test/subset/meson.build index d41c267b2..80282f410 100644 --- a/test/subset/meson.build +++ b/test/subset/meson.build @@ -28,6 +28,7 @@ tests = [ 'cmap14', 'sbix', 'colr', + 'colr_with_components', 'cbdt', 'variable', ]