summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextengine.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2018-12-20 09:27:09 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2018-12-21 10:27:12 +0000
commite6880e7cd145fe07651e8afdfd4a15d57b810024 (patch)
tree22ea4d5ed49824416f9afef9e1cf1351a9e70c9e /src/gui/text/qtextengine.cpp
parentb45c1e1c0e3dd838543c1e8d4725d9436367a16a (diff)
Fix text shifting vertically when elided
When eliding text we would check for the existence of the ellipsis character and fall back to using the dot if it was not available. However, when font merging was in use, we would also use ellipsis from a fallback font if available. This could cause the metrics of the text to increase if the fallback font had larger metrics, and the result was that text could shift when elided. It is better to prefer the dot from the current font than to use the ellipsis from a fallback, so we only use the ellipsis if it is in the main font. [ChangeLog][QtGui][Text] Fixed a bug where eliding text could change the height of its bounding rectangle for certain fonts. Fixes: QTBUG-72553 Change-Id: Ib27fc65302465ddce661801bcc5ae32e55f1aeb9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/gui/text/qtextengine.cpp')
-rw-r--r--src/gui/text/qtextengine.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 8de16038ad..bdb5592e9e 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -3192,6 +3192,16 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
QChar ellipsisChar(0x2026);
+ // We only want to use the ellipsis character if it is from the main
+ // font (not one of the fallbacks), since using a fallback font
+ // will affect the metrics of the text, potentially causing it to shift
+ // when it is being elided.
+ if (engine->type() == QFontEngine::Multi) {
+ QFontEngineMulti *multiEngine = static_cast<QFontEngineMulti *>(engine);
+ multiEngine->ensureEngineAt(0);
+ engine = multiEngine->engine(0);
+ }
+
glyph_t glyph = engine->glyphIndex(ellipsisChar.unicode());
QGlyphLayout glyphs;