summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2012-10-29 15:16:55 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-30 17:49:26 +0100
commit788e1b2ffa5541b86f62bf468540bb8b5872c033 (patch)
treeac75131a27924adc13ea24cf4cc08a30a3ec7a69 /src
parentfc0cbef59599174589a606838a9b55ba6a07ef06 (diff)
Pixel-align vertical metrics in QTextLayout again
To avoid regressing due to de58eb64bc564fcb8af61a45576783e432d2380c, we need to return a pixel aligned height in QTextLine::height() and also use pixel aligned heights when calculating the position of lines as well as the bounding rect of the layout. Later, we can add a QTextLine::naturalHeight() or something like that which gives the fractional value, but until then, we need to access private API in QPainter to get the correct alignment, since we still don't want to align the height of the last line in the layout, we only want to align the origin of each line. Task-number: QTBUG-27740 Change-Id: I12325f07d33aaf1a1b967e0a11492759d0f565d9 Reviewed-by: Caroline Chao <caroline.chao@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpainter.cpp5
-rw-r--r--src/gui/text/qtextlayout.cpp4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 7070e5732d..0cfe953e43 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7498,8 +7498,11 @@ start_lengthVariant:
l.setLineWidth(lineWidth);
height += leading;
+
+ // Make sure lines are positioned on whole pixels
+ height = qCeil(height);
l.setPosition(QPointF(0., height));
- height += l.height();
+ height += textLayout.engine()->lines[l.lineNumber()].height().toReal();
width = qMax(width, l.naturalTextWidth());
if (!dontclip && !brect && height >= r.height())
break;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index a0a92897c5..0ca8e8d9a6 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -916,7 +916,7 @@ QRectF QTextLayout::boundingRect() const
QFixed lineWidth = si.width < QFIXED_MAX ? qMax(si.width, si.textWidth) : si.textWidth;
xmax = qMax(xmax, si.x+lineWidth);
// ### shouldn't the ascent be used in ymin???
- ymax = qMax(ymax, si.y+si.height());
+ ymax = qMax(ymax, si.y+si.height().ceil());
}
return QRectF(xmin.toReal(), ymin.toReal(), (xmax-xmin).toReal(), (ymax-ymin).toReal());
}
@@ -1466,7 +1466,7 @@ qreal QTextLine::descent() const
*/
qreal QTextLine::height() const
{
- return eng->lines[index].height().toReal();
+ return eng->lines[index].height().ceil().toReal();
}
/*!