diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 336edf887..da11203d8 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1717,14 +1717,12 @@ struct Coverage bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); - const hb_set_t &glyphset = *c->plan->glyphset_gsub (); - const hb_map_t &glyph_map = *c->plan->glyph_map; - auto it = + iter () - | hb_filter (glyphset) - | hb_map_retains_sorting (glyph_map) + | hb_filter (c->plan->glyph_map_gsub) + | hb_map_retains_sorting (c->plan->glyph_map_gsub) ; + // Cache the iterator result as it will be iterated multiple times // by the serialize code below. hb_sorted_vector_t glyphs (it); diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 97085d68a..a62ae8e02 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -420,6 +420,20 @@ _populate_gids_to_retain (hb_subset_plan_t* plan, #endif } +static void +_create_glyph_map_gsub (const hb_set_t* glyph_set_gsub, + const hb_map_t* glyph_map, + hb_map_t* out) +{ + + hb_iter (glyph_set_gsub) + | hb_map ([&] (hb_codepoint_t gid) { + return hb_pair_t (gid, + glyph_map->get (gid)); + }) + | hb_sink (out) + ; +} + static void _create_old_gid_to_new_gid_map (const hb_face_t *face, bool retain_gids, @@ -518,6 +532,7 @@ hb_subset_plan_create_or_fail (hb_face_t *face, plan->codepoint_to_glyph = hb_map_create (); plan->glyph_map = hb_map_create (); plan->reverse_glyph_map = hb_map_create (); + plan->glyph_map_gsub = hb_map_create (); plan->gsub_lookups = hb_map_create (); plan->gpos_lookups = hb_map_create (); @@ -552,6 +567,11 @@ hb_subset_plan_create_or_fail (hb_face_t *face, plan->reverse_glyph_map, &plan->_num_output_glyphs); + _create_glyph_map_gsub ( + plan->_glyphset_gsub, + plan->glyph_map, + plan->glyph_map_gsub); + // Now that we have old to new gid map update the unicode to new gid list. for (unsigned i = 0; i < plan->unicode_to_new_gid_list.length; i++) { @@ -594,6 +614,7 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan) hb_map_destroy (plan->codepoint_to_glyph); hb_map_destroy (plan->glyph_map); hb_map_destroy (plan->reverse_glyph_map); + hb_map_destroy (plan->glyph_map_gsub); hb_set_destroy (plan->_glyphset); hb_set_destroy (plan->_glyphset_gsub); hb_set_destroy (plan->_glyphset_mathed); diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 0f20d74db..cb567b769 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -70,6 +70,7 @@ struct hb_subset_plan_t // Old -> New glyph id mapping hb_map_t *glyph_map; hb_map_t *reverse_glyph_map; + hb_map_t *glyph_map_gsub; // Plan is only good for a specific source/dest so keep them with it hb_face_t *source;