aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@theqtcompany.com>2016-04-13 11:56:50 +0200
committerAndy Nichols <andy.nichols@theqtcompany.com>2016-04-13 14:18:05 +0000
commit49f715f9f0b777d47de89f600199fe297c89a9c6 (patch)
tree141c760598438302ff919e70c79667f24333c506 /src
parentd210a5c839bc95cd1e382a2be50932e5eff4fbe0 (diff)
2DRenderer: Fix Text Styles on HiDPI screens
It's not enough to use 1 pixel offsets, you need to adjust for the devicePixelRatio because otherwise the corners will look unusual. Change-Id: I2879da82047ef53805286cbdb33af06d669529ea Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
index d22830a831..21f20c66cd 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
@@ -90,22 +90,26 @@ void QSGSoftwareGlyphNode::paint(QPainter *painter)
painter->setBrush(QBrush());
QPointF pos = m_position - QPointF(0, m_glyphRun.rawFont().ascent());
+ qreal offset = 1.0;
+ if (painter->device()->devicePixelRatio() != 0)
+ offset = 1.0 / painter->device()->devicePixelRatio();
+
switch (m_style) {
case QQuickText::Normal: break;
case QQuickText::Outline:
painter->setPen(m_styleColor);
- painter->drawGlyphRun(pos + QPointF(0, 1), m_glyphRun);
- painter->drawGlyphRun(pos + QPointF(0, -1), m_glyphRun);
- painter->drawGlyphRun(pos + QPointF(1, 0), m_glyphRun);
- painter->drawGlyphRun(pos + QPointF(-1, 0), m_glyphRun);
+ painter->drawGlyphRun(pos + QPointF(0, offset), m_glyphRun);
+ painter->drawGlyphRun(pos + QPointF(0, -offset), m_glyphRun);
+ painter->drawGlyphRun(pos + QPointF(offset, 0), m_glyphRun);
+ painter->drawGlyphRun(pos + QPointF(-offset, 0), m_glyphRun);
break;
case QQuickText::Raised:
painter->setPen(m_styleColor);
- painter->drawGlyphRun(pos + QPointF(0, 1), m_glyphRun);
+ painter->drawGlyphRun(pos + QPointF(0, offset), m_glyphRun);
break;
case QQuickText::Sunken:
painter->setPen(m_styleColor);
- painter->drawGlyphRun(pos + QPointF(0, -1), m_glyphRun);
+ painter->drawGlyphRun(pos + QPointF(0, -offset), m_glyphRun);
break;
}