From 73e1434814eb37005b4159babf972a2743b25700 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 15 Feb 2018 14:41:56 -0800 Subject: [PATCH] [subset] Add a DFS search to produce a closure of composite glyphs. --- src/hb-subset-plan.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 034180a0c..ea46e5f79 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -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& codepoints,