From 3c7b3641cfb00f2c4dcc0768b9854e4f4410d15f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 15 Oct 2013 11:21:01 +0200 Subject: [PATCH] [indic] Handle Avagraha It can come either at the end(ish!) of the syllable, or independently. When independent, it accepts a few bits and pieces. --- src/hb-ot-shape-complex-indic-machine.rl | 5 ++++- src/hb-ot-shape-complex-indic-private.hh | 5 +++-- src/hb-ot-shape-complex-indic.cc | 14 +++++++++++++- .../indic/script-devanagari/misc/misc.txt | 1 + .../shaper-indic/indic/script-telugu/misc/misc.txt | 1 + 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-shape-complex-indic-machine.rl b/src/hb-ot-shape-complex-indic-machine.rl index f9f07d801..fa068c43c 100644 --- a/src/hb-ot-shape-complex-indic-machine.rl +++ b/src/hb-ot-shape-complex-indic-machine.rl @@ -56,6 +56,7 @@ Coeng = 14; Repha = 15; Ra = 16; CM = 17; +Avag = 18; c = (C | Ra)CM*; # is_consonant n = ((ZWNJ?.RS)? (N.N?)?); # is_consonant_modifier @@ -66,7 +67,7 @@ reph = (Ra H | Repha); # possible reph cn = c.ZWJ?.n?; forced_rakar = ZWJ H ZWJ Ra; matra_group = z{0,3}.M.N?.(H | forced_rakar)?; -syllable_tail = (Coeng (cn|V))? (SM.ZWNJ?)? (VD VD?)?; +syllable_tail = (Coeng (cn|V))? (Avag.N?)? (SM.ZWNJ?)? (VD VD?)?; place_holder = NBSP | DOTTEDCIRCLE; halant_group = (z?.h.(ZWJ.N?)?); final_halant_group = halant_group | h.ZWNJ; @@ -76,6 +77,7 @@ halant_or_matra_group = (final_halant_group | (h.ZWJ)? matra_group{0,4}); consonant_syllable = Repha? (cn.halant_group){0,4} cn A? halant_or_matra_group? syllable_tail; vowel_syllable = reph? V.n? (ZWJ | (halant_group.cn){0,4} halant_or_matra_group? syllable_tail); standalone_cluster = reph? place_holder.n? (halant_group.cn){0,4} halant_or_matra_group? syllable_tail; +avagraha_cluster = Avag.N? (SM.ZWNJ?)? (VD VD?)?; broken_cluster = reph? n? (halant_group.cn){0,4} halant_or_matra_group syllable_tail; other = any; @@ -83,6 +85,7 @@ main := |* consonant_syllable => { found_syllable (consonant_syllable); }; vowel_syllable => { found_syllable (vowel_syllable); }; standalone_cluster => { found_syllable (standalone_cluster); }; + avagraha_cluster => { found_syllable (avagraha_cluster); }; broken_cluster => { found_syllable (broken_cluster); }; other => { found_syllable (non_indic_cluster); }; *|; diff --git a/src/hb-ot-shape-complex-indic-private.hh b/src/hb-ot-shape-complex-indic-private.hh index 39268b145..552a121a1 100644 --- a/src/hb-ot-shape-complex-indic-private.hh +++ b/src/hb-ot-shape-complex-indic-private.hh @@ -59,7 +59,8 @@ enum indic_category_t { OT_Coeng, OT_Repha, OT_Ra, /* Not explicitly listed in the OT spec, but used in the grammar. */ - OT_CM + OT_CM, + OT_Avag }; /* Visual positions in a syllable from left to right. */ @@ -93,7 +94,7 @@ enum indic_position_t { enum indic_syllabic_category_t { INDIC_SYLLABIC_CATEGORY_OTHER = OT_X, - INDIC_SYLLABIC_CATEGORY_AVAGRAHA = OT_X, + INDIC_SYLLABIC_CATEGORY_AVAGRAHA = OT_Avag, INDIC_SYLLABIC_CATEGORY_BINDU = OT_SM, INDIC_SYLLABIC_CATEGORY_CONSONANT = OT_C, INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD = OT_C, diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index a6242674f..00e3c45e3 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -249,7 +249,7 @@ set_indic_properties (hb_glyph_info_t &info) { pos = matra_position (u, pos); } - else if (cat == OT_SM || cat == OT_VD) + else if (cat == OT_SM || cat == OT_VD || cat == OT_Avag) { pos = POS_SMVD; } @@ -584,6 +584,7 @@ enum syllable_type_t { consonant_syllable, vowel_syllable, standalone_cluster, + avagraha_cluster, broken_cluster, non_indic_cluster, }; @@ -1081,6 +1082,16 @@ initial_reordering_broken_cluster (const hb_ot_shape_plan_t *plan, initial_reordering_standalone_cluster (plan, face, buffer, start, end); } +static void +initial_reordering_avagraha_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED, + hb_face_t *face HB_UNUSED, + hb_buffer_t *buffer HB_UNUSED, + unsigned int start HB_UNUSED, unsigned int end HB_UNUSED) +{ + /* Nothing to do right now. If we ever switch to using the output + * buffer in the reordering process, we'd need to next_glyph() here. */ +} + static void initial_reordering_non_indic_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED, hb_face_t *face HB_UNUSED, @@ -1103,6 +1114,7 @@ initial_reordering_syllable (const hb_ot_shape_plan_t *plan, case consonant_syllable: initial_reordering_consonant_syllable (plan, face, buffer, start, end); return; case vowel_syllable: initial_reordering_vowel_syllable (plan, face, buffer, start, end); return; case standalone_cluster: initial_reordering_standalone_cluster (plan, face, buffer, start, end); return; + case avagraha_cluster: initial_reordering_avagraha_cluster (plan, face, buffer, start, end); return; case broken_cluster: initial_reordering_broken_cluster (plan, face, buffer, start, end); return; case non_indic_cluster: initial_reordering_non_indic_cluster (plan, face, buffer, start, end); return; } diff --git a/test/shaping/texts/in-tree/shaper-indic/indic/script-devanagari/misc/misc.txt b/test/shaping/texts/in-tree/shaper-indic/indic/script-devanagari/misc/misc.txt index 83cac77ce..80bc4a62c 100644 --- a/test/shaping/texts/in-tree/shaper-indic/indic/script-devanagari/misc/misc.txt +++ b/test/shaping/texts/in-tree/shaper-indic/indic/script-devanagari/misc/misc.txt @@ -30,3 +30,4 @@ र्अ्‍ र्आ्र् क‌ि +ऽं diff --git a/test/shaping/texts/in-tree/shaper-indic/indic/script-telugu/misc/misc.txt b/test/shaping/texts/in-tree/shaper-indic/indic/script-telugu/misc/misc.txt index 43ff3b9d4..ff522d2d1 100644 --- a/test/shaping/texts/in-tree/shaper-indic/indic/script-telugu/misc/misc.txt +++ b/test/shaping/texts/in-tree/shaper-indic/indic/script-telugu/misc/misc.txt @@ -9,3 +9,4 @@ క్ష క్ష్ క్ష్ణ +ఽం