diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-08-14 13:02:22 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2014-08-14 14:24:50 +0300 |
commit | 53a30b4fc02cd522fb15344060565f623a8667ea (patch) | |
tree | f62c2e0c5406ceae9e6629768cd475fa0a7fc81c /softwarecontext | |
parent | c97c5ea5cf3ccc9e4379924d1ac7b9a1735efb6f (diff) |
Added support for the missing text rendering styles
Change-Id: Id1d3d518fbde6f2d8329850c4966b0576b36be36
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'softwarecontext')
-rw-r--r-- | softwarecontext/glyphnode.cpp | 26 | ||||
-rw-r--r-- | softwarecontext/glyphnode.h | 2 |
2 files changed, 27 insertions, 1 deletions
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); } diff --git a/softwarecontext/glyphnode.h b/softwarecontext/glyphnode.h index 71b529cf1b..d34013be5b 100644 --- a/softwarecontext/glyphnode.h +++ b/softwarecontext/glyphnode.h @@ -42,6 +42,8 @@ private: QGlyphRun m_glyphRun; QColor m_color; QSGGeometry m_geometry; + QQuickText::TextStyle m_style; + QColor m_styleColor; }; #endif // GLYPHNODE_H |