summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-07-12 09:33:31 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-07-12 13:58:35 (GMT)
commit2118a8df91263dcadd1ca0067caed84d1c749977 (patch)
treedf8bf1f038ac78c86757496bd57956e8bd7ec34c /src/gui/painting
parentade1378a4fc479d7ff3de3eb636c222c195a9082 (diff)
downloadQt-2118a8df91263dcadd1ca0067caed84d1c749977.zip
Qt-2118a8df91263dcadd1ca0067caed84d1c749977.tar.gz
Qt-2118a8df91263dcadd1ca0067caed84d1c749977.tar.bz2
Compensate for different rounding rule in CG engine
After we switched to fractional metrics, Core Graphics engine always put text at floored vertical postion, while underlines will be rounded after 0.75. Ceiling the underline position will make sure it will always leave the underline pixels given. Task-number: QTBUG-19959 Reviewed-by: Eskil
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qpainter.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 604c1ab..754b16e 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -6335,10 +6335,16 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const
QLineF line(pos.x(), pos.y(), pos.x() + width, pos.y());
- const qreal underlineOffset = fe->underlinePosition().toReal();
+ qreal underlineOffset = fe->underlinePosition().toReal();
+ qreal y = pos.y();
+ // compensate for different rounding rule in Core Graphics paint engine,
+ // ideally code like this should be moved to respective engines.
+ if (painter->paintEngine()->type() == QPaintEngine::CoreGraphics) {
+ y = qCeil(y);
+ }
// deliberately ceil the offset to avoid the underline coming too close to
// the text above it.
- const qreal underlinePos = pos.y() + qCeil(underlineOffset);
+ const qreal underlinePos = y + qCeil(underlineOffset);
if (underlineStyle == QTextCharFormat::SpellCheckUnderline) {
underlineStyle = QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle));