diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index a595a4b89..28ba3b9d9 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1037,7 +1037,9 @@ struct ReverseChainSingleSubstFormat1 1)) { c->replace_glyph_inplace (substitute[index]); - c->buffer->idx--; /* Reverse! */ + /* Note: We DON'T decrease buffer->idx. The main loop does it + * for us. This is useful for preventing surprises if someone + * calls us through a Context lookup. */ return TRACE_RETURN (true); } diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 5f3eb573c..06c98d22d 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -867,8 +867,8 @@ apply_string (OT::hb_apply_context_t *c, (c->buffer->cur().mask & c->lookup_mask) && apply_once (c, lookup)) ret = true; - else - c->buffer->idx--; + /* The reverse lookup doesn't "advance" cursor (for good reason). */ + c->buffer->idx--; } while ((int) c->buffer->idx >= 0);