From bdc2fc8294da7f374701aafe9f5a82d60633946f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 25 Sep 2012 21:32:35 -0400 Subject: [PATCH] [Arabic] Respect Arabic joining from neighboring context Now we respect Arabic joining across runs. --- src/hb-ot-shape-complex-arabic.cc | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 56949ddfa..572089186 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -229,10 +229,23 @@ static void arabic_joining (hb_buffer_t *buffer) { unsigned int count = buffer->len; - unsigned int prev = 0, state = 0; + unsigned int prev = (unsigned int) -1, state = 0; HB_BUFFER_ALLOCATE_VAR (buffer, arabic_shaping_action); + /* Check pre-context */ + for (unsigned int i = 0; i < buffer->context_len[0]; i++) + { + unsigned int this_type = get_joining_type (buffer->context[0][i], buffer->unicode->general_category (buffer->context[0][i])); + + if (unlikely (this_type == JOINING_TYPE_T)) + continue; + + const arabic_state_table_entry *entry = &arabic_state_table[state][this_type]; + state = entry->next_state; + break; + } + for (unsigned int i = 0; i < count; i++) { unsigned int this_type = get_joining_type (buffer->info[i].codepoint, _hb_glyph_info_get_general_category (&buffer->info[i])); @@ -244,7 +257,7 @@ arabic_joining (hb_buffer_t *buffer) const arabic_state_table_entry *entry = &arabic_state_table[state][this_type]; - if (entry->prev_action != NONE) + if (entry->prev_action != NONE && prev != (unsigned int) -1) buffer->info[prev].arabic_shaping_action() = entry->prev_action; buffer->info[i].arabic_shaping_action() = entry->curr_action; @@ -253,6 +266,20 @@ arabic_joining (hb_buffer_t *buffer) state = entry->next_state; } + for (unsigned int i = 0; i < buffer->context_len[1]; i++) + { + unsigned int this_type = get_joining_type (buffer->context[1][i], buffer->unicode->general_category (buffer->context[0][i])); + + if (unlikely (this_type == JOINING_TYPE_T)) + continue; + + const arabic_state_table_entry *entry = &arabic_state_table[state][this_type]; + if (entry->prev_action != NONE && prev != (unsigned int) -1) + buffer->info[prev].arabic_shaping_action() = entry->prev_action; + break; + } + + HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action); }