From 05cfb6cd09eb27f960362c077855959835dae88c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 9 Apr 2014 14:19:32 +0200 Subject: HB-NG w/CoreText backend: Fix clustering of neutral characters Say you have a string with logical contents "abc ABC, " where lowercase is LTR and uppercase is RTL. In this case, the UBA will give "abc " LTR direction, and "ABC, " will get RTL. However, our itemization currently divides "ABC, " into two script items: "ABC" and ", ". CoreText will return glyphs in visual order, so for the first we will get "CBA" and for the second we will get ", ". But as the ", " item has an adapted directionality of RTL in the context of the full paragraph, it should actually be " ," visually. This caused a mismatch which broke the tst_QComplexText test with HB-NG using CoreText backend. As a temporary fix for this, we check whether the directionality of the first run in the text is different from the directionality expected by HB-NG. If this happens, it means the order of the glyphs produced by CoreText will be the reverse order of what is expected by HB-NG, and we therefore need to reverse it. Task-number: QTBUG-38113 Change-Id: I9f5a041791e4529a14041a362b2d5dd00490a38b Reviewed-by: Konstantin Ritt Reviewed-by: Simon Hausmann --- src/3rdparty/harfbuzz-ng/src/hb-coretext.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/3rdparty/harfbuzz-ng/src') diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc index 09f3171b30..4a905ee189 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc +++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc @@ -807,6 +807,9 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, buffer->clear_positions (); + bool bufferRtl = !HB_DIRECTION_IS_FORWARD (buffer->props.direction); + bool runRtl = (CTRunGetStatus(static_cast(CFArrayGetValueAtIndex(glyph_runs, 0))) & kCTRunStatusRightToLeft); + unsigned int count = buffer->len; for (unsigned int i = 0; i < count; ++i) { hb_glyph_info_t *info = &buffer->info[i]; @@ -816,6 +819,12 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, pos->x_advance = info->mask; pos->x_offset = info->var1.u32; pos->y_offset = info->var2.u32; + + if (bufferRtl != runRtl && i < count / 2) { + unsigned int temp = buffer->info[count - i - 1].cluster; + buffer->info[count - i - 1].cluster = info->cluster; + info->cluster = temp; + } } /* Fix up clusters so that we never return out-of-order indices; -- cgit v1.2.3