diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index a7607f626..108144388 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -952,6 +952,32 @@ hb_ot_layout_lookup_substitute_closure (hb_face_t *face, l.closure (&c, lookup_index); } +/** + * hb_ot_layout_lookups_substitute_closure: + * + * Compute the transitive closure of glyphs needed for all of the + * provided lookups. + * + * Since: 1.8.1 + **/ +void +hb_ot_layout_lookups_substitute_closure (hb_face_t *face, + const hb_set_t *lookups, + hb_set_t *glyphs) +{ + hb_auto_t done_lookups; + OT::hb_closure_context_t c (face, glyphs, &done_lookups); + const OT::GSUB& gsub = _get_gsub (face); + + unsigned int glyphs_length; + do + { + glyphs_length = glyphs->get_population (); + for (hb_codepoint_t lookup_index = HB_SET_VALUE_INVALID; hb_set_next (lookups, &lookup_index);) + gsub.get_lookup (lookup_index).closure (&c, lookup_index); + } while (glyphs_length != glyphs->get_population ()); +} + /* * OT::GPOS */ diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index d82dc0226..027879622 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h @@ -277,6 +277,12 @@ hb_ot_layout_lookup_substitute_closure (hb_face_t *face, hb_set_t *glyphs /*TODO , hb_bool_t inclusive */); +HB_EXTERN void +hb_ot_layout_lookups_substitute_closure (hb_face_t *face, + const hb_set_t *lookups, + hb_set_t *glyphs); + + #ifdef HB_NOT_IMPLEMENTED /* Note: You better have GDEF when using this API, or marks won't do much. */ HB_EXTERN hb_bool_t diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index c20b110e2..36e0bf9c3 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -957,15 +957,7 @@ hb_ot_shape_glyphs_closure (hb_font_t *font, hb_set_t *lookups = hb_set_create (); hb_ot_shape_plan_collect_lookups (shape_plan, HB_OT_TAG_GSUB, lookups); - - /* And find transitive closure. */ - hb_set_t *copy = hb_set_create (); - do { - copy->set (glyphs); - for (hb_codepoint_t lookup_index = HB_SET_VALUE_INVALID; hb_set_next (lookups, &lookup_index);) - hb_ot_layout_lookup_substitute_closure (font->face, lookup_index, glyphs); - } while (!copy->is_equal (glyphs)); - hb_set_destroy (copy); + hb_ot_layout_lookups_substitute_closure (font->face, lookups, glyphs); hb_set_destroy (lookups);