diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index b3af128e0..e2e9bcbeb 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1937,13 +1937,22 @@ struct ClassDefFormat2_4 { /* Match if there's any glyph that is not listed! */ hb_codepoint_t g = HB_SET_VALUE_INVALID; - for (auto &range : rangeRecord) + hb_codepoint_t last = HB_SET_VALUE_INVALID; + auto it = hb_iter (rangeRecord); + for (auto &range : it) { + if (it->first == last + 1) + { + it++; + continue; + } + if (!glyphs->next (&g)) break; if (g < range.first) return true; g = range.last; + last = g; } if (g != HB_SET_VALUE_INVALID && glyphs->next (&g)) return true; diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 9a00de3e6..33ca46d1f 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -605,11 +605,14 @@ _populate_unicodes_to_retain (const hb_set_t *unicodes, /* Add gids which where requested, but not mapped in cmap */ unsigned num_glyphs = plan->source->get_num_glyphs (); - for (hb_codepoint_t gid : *glyphs) + hb_codepoint_t first = HB_SET_VALUE_INVALID, last = HB_SET_VALUE_INVALID; + for (; glyphs->next_range (&first, &last); ) { - if (gid >= num_glyphs) + if (first >= num_glyphs) break; - plan->_glyphset_gsub.add (gid); + if (last >= num_glyphs) + last = num_glyphs - 1; + plan->_glyphset_gsub.add_range (first, last); } }