diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 13fe11f18..0632a4abb 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -1755,6 +1755,21 @@ hb_buffer_append (hb_buffer_t *buffer, memcpy (buffer->info + orig_len, source->info + start, (end - start) * sizeof (buffer->info[0])); if (buffer->have_positions) memcpy (buffer->pos + orig_len, source->pos + start, (end - start) * sizeof (buffer->pos[0])); + + if (source->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE) + { + /* pre-context */ + while (start > 0 && buffer->context_len[0] < buffer->CONTEXT_LENGTH) + buffer->context[0][buffer->context_len[0]++] = source->info[--start].codepoint; + for (auto i = 0u; i < source->context_len[0] && buffer->context_len[0] < buffer->CONTEXT_LENGTH; i++) + buffer->context[0][buffer->context_len[0]++] = source->context[0][i]; + + /* post-context */ + while (end < source->len && buffer->context_len[1] < buffer->CONTEXT_LENGTH) + buffer->context[1][buffer->context_len[1]++] = source->info[end++].codepoint; + for (auto i = 0u; i < source->context_len[1] && buffer->context_len[1] < buffer->CONTEXT_LENGTH; i++) + buffer->context[1][buffer->context_len[1]++] = source->context[1][i]; + } } diff --git a/util/shape-options.hh b/util/shape-options.hh index 89dd8dfc9..a87c9d48c 100644 --- a/util/shape-options.hh +++ b/util/shape-options.hh @@ -235,7 +235,6 @@ struct shape_options_t hb_buffer_clear_contents (fragment); copy_buffer_properties (fragment, buffer); - /* TODO: Add pre/post context text. */ hb_buffer_flags_t flags = hb_buffer_get_flags (fragment); if (0 < text_start) flags = (hb_buffer_flags_t) (flags & ~HB_BUFFER_FLAG_BOT);