From 32983c2027aed90b829fcdebf488f1de8945bcc8 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 16 Mar 2013 02:57:17 +0200 Subject: [PATCH] Improve QTextEngine::elidedText() in TextShowMnemonic mode Check if the sequence is really a mnemonic and emulate grapheme cluster if so, rather than blindly reset the next character's attributes. This covers cases like "& ", "&", etc. Change-Id: Ibb063a2d258aff6455b9bb41bbe1a58a5036d0d6 Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 066282d09c7..229db801867 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2422,12 +2422,13 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int const int end = si.position + length(&si); for (int i = si.position; i < end - 1; ++i) { - if (layoutData->string.at(i) == QLatin1Char('&')) { + if (layoutData->string.at(i) == QLatin1Char('&') + && !attributes[i + 1].whiteSpace && attributes[i + 1].graphemeBoundary) { const int gp = logClusters[i - si.position]; glyphs.attributes[gp].dontPrint = true; - attributes[i + 1].graphemeBoundary = false; - attributes[i + 1].lineBreak = false; - attributes[i + 1].whiteSpace = false; + // emulate grapheme cluster + attributes[i] = attributes[i + 1]; + memset(attributes + i + 1, 0, sizeof(QCharAttributes)); if (layoutData->string.at(i + 1) == QLatin1Char('&')) ++i; }