From 49f715f9f0b777d47de89f600199fe297c89a9c6 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Wed, 13 Apr 2016 11:56:50 +0200 Subject: 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 --- .../adaptations/software/qsgsoftwareglyphnode.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp') 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; } -- cgit v1.2.3