summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpicture.cpp
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond@trolltech.com>2010-03-25 13:31:16 +0100
committerTrond Kjernåsen <trond@trolltech.com>2010-03-25 13:37:17 +0100
commita81b5cf5b4e5388f3bda2aa8c4855d9a1b0bba28 (patch)
treef81c2d596930e1c026e8c0e73f80a52b98c12cf4 /src/gui/image/qpicture.cpp
parent6729645b28f6acfeab9bb0bc488ca4143c480f5a (diff)
Fixed QPrintPreview text drawing (visible in Assistant).
WebKit (which Assistant uses) uses QFont::setPixelSize() to specify the font sizes. Those are treated differently in Qt than fonts specified with setPointSize(). Fonts specified with setPixelSize() should *not* be scaled to compensate for DPI changes between devices, unlike fonts with a pointSize() set. Task-number: QTBUG-9282 Reviewed-by: Eskil
Diffstat (limited to 'src/gui/image/qpicture.cpp')
-rw-r--r--src/gui/image/qpicture.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 3220a67332..45b3ed0e24 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -651,7 +651,12 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords)
s >> dbl;
QFont fnt(font, painter->device());
- qreal scale = painter->device()->logicalDpiY() / (dbl*qt_defaultDpiY());
+ // Fonts that specify a pixel size should not be scaled - QPicture already
+ // have a matrix set to compensate for the DPI differences between the
+ // default Qt DPI and the actual target device DPI, and we have to take that
+ // into consideration in the case where the font has a pixel size set.
+
+ qreal scale = fnt.pointSize() == -1 ? 1 : painter->device()->logicalDpiY() / (dbl*qt_defaultDpiY());
painter->save();
painter->scale(1/scale, 1/scale);
@@ -660,7 +665,7 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords)
int flags = Qt::TextSingleLine | Qt::TextDontClip | Qt::TextForceLeftToRight;
- QSizeF size(scale, scale);
+ QSizeF size(1, 1);
if (justificationWidth > 0) {
size.setWidth(justificationWidth*scale);
flags |= Qt::TextJustificationForced;