summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-06-29 07:53:29 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-07-14 14:09:33 +0200
commitade2df4c4b2df638fefd42d9b755ee7a789da503 (patch)
tree7e185057db4156bb6eba128a891a2dce5e29ba44 /src/gui/painting
parentfef9e0e216d07d7e8a144f57a8ec4133ff94fac7 (diff)
Relayout QStaticText when dpi changes
If the cached font has a different DPI than the one used in QPainter, we need to treat this the same as if other font properties have changed and redo the layout. This happened when running the QStaticText test on Wayland, because the default dpi was 100 and the QPixmap we ended up drawing to was 96. This caused the pixel size of the font to be calculated differently when doing drawText() (using 96 dpi) and drawStaticText() (using the cached 100 dpi). Pick-to: 6.4 Fixes: QTBUG-100982 Change-Id: Ie4270341bb8a64b6458eb67ba460a282c65dc26b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qpainter.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 6995f7d180..0ccfccb19e 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -39,6 +39,7 @@
#include <private/qhexstring_p.h>
#include <private/qguiapplication_p.h>
#include <private/qrawfont_p.h>
+#include <private/qfont_p.h>
QT_BEGIN_NAMESPACE
@@ -5448,7 +5449,9 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText
QStaticTextPrivate *staticText_d =
const_cast<QStaticTextPrivate *>(QStaticTextPrivate::get(&staticText));
- if (font() != staticText_d->font) {
+ QFontPrivate *fp = QFontPrivate::get(font());
+ QFontPrivate *stfp = QFontPrivate::get(staticText_d->font);
+ if (font() != staticText_d->font || fp == nullptr || stfp == nullptr || fp->dpi != stfp->dpi) {
staticText_d->font = font();
staticText_d->needsRelayout = true;
}