From 9940504e933d6766f87dca7fccc3c2f889976a22 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 3 Jul 2018 14:29:25 +0430 Subject: [PATCH] [indic] Adjust left-matra repositioning and Halant,ZWJ sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From the new code (first paragraph is from the OT Devanagari spec.): /* o Reorder matras: * * If a pre-base matra character had been reordered before applying basic * features, the glyph can be moved closer to the main consonant based on * whether half-forms had been formed. Actual position for the matra is * defined as “after last standalone halant glyph, after initial matra * position and before the main consonant”. If ZWJ or ZWNJ follow this * halant, position is moved after it. * * IMPLEMENTATION NOTES: * * It looks like the last sentence is wrong. Testing, with Windows 7 Uniscribe * and Devanagari shows that the behavior is best described as: * * "If ZWJ follows this halant, matra is NOT repositioned after this halant. * If ZWNJ follows this halant, position is moved after it." * * Test case, with Adobe Devanagari or Nirmala UI: * * U+091F,U+094D,U+200C,U+092F,U+093F * (Matra moves to the middle, after ZWNJ.) * * U+091F,U+094D,U+200D,U+092F,U+093F * (Matra does NOT move, stays to the left.) Fixes https://github.com/harfbuzz/harfbuzz/issues/1070 Test case added with Adobe Devanagari. --- src/hb-ot-shape-complex-indic.cc | 37 ++++++++++++++++++ ...16e5d8fedfbec74e45dc350d2416d810bed8c4.ttf | Bin 0 -> 4364 bytes .../data/in-house/tests/indic-joiners.tests | 4 ++ 3 files changed, 41 insertions(+) create mode 100644 test/shaping/data/in-house/fonts/8116e5d8fedfbec74e45dc350d2416d810bed8c4.ttf diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 8377dae97..b8d9a3acf 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1127,6 +1127,24 @@ final_reordering_syllable (const hb_ot_shape_plan_t *plan, * defined as “after last standalone halant glyph, after initial matra * position and before the main consonant”. If ZWJ or ZWNJ follow this * halant, position is moved after it. + * + * IMPLEMENTATION NOTES: + * + * It looks like the last sentence is wrong. Testing, with Windows 7 Uniscribe + * and Devanagari shows that the behavior is best described as: + * + * "If ZWJ follows this halant, matra is NOT repositioned after this halant. + * If ZWNJ follows this halant, position is moved after it." + * + * Test case, with Adobe Devanagari or Nirmala UI: + * + * U+091F,U+094D,U+200C,U+092F,U+093F + * (Matra moves to the middle, after ZWNJ.) + * + * U+091F,U+094D,U+200D,U+092F,U+093F + * (Matra does NOT move, stays to the left.) + * + * https://github.com/harfbuzz/harfbuzz/issues/1070 */ if (start + 1 < end && start < base) /* Otherwise there can't be any pre-base matra characters. */ @@ -1140,6 +1158,7 @@ final_reordering_syllable (const hb_ot_shape_plan_t *plan, */ if (buffer->props.script != HB_SCRIPT_MALAYALAM && buffer->props.script != HB_SCRIPT_TAMIL) { + search: while (new_pos > start && !(is_one_of (info[new_pos], (FLAG (OT_M) | FLAG (OT_H))))) new_pos--; @@ -1150,9 +1169,27 @@ final_reordering_syllable (const hb_ot_shape_plan_t *plan, if (is_halant (info[new_pos]) && info[new_pos].indic_position() != POS_PRE_M) { +#if 0 // See comment above /* -> If ZWJ or ZWNJ follow this halant, position is moved after it. */ if (new_pos + 1 < end && is_joiner (info[new_pos + 1])) new_pos++; +#endif + if (new_pos + 1 < end) + { + /* -> If ZWJ follows this halant, matra is NOT repositioned after this halant. */ + if (info[new_pos + 1].indic_category() == OT_ZWJ) + { + /* Keep searching. */ + if (new_pos > start) + { + new_pos--; + goto search; + } + } + /* -> If ZWNJ follows this halant, position is moved after it. */ + if (info[new_pos + 1].indic_category() == OT_ZWNJ) + new_pos++; + } } else new_pos = start; /* No move. */ diff --git a/test/shaping/data/in-house/fonts/8116e5d8fedfbec74e45dc350d2416d810bed8c4.ttf b/test/shaping/data/in-house/fonts/8116e5d8fedfbec74e45dc350d2416d810bed8c4.ttf new file mode 100644 index 0000000000000000000000000000000000000000..e8512bb29e14215e702082959b9a81179fe08d47 GIT binary patch literal 4364 zcmaJE3sh8P`nz}L-hq2zP?s@f_-8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DqEaI<~7Hf|kA3Gyh+o2;B9Tf+C?kDD=iMH3_o}NUJ{jyh?#V&F*U1dTEP`w>%0vspkUBC zy*c1(0r#M_M3015XyDYiFQYy!c>N`;$Z*UjA3U%K-}84s7aW3jb$+>95m>G74twKn1Gmskx6rF@p;w?C8)m8C zdGUToK%Dn2_aDaaZwcle?u~HIL?yiPg5Ezdh{d3VWVFM7-?^p%`@*2(aXRFCc?SyE z^8^0kb?aPv2KT^@fNLf-FD4SpL2@Nl+#FYisA|3A`zTABa= literal 0 HcmV?d00001 diff --git a/test/shaping/data/in-house/tests/indic-joiners.tests b/test/shaping/data/in-house/tests/indic-joiners.tests index 57107d587..dca83f87d 100644 --- a/test/shaping/data/in-house/tests/indic-joiners.tests +++ b/test/shaping/data/in-house/tests/indic-joiners.tests @@ -1,2 +1,6 @@ ../fonts/f443753e8ffe8e8aae606cfba158e00334b6efb1.ttf::U+179A,U+1784,U+17D2,U+179F,U+200C,U+17CA,U+17B8,U+0020:[uni179a=0+775|uni1784=1+1550|uni179f.sub=1+775|space=1+0|uni17ca=1+0|uni17b8=1@0,300+0|space=7+600] ../fonts/f443753e8ffe8e8aae606cfba158e00334b6efb1.ttf::U+179A,U+1784,U+17D2,U+179F,U+17CA,U+17B8:[uni179a=0+775|uni1784=1+1550|uni179f.sub=1+775|uni17bb=1@-75,-700+0|uni17b8=1+0] +../fonts/8116e5d8fedfbec74e45dc350d2416d810bed8c4.ttf:--font-funcs=ft:U+091F,U+094D,U+200C,U+092F,U+093F:[uni091F=0+876|uni094D=0@4,0+0|space=0+0|uni093F.750=3+397|uni092F=3+924] +../fonts/8116e5d8fedfbec74e45dc350d2416d810bed8c4.ttf:--font-funcs=ft:U+091F,U+094D,U+200D,U+092F,U+093F:[uni093F=0+398|uni091F=0+876|uni094D=0@4,0+0|space=0+0|uni092F=0+924] +../fonts/8116e5d8fedfbec74e45dc350d2416d810bed8c4.ttf:--font-funcs=ft:U+091F,U+094D,U+200D,U+091F,U+094D,U+200C,U+091F,U+094D,U+200D,U+092F,U+093F:[uni091F=0+876|uni094D=0@4,0+0|space=0+0|uni091F=3+876|uni094D=3@4,0+0|space=3+0|uni093F=6+398|uni091F=6+876|uni094D=6@4,0+0|space=6+0|uni092F=6+924] +../fonts/8116e5d8fedfbec74e45dc350d2416d810bed8c4.ttf:--font-funcs=ft:U+091F,U+094D,U+200D,U+091F,U+094D,U+200D,U+091F,U+094D,U+200D,U+092F,U+093F:[uni093F=0+398|uni091F=0+876|uni094D=0@4,0+0|space=0+0|uni091F=0+876|uni094D=0@4,0+0|space=0+0|uni091F=0+876|uni094D=0@4,0+0|space=0+0|uni092F=0+924]