diff options
-rw-r--r-- | src/quick/items/qquicktext.cpp | 8 | ||||
-rw-r--r-- | src/quick/items/qquicktext_p_p.h | 2 |
2 files changed, 10 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; diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index 957641ec0a..87f5162384 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -154,6 +154,8 @@ public: QQuickText::RenderType renderType; UpdateType updateType; + QString assignedFont; + bool maximumLineCountValid:1; bool updateOnComponentComplete:1; bool richText:1; |