diff options
author | Nils Jeisecke <jeisecke@saltation.de> | 2016-09-01 14:26:18 +0200 |
---|---|---|
committer | Nils Jeisecke <nils.jeisecke@saltation.com> | 2019-09-17 23:05:09 +0200 |
commit | 4a240bb67e72b34c80af448e0a74846609fa6975 (patch) | |
tree | 6ce38e4b7f44cc6dc260534fcc4df4525c2d817a /src/gui/text/qtextdocumentlayout.cpp | |
parent | 6cee284001adf9da42b347a074cbff3cb92621b2 (diff) |
QTextDocument: Fix device scaling for QTextFrameFormat margins, padding and border
Those values must be scaled to device coordinates - otherwise borders,
margins etc. will be too small when rendered on high dpi devices
(printers etc.).
This change will add the scaling to those values.
QTextDocument::print applies 2cm margins to the root frame of a
unpaginated QTextDocument. Those margins were previously scaled to
device coordinates in order to give the correct result. But because
scaling is now done inside QTextDocumentLayout that scaling must be
removed and pixel values based on qt_defaultDpi are provided instead.
Fixes: QTBUG-78318
Change-Id: I6fe6dcc25f846341f6a2fe5df2f54baea473fdfd
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/gui/text/qtextdocumentlayout.cpp')
-rw-r--r-- | src/gui/text/qtextdocumentlayout.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index b02723c047..a9a177da8b 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -2915,24 +2915,24 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in { QTextFrameFormat fformat = f->frameFormat(); // set sizes of this frame from the format - QFixed tm = QFixed::fromReal(fformat.topMargin()); + QFixed tm = QFixed::fromReal(scaleToDevice(fformat.topMargin())).round(); if (tm != fd->topMargin) { fd->topMargin = tm; fullLayout = true; } - QFixed bm = QFixed::fromReal(fformat.bottomMargin()); + QFixed bm = QFixed::fromReal(scaleToDevice(fformat.bottomMargin())).round(); if (bm != fd->bottomMargin) { fd->bottomMargin = bm; fullLayout = true; } - fd->leftMargin = QFixed::fromReal(fformat.leftMargin()); - fd->rightMargin = QFixed::fromReal(fformat.rightMargin()); - QFixed b = QFixed::fromReal(fformat.border()); + fd->leftMargin = QFixed::fromReal(scaleToDevice(fformat.leftMargin())).round(); + fd->rightMargin = QFixed::fromReal(scaleToDevice(fformat.rightMargin())).round(); + QFixed b = QFixed::fromReal(scaleToDevice(fformat.border())).round(); if (b != fd->border) { fd->border = b; fullLayout = true; } - QFixed p = QFixed::fromReal(fformat.padding()); + QFixed p = QFixed::fromReal(scaleToDevice(fformat.padding())).round(); if (p != fd->padding) { fd->padding = p; fullLayout = true; |