[buffer] Handle pre/post-context in buffer_append

Fixes https://github.com/harfbuzz/harfbuzz/issues/1843
This commit is contained in:
Khaled Hosny 2021-08-16 15:40:47 +02:00
parent 6ca0ffd42e
commit 430224b1a0
2 changed files with 15 additions and 1 deletions

View File

@ -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];
}
}

View File

@ -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);