From 53a30b4fc02cd522fb15344060565f623a8667ea Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 14 Aug 2014 13:02:22 +0200 Subject: Added support for the missing text rendering styles Change-Id: Id1d3d518fbde6f2d8329850c4966b0576b36be36 Reviewed-by: Lars Knoll --- softwarecontext/glyphnode.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'softwarecontext/glyphnode.cpp') diff --git a/softwarecontext/glyphnode.cpp b/softwarecontext/glyphnode.cpp index a30a64599b..8099df03d9 100644 --- a/softwarecontext/glyphnode.cpp +++ b/softwarecontext/glyphnode.cpp @@ -21,6 +21,7 @@ GlyphNode::GlyphNode() : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 0) + , m_style(QQuickText::Normal) { setMaterial((QSGMaterial*)1); setGeometry(&m_geometry); @@ -40,10 +41,12 @@ void GlyphNode::setColor(const QColor &color) void GlyphNode::setStyle(QQuickText::TextStyle style) { + m_style = style; } void GlyphNode::setStyleColor(const QColor &color) { + m_styleColor = color; } QPointF GlyphNode::baseLine() const @@ -61,6 +64,27 @@ void GlyphNode::update() void GlyphNode::paint(QPainter *painter) { + QPointF pos = m_position - QPointF(0, m_glyphRun.rawFont().ascent()); + + 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); + break; + case QQuickText::Raised: + painter->setPen(m_styleColor); + painter->drawGlyphRun(pos + QPointF(0, 1), m_glyphRun); + break; + case QQuickText::Sunken: + painter->setPen(m_styleColor); + painter->drawGlyphRun(pos + QPointF(0, -1), m_glyphRun); + break; + } + painter->setPen(m_color); - painter->drawGlyphRun(m_position - QPointF(0, m_glyphRun.rawFont().ascent()), m_glyphRun); + painter->drawGlyphRun(pos, m_glyphRun); } -- cgit v1.2.3