[aat] In ContextualSubstitute, apply end-of-text action to last glyph

This commit is contained in:
Behdad Esfahbod 2018-02-04 14:40:17 -05:00
parent c0b1c7eb2e
commit 8be596f0b7
1 changed files with 5 additions and 4 deletions

View File

@ -219,15 +219,16 @@ struct ContextualSubtable
ret = true; ret = true;
} }
} }
if (entry->data.currentIndex != 0xFFFF && buffer->idx < buffer->len) if (entry->data.currentIndex != 0xFFFF)
{ {
unsigned int idx = MIN (buffer->idx, buffer->len - 1);
const Lookup<GlyphID> &lookup = subs[entry->data.currentIndex]; const Lookup<GlyphID> &lookup = subs[entry->data.currentIndex];
hb_glyph_info_t *info = buffer->info; hb_glyph_info_t *info = buffer->info;
const GlyphID *replacement = lookup.get_value (info[buffer->idx].codepoint, driver->num_glyphs); const GlyphID *replacement = lookup.get_value (info[idx].codepoint, driver->num_glyphs);
if (replacement) if (replacement)
{ {
buffer->unsafe_to_break (driver->last_zero, MIN (buffer->idx + 1, buffer->len)); buffer->unsafe_to_break (driver->last_zero, idx + 1);
info[buffer->idx].codepoint = *replacement; info[idx].codepoint = *replacement;
ret = true; ret = true;
} }
} }