[subset] fix failing colrv0 subsetting when font has composite glyphs.

Composite glyph collection was happening along side colrv0 glyph collection which meant it was possible to miss grabbing the component glyphs for a glyph added by colrv0.
pull/2955/head
Garret Rieger 4 years ago committed by Behdad Esfahbod
parent b54d9b695a
commit a08900b721
  1. 16
      src/hb-subset-plan.cc
  2. 1
      test/subset/data/Makefile.am
  3. 1
      test/subset/data/Makefile.sources
  4. BIN
      test/subset/data/expected/colr_with_components/colr-table.default.6B.ttf
  5. BIN
      test/subset/data/expected/colr_with_components/colr-table.drop-hints-retain-gids.6B.ttf
  6. BIN
      test/subset/data/expected/colr_with_components/colr-table.drop-hints.6B.ttf
  7. BIN
      test/subset/data/expected/colr_with_components/colr-table.retain-gids.6B.ttf
  8. BIN
      test/subset/data/fonts/colr-table.ttf
  9. 11
      test/subset/data/tests/colr_with_components.tests
  10. 1
      test/subset/meson.build

@ -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 ());

@ -36,6 +36,7 @@ EXTRA_DIST += \
expected/cmap14 \
expected/sbix \
expected/colr \
expected/colr_with_components \
expected/cbdt \
expected/variable \
fonts \

@ -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 \

@ -0,0 +1,11 @@
FONTS:
colr-table.ttf
PROFILES:
default.txt
drop-hints.txt
drop-hints-retain-gids.txt
retain-gids.txt
SUBSETS:
k

@ -28,6 +28,7 @@ tests = [
'cmap14',
'sbix',
'colr',
'colr_with_components',
'cbdt',
'variable',
]

Loading…
Cancel
Save