[subset] Add a DFS search to produce a closure of composite glyphs.

This commit is contained in:
Garret Rieger 2018-02-15 14:41:56 -08:00 committed by Behdad Esfahbod
parent d368414143
commit 73e1434814
1 changed files with 21 additions and 0 deletions

View File

@ -93,6 +93,27 @@ _populate_codepoints (hb_set_t *input_codepoints,
plan_codepoints.qsort (_hb_codepoint_t_cmp);
}
static void
_add_composite_gids (const OT::glyf::accelerator_t &glyf,
hb_codepoint_t gid,
hb_set_t *gids_to_retain)
{
if (hb_set_has (gids_to_retain, gid))
// Already visited this gid, ignore.
return;
hb_set_add (gids_to_retain, gid);
const OT::glyf::CompositeGlyphHeader *composite;
if (glyf.get_composite (gid, &composite))
{
do
{
_add_composite_gids (glyf, (hb_codepoint_t) composite->glyphIndex, gids_to_retain);
} while (glyf.next_composite (&composite);
}
}
static void
_populate_gids_to_retain (hb_face_t *face,
hb_prealloced_array_t<hb_codepoint_t>& codepoints,