diff --git a/src/hb-ot-shape-complex-indic-private.hh b/src/hb-ot-shape-complex-indic-private.hh index 91e288ff6..0fe350f0f 100644 --- a/src/hb-ot-shape-complex-indic-private.hh +++ b/src/hb-ot-shape-complex-indic-private.hh @@ -75,6 +75,7 @@ enum indic_position_t { POS_BELOW_M, POS_POST_C, POS_POST_M, + POS_FINAL_C, POS_SMVD }; diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 8e738db5b..18a36990b 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -429,8 +429,21 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff for (unsigned int i = start; i < base; i++) info[i].indic_position() = POS_PRE_C; + info[base].indic_position() = POS_BASE_C; + /* Mark final consonants. A final consonant is one appearing after a matra, + * like in Khmer. */ + for (unsigned int i = base + 1; i < end; i++) + if (info[i].indic_category() == OT_M) { + for (unsigned int j = i + 1; j < end; j++) + if (is_consonant (info[j])) { + info[j].indic_position() = POS_FINAL_C; + break; + } + break; + } + /* Handle beginning Ra */ if (has_reph) info[start].indic_position() = POS_RA_TO_BECOME_REPH; diff --git a/test/shaping/texts/in-tree/shaper-indic/south-east-asian/script-khmer/misc/misc.txt b/test/shaping/texts/in-tree/shaper-indic/south-east-asian/script-khmer/misc/misc.txt index b305cb8cb..5a354b2a5 100644 --- a/test/shaping/texts/in-tree/shaper-indic/south-east-asian/script-khmer/misc/misc.txt +++ b/test/shaping/texts/in-tree/shaper-indic/south-east-asian/script-khmer/misc/misc.txt @@ -8,3 +8,5 @@ រ៍ សៅ រ្ឥ +ងឹ្ឈ +ង្ឈឹ