[Indic] Implement Sinhala "Al Lakuna" Reph behavior
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 18 Jul 2012 21:22:14 +0000 (17:22 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 18 Jul 2012 21:22:14 +0000 (17:22 -0400)
In Sinhala, Reph is formed only explicitly, by the presence of a ZWJ.

src/hb-ot-shape-complex-indic-private.hh
src/hb-ot-shape-complex-indic.cc
test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/MANIFEST
test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/reph.txt [new file with mode: 0644]

index e97fca9..ac11732 100644 (file)
@@ -269,6 +269,8 @@ static const hb_codepoint_t ra_chars[] = {
   0x0CB0, /* Kannada */
   0x0D30, /* Malayalam */      /* No Reph, Logical Repha */
 
+  0x0DBB, /* Sinhala */                /* Reph formed only with ZWJ */
+
   0x179A, /* Khmer */          /* No Reph, Visual Repha */
 };
 
index 9b5b499..fa88d2e 100644 (file)
@@ -356,9 +356,14 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff
        start + 3 <= end &&
        info[start].indic_category() == OT_Ra &&
        info[start + 1].indic_category() == OT_H &&
-       !is_joiner (info[start + 2]))
+       (unlikely (buffer->props.script == HB_SCRIPT_SINHALA) ?
+        info[start + 2].indic_category() == OT_ZWJ /* In Sinhala, form Reph only if ZWJ is present */:
+        !is_joiner (info[start + 2] /* In other scripts, any joiner blocks Reph formation */ )
+       ))
     {
       limit += 2;
+      while (limit < end && is_joiner (info[limit]))
+        limit++;
       base = start;
       has_reph = true;
     };
diff --git a/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/reph.txt b/test/shaping/texts/in-tree/shaper-indic/indic/script-sinhala/misc/reph.txt
new file mode 100644 (file)
index 0000000..f5f2f53
--- /dev/null
@@ -0,0 +1,3 @@
+ර්ධ
+ර්‍ධ
+ර්‌ධ