diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2017-08-08 09:23:45 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2017-08-09 08:08:02 +0000 |
commit | e8161969828a67584fa3ab1cdb2bd79eb447c1da (patch) | |
tree | 31e541177e022343933901d8835c0cff02618484 /src/quick/items/qquicktext.cpp | |
parent | bf0368f9af60278f5216dabed3cf9a2bf0e1233b (diff) |
Fix hardcoding font family before the font is loaded
When you hardcoded the font family of an application font before
the font was actually loaded, the QTextLayout would cache the
glyph indexes from the fallback font, and these would later be
applied to the proper font in the render thread, causing corrupted
text and warnings.
It is easy enough to work around this by binding the font.family
property to the name property of the FontLoader, but to handle the
error case more gracefully, we now check during the polish phase
whether the actual font assignment has changed, and redo the
QTextLayout when we have to.
[ChangeLog][QtQuick][Text] Fixed an issue when the family of
an application font was hardcoded and applied to text before
the font itself was loaded.
Task-number: QTBUG-61984
Change-Id: Ib0e80a78f3b6fe4a3b0188c69516a20d0bf4cb45
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/quick/items/qquicktext.cpp')
-rw-r--r-- | src/quick/items/qquicktext.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 2e66367e85..5ca0bb5f79 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -1059,6 +1059,8 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) if (eos != multilengthEos) truncated = true; + assignedFont = QFontInfo(font).family(); + if (elide) { if (!elideLayout) { elideLayout = new QTextLayout; @@ -2414,6 +2416,12 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data void QQuickText::updatePolish() { Q_D(QQuickText); + // If the fonts used for rendering are different from the ones used in the GUI thread, + // it means we will get warnings and corrupted text. If this case is detected, we need + // to update the text layout before creating the scenegraph nodes. + if (!d->assignedFont.isEmpty() && QFontInfo(d->font).family() != d->assignedFont) + d->polishSize = true; + if (d->polishSize) { d->updateSize(); d->polishSize = false; |