From f53ef69d5941514b06f5afbcd83709cf724eb74d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 4 Nov 2022 16:00:34 -0600 Subject: [PATCH] [indic] Order left-matras inside-out Fixes https://github.com/harfbuzz/harfbuzz/issues/3863 --- src/hb-ot-shaper-indic.cc | 28 +++++++++++++++++- src/hb-ot-shaper-myanmar.cc | 27 +++++++++++++++++ ...8c53cb64b8747abdd2b70755cce2ee0eb42ef7.ttf | Bin 0 -> 3000 bytes ...32bb734d4c6c898a44506547d19768f0eba6a6.ttf | Bin 0 -> 2512 bytes .../in-house/tests/indic-special-cases.tests | 2 ++ .../data/in-house/tests/myanmar-misc.tests | 1 + 6 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 test/shape/data/in-house/fonts/9d8c53cb64b8747abdd2b70755cce2ee0eb42ef7.ttf create mode 100644 test/shape/data/in-house/fonts/a232bb734d4c6c898a44506547d19768f0eba6a6.ttf diff --git a/src/hb-ot-shaper-indic.cc b/src/hb-ot-shaper-indic.cc index 55509c110..1f6ae5237 100644 --- a/src/hb-ot-shaper-indic.cc +++ b/src/hb-ot-shaper-indic.cc @@ -742,14 +742,40 @@ initial_reordering_consonant_syllable (const hb_ot_shape_plan_t *plan, /* Sit tight, rock 'n roll! */ hb_stable_sort (info + start, end - start, compare_indic_order); - /* Find base again */ + + /* Find base again; also flip left-matra sequence. */ + unsigned first_left_matra = end; + unsigned last_left_matra = end; base = end; for (unsigned int i = start; i < end; i++) + { if (info[i].indic_position() == POS_BASE_C) { base = i; break; } + else if (info[i].indic_position() == POS_PRE_M) + { + if (first_left_matra == end) + first_left_matra = i; + last_left_matra = i; + } + } + /* https://github.com/harfbuzz/harfbuzz/issues/3863 */ + if (first_left_matra < last_left_matra) + { + /* No need to merge clusters, handled later. */ + buffer->reverse_range (first_left_matra, last_left_matra + 1); + /* Reverse back nuktas, etc. */ + unsigned i = first_left_matra; + for (unsigned j = i; j <= last_left_matra; j++) + if (info[j].indic_category() == I_Cat(M)) + { + buffer->reverse_range (i, j + 1); + i = j + 1; + } + } + /* Things are out-of-control for post base positions, they may shuffle * around like crazy. In old-spec mode, we move halants around, so in * that case merge all clusters after base. Otherwise, check the sort diff --git a/src/hb-ot-shaper-myanmar.cc b/src/hb-ot-shaper-myanmar.cc index 78bd8de52..1039bdfeb 100644 --- a/src/hb-ot-shaper-myanmar.cc +++ b/src/hb-ot-shaper-myanmar.cc @@ -270,6 +270,33 @@ initial_reordering_consonant_syllable (hb_buffer_t *buffer, /* Sit tight, rock 'n roll! */ buffer->sort (start, end, compare_myanmar_order); + + /* Flip left-matra sequence. */ + unsigned first_left_matra = end; + unsigned last_left_matra = end; + for (unsigned int i = start; i < end; i++) + { + if (info[i].myanmar_position() == POS_PRE_M) + { + if (first_left_matra == end) + first_left_matra = i; + last_left_matra = i; + } + } + /* https://github.com/harfbuzz/harfbuzz/issues/3863 */ + if (first_left_matra < last_left_matra) + { + /* No need to merge clusters, done already? */ + buffer->reverse_range (first_left_matra, last_left_matra + 1); + /* Reverse back VS, etc. */ + unsigned i = first_left_matra; + for (unsigned j = i; j <= last_left_matra; j++) + if (info[j].myanmar_category() == M_Cat(VPre)) + { + buffer->reverse_range (i, j + 1); + i = j + 1; + } + } } static void diff --git a/test/shape/data/in-house/fonts/9d8c53cb64b8747abdd2b70755cce2ee0eb42ef7.ttf b/test/shape/data/in-house/fonts/9d8c53cb64b8747abdd2b70755cce2ee0eb42ef7.ttf new file mode 100644 index 0000000000000000000000000000000000000000..9c9f9426a824d3dd3df001e4cd2462b9c60b4af6 GIT binary patch literal 3000 zcmb7GeQZ*X89LEks>2qwHkOs%`S4qf+6DX!FNfwe(y0(Bzj2+cU7zrUr zRcq6{X3$Go>?O4EpYo|UmFDk@&!o~|kGQ>1EFw_#b5`6qo;9=kcL&H78*FOI90(5@_?1@ju zkF@_G3S|}rt~)puKU{gf@-_Gy0p4{8@|Vn`uL3K;+mq?zhu*VYyiTNl8GAlULY{l= z@(CjCpMc*^CE_FH^GXE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bK|aknx`B0~k4qL((S+Zwe0eDFP~VL2y_$GCRkBVGr|D{7)AiM>g$;&kKD zd{54hlN9U^)JYDvPe$@Qdxu+;M0ST=cDL2dW?sJf`yY2FVkh7D*@4H8cT`*Ulvlp_ z+#}4I9F#LneTO;%{oz_?=-v%Jt25{x+M9nP7F)*Q5ngz#qf|z|BF%7HdWy7m)h52z zWvHa8ug6!-P^1mw#^|L9O4A4pQ3C&YMyZ7RfJcCjg8MMm5t^bDs08RFs43i*6PPEk zGmh9Mapxp(-*7q(jW`{F=4RRrZW30~g0lzc2y{oWZyenXAbP*}m8>Z%_LQ%*sQib; zRSR1wMg#c8a0!&G{XenY9cjtJ|B7cDGC54gMYd{PcvgODr7-e~K{|o_)5u$)2axkY bWUNpRIBBfASE@NFPy)5#6`IC8LcV_kHEa<* literal 0 HcmV?d00001 diff --git a/test/shape/data/in-house/fonts/a232bb734d4c6c898a44506547d19768f0eba6a6.ttf b/test/shape/data/in-house/fonts/a232bb734d4c6c898a44506547d19768f0eba6a6.ttf new file mode 100644 index 0000000000000000000000000000000000000000..e0325bb0c0b41f08c281b7fc61198bb434411273 GIT binary patch literal 2512 zcma)7T~Hg>6+XM#)z4ag2uVm7WFg6t3__qEBw=I_f*^x!oHah7NiI>K<&8W zy1~s$GM#Cs(?>rgnNA;^X&?H~hs-z+nardQ>2KWWj~!=>8=PbY#wI|8Z1uY!e z)4Q{K&v(u}=X~ef-MhpQkqHlhoSFU?2FOA@5jO^Hedcs_6j%aI0BbX&FQtF~#^)!A z6gPnvj*s__Y`kIkB@w?4d?GvA7XHDr!tY>D0-qlp>m6JF*X>wsw%B>Ykyq3{vX^KXCoMJh#`<#t{XeYc8|v! z!kWj470f9yZ{SwJ_A+L5bq$L_Ern=A*NsLb3s3Ug^_4~V=V3OvuES4Tz6WV0DAg*soa?2{N!oW%l`n|K@l zTTD*yVOSyu1&AwLErii0*&RJ%7Vg`#R~DhG_;Ii)(PB>SW|W%A1y3kY1G81%3t*A}vjh%~EmWYn7(BdGGe^+aLVl{^uJi>rU~>qc1l~rBYF`wMmbcU+dw@f+I}|IuvTYxKm$m zH;{HY#&HUbK@tT8m7hH=m6a@qR<*wJ*E@Ia{QbdKk4t*H-Tv_5!*yP3@qqM8=>x)~hk#KBRuk!7# z*Ym&ebh!qv5075!Z#wFYH2N&TkwjuFXz@4jDMz@u)@cqlj9zFNNd}K64|;spPK{sd z^A4PoY$G$B~XR(Zj5}q<9QKvsvz%n>3K#z60z*o0s66cou20+V~br4vBR!_ zwIe@tY@)BW&(PlE_a?k1d%H)}9f{SuPbB@BxM85?g-Pk~K*$|CEGea?)`r#|mp$S= z>~I?-i^F2}SdZI$R!2*nE$nx<_q!RlD7dA-EyTF(=TvE^Or+9Z)@#;xMr$BBHR#V= z%cgQ^!+^fMuQfap@}BPYCtD1*o={UyqOS2^deGfAobl@V@>0vmi${mA4;~o|d79%5 z;cp!aPaHG*9W{1Slcm4TU2F0l>KbpuZtLhR_N59M$mckJRp!Wrv#z4&Nl)8VSwa2u z>#8i^tiDl|MXIOis;s0S9j(at;I%+<9Q;Eh@>FH?JTNv(jY3lfcl*HzGrbU{<~dUl+hGA!TNC-&q)gY E8(K5OZ~y=R literal 0 HcmV?d00001 diff --git a/test/shape/data/in-house/tests/indic-special-cases.tests b/test/shape/data/in-house/tests/indic-special-cases.tests index 016f8947f..99ba13b30 100644 --- a/test/shape/data/in-house/tests/indic-special-cases.tests +++ b/test/shape/data/in-house/tests/indic-special-cases.tests @@ -2,3 +2,5 @@ ../fonts/3cae6bfe5b57c07ba81ddbd54c02fe4f3a1e3bf6.ttf;;U+0CB0,U+200D,U+0CCD,U+0C95;[gid2=0+1334|gid6=0+358] ../fonts/3cae6bfe5b57c07ba81ddbd54c02fe4f3a1e3bf6.ttf;;U+0CB0,U+0CCD,U+200D,U+0C95;[gid2=0+1334|gid6=0+358] ../fonts/e716f6bd00a108d186b7e9f47b4515565f784f36.ttf;;U+0C1A,U+0C3F,U+0C32,U+0C4D,U+0C15,U+0C42,U+0C30,U+0C4D;[civoweltelu=0+766|latelu=2+709|uuvowelsigntelu=2+661|kasubscripttelu=2+483|rahalanttelu=6+593] +../fonts/9d8c53cb64b8747abdd2b70755cce2ee0eb42ef7.ttf;;U+0915,U+093F,U+094E,U+093C;[uni094E=0+273|uni093C=0+0|ivowelsign03deva=0+259|uni0915=0+762] +../fonts/9d8c53cb64b8747abdd2b70755cce2ee0eb42ef7.ttf;;U+0915,U+093F,U+093C,U+094E;[uni094E=0+273|ivowelsign00deva=0+259|uni093C=0+0|uni0915=0+762] diff --git a/test/shape/data/in-house/tests/myanmar-misc.tests b/test/shape/data/in-house/tests/myanmar-misc.tests index 527386394..8ba0be472 100644 --- a/test/shape/data/in-house/tests/myanmar-misc.tests +++ b/test/shape/data/in-house/tests/myanmar-misc.tests @@ -1 +1,2 @@ ../fonts/065b01e54f35f0d849fd43bd5b936212739a50cb.ttf;;U+101A,U+1035;[ya_e_above=0+1000] +../fonts/a232bb734d4c6c898a44506547d19768f0eba6a6.ttf;;U+1000,U+1031,U+1084;[e_shn=0+592|_e=0+618|ka=0+1124]