From e26660c004f8a68dbf6b262139f568d0b5efe663 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 26 Jun 2014 22:47:34 +0300 Subject: [PATCH] Don't assert when HB-old is unable to deal with surrogates Since we have no interest in fixing HB-old to properly support surrogates, here is a simple workaround for the case when surrogate parts gets treated like two separate glyphs in log_clusters but a single character. And since it's a known issue that HB-old doesn't really support surrogates, it's better to draw some garbage/boxes rather than to assert, IMO. Task-number: QTBUG-39875 Change-Id: I95ff43e821ae989d7a6f792f71f157dcea92dd16 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 67dedca760..a3059008be 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1298,8 +1298,12 @@ int QTextEngine::shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *stri attrs.justification = hbAttrs.justification; } - for (quint32 i = 0; i < shaper_item.item.length; ++i) + for (quint32 i = 0; i < shaper_item.item.length; ++i) { + // Workaround wrong log_clusters for surrogates (i.e. QTBUG-39875) + if (shaper_item.log_clusters[i] >= shaper_item.num_glyphs) + shaper_item.log_clusters[i] = shaper_item.num_glyphs - 1; shaper_item.log_clusters[i] += glyph_pos; + } if (kerningEnabled && !shaper_item.kerning_applied) actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0));