From ce0d3f4e72af11775e3591f831283469d6a0c4ce Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 9 Feb 2015 17:44:14 +0400 Subject: [HarfBuzz/CoreText] Re-apply fix for QTBUG-38113 Task-number: QTBUG-38113 Change-Id: Icdedfdb240a2888e0a084a156db5598c033495de Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/3rdparty/harfbuzz-ng/src/hb-coretext.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/3rdparty') diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc index 4548b7402b..ab9e1d4a93 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc +++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc @@ -827,6 +827,8 @@ retry: run_advance = -run_advance; DEBUG_MSG (CORETEXT, run, "Run advance: %g", run_advance); + CFRange range = CTRunGetStringRange (run); + /* CoreText does automatic font fallback (AKA "cascading") for characters * not supported by the requested font, and provides no way to turn it off, * so we must detect if the returned run uses a font other than the requested @@ -893,7 +895,6 @@ retry: } if (!matched) { - CFRange range = CTRunGetStringRange (run); DEBUG_MSG (CORETEXT, run, "Run used fallback font: %ld..%ld", range.location, range.location + range.length); if (!buffer->ensure_inplace (buffer->len + range.length)) @@ -945,7 +946,13 @@ retry: if (num_glyphs == 0) continue; - if (!buffer->ensure_inplace (buffer->len + num_glyphs)) + /* ### temporary fix for QTBUG-38113 */ + /* CoreText throws away the PDF token, while the OpenType backend will add a zero-advance + * glyph for this. We need to make sure the two produce the same output. */ + UniChar endGlyph = CFStringGetCharacterAtIndex (string_ref, range.location + range.length - 1); + bool endsWithPDF = endGlyph == 0x202c; + + if (!buffer->ensure_inplace (buffer->len + num_glyphs + (endsWithPDF ? 1 : 0))) goto resize_and_retry; hb_glyph_info_t *run_info = buffer->info + buffer->len; @@ -1036,6 +1043,20 @@ retry: info++; } } + if (endsWithPDF) { + /* Ensure a zero-advance glyph the PDF token */ + if (unlikely (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))) { + memmove (run_info + 1, run_info, num_glyphs * sizeof (hb_glyph_info_t)); + info = run_info; + } + info->codepoint = 0xffff; + info->cluster = log_clusters[range.location + range.length - 1]; + info->mask = 0; + info->var1.u32 = 0; + info->var2.u32 = 0; + + buffer->len++; + } SCRATCH_RESTORE(); advances_so_far += run_advance; } -- cgit v1.2.3