From 483bc0a3847ae55860bd55fa0eb214f899a02b31 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 8 Aug 2023 15:58:20 -0600 Subject: [PATCH] [arabic/stch] Center the stretched group over the digits Mostly relevant when there's one digit only. https://github.com/harfbuzz/harfbuzz/issues/4369#issuecomment-1670361856 --- src/hb-ot-shaper-arabic.cc | 5 ++++- test/shape/data/in-house/tests/arabic-stch.tests | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-shaper-arabic.cc b/src/hb-ot-shaper-arabic.cc index 1bd730be2..72dcc84df 100644 --- a/src/hb-ot-shaper-arabic.cc +++ b/src/hb-ot-shaper-arabic.cc @@ -579,7 +579,10 @@ apply_stch (const hb_ot_shape_plan_t *plan HB_UNUSED, ++n_copies; hb_position_t excess = (n_copies + 1) * sign * w_repeating - sign * w_remaining; if (excess > 0) + { extra_repeat_overlap = excess / (n_copies * n_repeating); + w_remaining = 0; + } } if (step == MEASURE) @@ -590,7 +593,7 @@ apply_stch (const hb_ot_shape_plan_t *plan HB_UNUSED, else { buffer->unsafe_to_break (context, end); - hb_position_t x_offset = 0; + hb_position_t x_offset = w_remaining / 2; for (unsigned int k = end; k > start; k--) { hb_position_t width = font->get_glyph_h_advance (info[k - 1].codepoint); diff --git a/test/shape/data/in-house/tests/arabic-stch.tests b/test/shape/data/in-house/tests/arabic-stch.tests index 9221d31bb..890d8bf11 100644 --- a/test/shape/data/in-house/tests/arabic-stch.tests +++ b/test/shape/data/in-house/tests/arabic-stch.tests @@ -1,2 +1,3 @@ ../fonts/d9b8bc10985f24796826c29f7ccba3d0ae11ec02.ttf;--no-glyph-names;U+0718,U+070F,U+0718,U+0718,U+002E;[1=4+168|3=3+502|3=2+502|4=1@-1004,0+0|5=1@-876,0+0|5=1@-799,0+0|5=1@-722,0+0|5=1@-645,0+0|4=1@-566,0+0|5=1@-438,0+0|5=1@-361,0+0|5=1@-284,0+0|5=1@-207,0+0|4=1@-128,0+0|3=0+502] ../fonts/507637795ce4f2975593da54d12b46f76c7cc4cc.ttf;--direction=l;U+0891,U+0661,U+0662,U+0663,U+0664,U+066B;[piastre-ar.head=0+0|piastre-ar.repeat=0@644,0+0|piastre-ar.repeat=0@778,0+0|piastre-ar.repeat=0@897,0+0|piastre-ar.repeat=0@1016,0+0|piastre-ar.repeat=0@1135,0+0|piastre-ar.repeat=0@1254,0+0|piastre-ar.repeat=0@1373,0+0|piastre-ar.repeat=0@1492,0+0|piastre-ar.tail=0@1611,0+0|one-ar=1+449|two-ar=2+449|three-ar=3+449|four-ar=4+449|decimalseparator-ar=5+222] +../fonts/507637795ce4f2975593da54d12b46f76c7cc4cc.ttf;--direction=l;U+0661,U+0662,U+0663,U+0891,U+0664,U+066B;[one-ar=0+449|two-ar=1+449|three-ar=2+449|piastre-ar.head=3@-192,0+0|piastre-ar.repeat=3@452,0+0|piastre-ar.tail=3@586,0+0|four-ar=4+449|decimalseparator-ar=5+222]