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>
l.setLineWidth(lineWidth);
height += leading;
l.setLineWidth(lineWidth);
height += leading;
+
+ // Make sure lines are positioned on whole pixels
+ height = qCeil(height);
l.setPosition(QPointF(0., height));
l.setPosition(QPointF(0., height));
+ height += textLayout.engine()->lines[l.lineNumber()].height().toReal();
width = qMax(width, l.naturalTextWidth());
if (!dontclip && !brect && height >= r.height())
break;
width = qMax(width, l.naturalTextWidth());
if (!dontclip && !brect && height >= r.height())
break;
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???
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());
}
}
return QRectF(xmin.toReal(), ymin.toReal(), (xmax-xmin).toReal(), (ymax-ymin).toReal());
}
*/
qreal QTextLine::height() const
{
*/
qreal QTextLine::height() const
{
- return eng->lines[index].height().toReal();
+ return eng->lines[index].height().ceil().toReal();