[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.
This commit is contained in:
Garret Rieger 2021-05-04 16:48:41 -07:00 committed by Behdad Esfahbod
parent b54d9b695a
commit a08900b721
10 changed files with 26 additions and 4 deletions

View File

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

View File

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

View File

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

Binary file not shown.

View File

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

View File

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