diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index e7b70c8ed0ba2168a65e05071b1f57a87ce7010d..83d7ab58e34d140405d18c29d8f09426816bce5e 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -501,6 +501,7 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff switch ((hb_tag_t) buffer->props.script) { + case HB_SCRIPT_SINHALA: case HB_SCRIPT_KHMER: base_pos = BASE_FIRST; break; @@ -557,6 +558,19 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff if (!has_reph) base = limit; + + /* Find the last base consonant that is not blocked by ZWJ. If there is + * a ZWJ before a bse consonant, that would request a subjoined form. */ + for (unsigned int i = limit; i < end; i++) + if (is_consonant (info[i]) && info[i].indic_position() == POS_BASE_C) + base = i; + else if (info[i].indic_category() == OT_ZWJ) + break; + + /* Mark all subsequent consonants as below. */ + for (unsigned int i = base + 1; i < end; i++) + if (is_consonant (info[i]) && info[i].indic_position() == POS_BASE_C) + info[i].indic_position() = POS_BELOW_C; } if (base < start) @@ -570,6 +584,8 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff has_reph = false; } } + if (base < end) + info[base].indic_position() = POS_BASE_C; /* 2. Decompose and reorder Matras: @@ -931,6 +947,7 @@ final_reordering_syllable (hb_buffer_t *buffer, { case HB_SCRIPT_MALAYALAM: case HB_SCRIPT_ORIYA: + case HB_SCRIPT_SINHALA: reph_pos = REPH_AFTER_MAIN; break; @@ -945,7 +962,6 @@ final_reordering_syllable (hb_buffer_t *buffer, default: case HB_SCRIPT_DEVANAGARI: case HB_SCRIPT_GUJARATI: - case HB_SCRIPT_SINHALA: reph_pos = REPH_BEFORE_POSTSCRIPT; break; diff --git a/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/misc.txt b/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/misc.txt index 03a0fae87d9fa1bfca7fb189dd8bf1e506a0dbde..c4f6b6b7dbc9c1fa23467df64a5a2d0ef57b8ba1 100644 --- a/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/misc.txt +++ b/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/misc.txt @@ -30,3 +30,4 @@ ශී‍්‍ර ස්ට්‍රේ ග්‍යෙ +ර්‍ය්‍ය