[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.
This commit is contained in:
Behdad Esfahbod 2013-10-15 11:21:01 +02:00
parent 5e7432b817
commit 3c7b3641cf
5 changed files with 22 additions and 4 deletions

View File

@ -56,6 +56,7 @@ Coeng = 14;
Repha = 15; Repha = 15;
Ra = 16; Ra = 16;
CM = 17; CM = 17;
Avag = 18;
c = (C | Ra)CM*; # is_consonant c = (C | Ra)CM*; # is_consonant
n = ((ZWNJ?.RS)? (N.N?)?); # is_consonant_modifier n = ((ZWNJ?.RS)? (N.N?)?); # is_consonant_modifier
@ -66,7 +67,7 @@ reph = (Ra H | Repha); # possible reph
cn = c.ZWJ?.n?; cn = c.ZWJ?.n?;
forced_rakar = ZWJ H ZWJ Ra; forced_rakar = ZWJ H ZWJ Ra;
matra_group = z{0,3}.M.N?.(H | forced_rakar)?; 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; place_holder = NBSP | DOTTEDCIRCLE;
halant_group = (z?.h.(ZWJ.N?)?); halant_group = (z?.h.(ZWJ.N?)?);
final_halant_group = halant_group | h.ZWNJ; 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; 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); 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; 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; broken_cluster = reph? n? (halant_group.cn){0,4} halant_or_matra_group syllable_tail;
other = any; other = any;
@ -83,6 +85,7 @@ main := |*
consonant_syllable => { found_syllable (consonant_syllable); }; consonant_syllable => { found_syllable (consonant_syllable); };
vowel_syllable => { found_syllable (vowel_syllable); }; vowel_syllable => { found_syllable (vowel_syllable); };
standalone_cluster => { found_syllable (standalone_cluster); }; standalone_cluster => { found_syllable (standalone_cluster); };
avagraha_cluster => { found_syllable (avagraha_cluster); };
broken_cluster => { found_syllable (broken_cluster); }; broken_cluster => { found_syllable (broken_cluster); };
other => { found_syllable (non_indic_cluster); }; other => { found_syllable (non_indic_cluster); };
*|; *|;

View File

@ -59,7 +59,8 @@ enum indic_category_t {
OT_Coeng, OT_Coeng,
OT_Repha, OT_Repha,
OT_Ra, /* Not explicitly listed in the OT spec, but used in the grammar. */ 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. */ /* Visual positions in a syllable from left to right. */
@ -93,7 +94,7 @@ enum indic_position_t {
enum indic_syllabic_category_t { enum indic_syllabic_category_t {
INDIC_SYLLABIC_CATEGORY_OTHER = OT_X, 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_BINDU = OT_SM,
INDIC_SYLLABIC_CATEGORY_CONSONANT = OT_C, INDIC_SYLLABIC_CATEGORY_CONSONANT = OT_C,
INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD = OT_C, INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD = OT_C,

View File

@ -249,7 +249,7 @@ set_indic_properties (hb_glyph_info_t &info)
{ {
pos = matra_position (u, pos); 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; pos = POS_SMVD;
} }
@ -584,6 +584,7 @@ enum syllable_type_t {
consonant_syllable, consonant_syllable,
vowel_syllable, vowel_syllable,
standalone_cluster, standalone_cluster,
avagraha_cluster,
broken_cluster, broken_cluster,
non_indic_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); 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 static void
initial_reordering_non_indic_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED, initial_reordering_non_indic_cluster (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_face_t *face 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 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 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 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 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; case non_indic_cluster: initial_reordering_non_indic_cluster (plan, face, buffer, start, end); return;
} }

View File

@ -30,3 +30,4 @@
र्अ्‍ र्अ्‍
र्आ्र् र्आ्र्
क‌ि क‌ि
ऽं

View File

@ -9,3 +9,4 @@
క్ష క్ష
క్ష్ క్ష్
క్ష్ణ క్ష్ణ
ఽం