From 2452543fdd383e62b8c4bc44b11bfd6796fc9963 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 18 Jan 2017 22:48:13 +0200 Subject: [PATCH] [ot] Fix automatic fraction for RTL scripts (#405) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The numbers for right-to-left scripts are processed also from right to left, so the order of applying “numr” and “dnom” features should be reversed in such case. Fixes https://github.com/behdad/harfbuzz/issues/395 --- src/hb-ot-shape.cc | 16 ++++++++++++++-- test/shaping/Makefile.am | 1 + ...15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf | Bin 0 -> 4936 bytes test/shaping/tests/automatic-fractions.tests | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/shaping/fonts/sha1sum/15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf create mode 100644 test/shaping/tests/automatic-fractions.tests diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index ddd6662e8..6b38739c9 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -362,6 +362,18 @@ hb_ot_shape_setup_masks_fraction (hb_ot_shape_context_t *c) hb_buffer_t *buffer = c->buffer; + hb_mask_t pre_mask, post_mask; + if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) + { + pre_mask = c->plan->numr_mask | c->plan->frac_mask; + post_mask = c->plan->frac_mask | c->plan->dnom_mask; + } + else + { + pre_mask = c->plan->frac_mask | c->plan->dnom_mask; + post_mask = c->plan->numr_mask | c->plan->frac_mask; + } + /* TODO look in pre/post context text also. */ unsigned int count = buffer->len; hb_glyph_info_t *info = buffer->info; @@ -380,10 +392,10 @@ hb_ot_shape_setup_masks_fraction (hb_ot_shape_context_t *c) end++; for (unsigned int j = start; j < i; j++) - info[j].mask |= c->plan->numr_mask | c->plan->frac_mask; + info[j].mask |= pre_mask; info[i].mask |= c->plan->frac_mask; for (unsigned int j = i + 1; j < end; j++) - info[j].mask |= c->plan->frac_mask | c->plan->dnom_mask; + info[j].mask |= post_mask; i = end - 1; } diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am index f2bb95bdd..ea0b28a7e 100644 --- a/test/shaping/Makefile.am +++ b/test/shaping/Makefile.am @@ -43,6 +43,7 @@ CLEANFILES += \ TESTS = \ tests/arabic-fallback-shaping.tests \ tests/arabic-feature-order.tests \ + tests/automatic-fractions.tests \ tests/cluster.tests \ tests/color-fonts.tests \ tests/context-matching.tests \ diff --git a/test/shaping/fonts/sha1sum/15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf b/test/shaping/fonts/sha1sum/15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf new file mode 100644 index 0000000000000000000000000000000000000000..4b80f80443b099f82927f924a4434818d76394ad GIT binary patch literal 4936 zcmaJl3vg7&k<&Bt-oAaiTCMi0&uZCy`$ZCqv|kX?B7_ja=A#I(F#>_m2MP2;NPumK z2{AFYAtAQoU_vS>@-udFhtD~e>k266j`LBDxpOXXsWV)Bz69UpDmf<{$zcP#*YkFb zMJ1Je)zi~GGu{1qdb;N=0YZos8&1g5wk7SPjNDI1SrWP4rJbu*-*TVpL3$0+mzJ(x z+q(G5wnquEMF|1ls?~GjFKknH6H;;%$2a$l_D(dOXj*~vZ;?LHw`Mb%>R%BM%S$UK~#kA!DyCME|ahUCKskv@#$1_BVwf6S^SP9lVa%97!LW(cQ}nJirZakuO& zbGW^b@Pa`fNN3{dOd9^j;qq^H@FlPGQ*M#1D&JHsgW+PC@uC6b>P_7IUo2XqMXfdy z%vv+o*YU{hH>Z3Sn^L2wDmFGtm;gCM2s?v%YtR?6q23>Z6v<>EB}}kTgBDI@St9Oo zIt()Sh1x`%ovCZNvs|`7^Ec*4_HLfHwWHQ-s*)SK4=+1%aq@WX1328c!Y|p&p>F$+ zm|ccVzgqK!uA!%9XB!+926xxyC2t=%dH783&HFmdXu*s5Kd@tHK^s~S_fn?=)q0sg z0WE^&BvGXo+^$4COABV98-#DzOe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p=z}uFIQBn|@DBieQinYQrl6UplyN`>pjiFLs}`;2oVPx~15mzb0*T9ez-> zLXfwTLkKS-^cV3n{4|{8r^!`>1K6)Zd>i2mxt(vsb>|Q|5Nrse2;B%twv3!*r^yDa z!yDLYa+KX5&#~*I2gk+`LI`OD4?-NFhJJyxuydr9Jx|)$yTrksLVT4B;@BA8Cep-1 z;+PB1kq%-bqokW8(QtfU<@U$FCZv1st@S@}bf3NJYaG;nQNpDs;V6+XYb2x>aEZ5o z+0Rh6P0Ya|{kNa^bpI7evS|6TcJc=C`PvFP9K9u22gy&-Z-fm?Y3%z%WfWg}gdqfr z{S8P7NkPOa;te=s9%5DZIK@?IdC=E}CqYPPkb6Zx|9<`_AARq=xAc`bp#RKz+fpEO zJwEIU5b_%kgcTTXaxcOl_R%&UesKsOme(PF@H9U{3g3)4&nqnBMqDlID)cGAs!JB3 zPlw4QLKhhzTgfyTA-zcJ(y=ACK1YQ7KmH|<#fSs%9xl95mXivgz<`4U_|-13zdGfFOh*3=xRJY^Z@+!}Qp2 zeLCGx#PK3d6mhbMQ$?IEDbA1W9PJ$$DN^x!sKh-~@*XO650x%Z=1*i!OpZ?!iFj-V zk(fy&XA-HIL|P||<6{E_xyGs8`!b>u$6+S-?|A&%b3-Yvv2(mOSV zktfcds5FJVOScb9juFewo%Jb<$U^)=VGgRHM8-T^n5m!+t3JZ;D>sS{U?e*+hAR=f z@+XKJp)x-Y`Of@5-d#m;T<8qr7p#P1pZnx>qY(O!hI{eZxFL|_|q(a pKKf)9;Le5aQX&hP@h;%OTJI&Zh{&N<{Flr|?6{X=_o?`<{eNRP0Nwxq literal 0 HcmV?d00001 diff --git a/test/shaping/tests/automatic-fractions.tests b/test/shaping/tests/automatic-fractions.tests new file mode 100644 index 000000000..f9510e26c --- /dev/null +++ b/test/shaping/tests/automatic-fractions.tests @@ -0,0 +1,3 @@ +fonts/sha1sum/15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf::U+0031,U+0032,U+0033,U+2044,U+0034,U+0035,U+0036:[one.numr=0+600|two.numr=1+600|three.numr=2+600|fraction=3+252|four.small=4+600|five.small=5+600|six.small=6+600] +fonts/sha1sum/15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf:--direction=l --script=arab:U+0031,U+0032,U+0033,U+2044,U+0034,U+0035,U+0036:[one.numr=0+600|two.numr=1+600|three.numr=2+600|fraction=3+252|four.small=4+600|five.small=5+600|six.small=6+600] +fonts/sha1sum/15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf:--direction=l:U+0661,U+0662,U+0663,U+2044,U+0664,U+0665,U+0666:[uni0661.numr=0+600|uni0662.numr=1+600|uni0663.numr=2+600|fraction=3+252|uni0664.small=4+600|uni0665.small=5+600|uni0666.small=6+600]