Search
SailfishOS Open Build Service
>
Projects
>
home:kaltsi
:
tnhlbug
>
qt
> 0017-Ensure-QDeclarativeTextLayout-uses-the-correct-pen.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File 0017-Ensure-QDeclarativeTextLayout-uses-the-correct-pen.patch of Package qt
From 3eff3b9dd0fbfda8e2823e7b0d12861d5645f196 Mon Sep 17 00:00:00 2001 From: Chris Adams <chris.adams@jollamobile.com> Date: Mon, 19 Nov 2012 14:05:16 +1000 Subject: [PATCH 17/29] Ensure QDeclarativeTextLayout uses the correct pen When a styled text specifies a font region with some color set, QDeclarativeTextLayout used to revert to using a default-constructed (black-colored) pen for text occurring after the </font> tag, rather than the "default" (property-defined) color. This commit ensures that the correct pen is used, by setting the pen of the "inert" painter to be an invalid color rather than a default constructed pen. --- .../graphicsitems/qdeclarativetextlayout.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp index 744e572..e67898d 100644 --- a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp @@ -233,12 +233,21 @@ class DrawTextItemDevice: public QPaintDevice DrawTextItemRecorder *m_paintEngine; }; +class InvalidColorPainter : public QPainter +{ +public: + InvalidColorPainter(QPaintDevice *d) : QPainter(d) + { + setPen(QPen(QColor())); + } +}; + struct InertTextPainter { InertTextPainter() : device(true, true), painter(&device) {} DrawTextItemDevice device; - QPainter painter; + InvalidColorPainter painter; }; } @@ -371,11 +380,19 @@ void QDeclarativeTextLayout::draw(QPainter *painter, const QPointF &p) QPen oldPen = priv->state->pen; QColor currentColor = oldPen.color(); + QColor defaultColor = currentColor; for (int ii = 0; ii < itemCount; ++ii) { QStaticTextItem &item = d->items[ii]; if (item.color.isValid() && currentColor != item.color) { + // up-edge of a <font color="">text</font> tag + // we set the painter pen to the text item's specified color. painter->setPen(item.color); currentColor = item.color; + } else if (!item.color.isValid() && currentColor != defaultColor) { + // down-edge of a <font color="">text</font> tag + // we reset the painter pen back to the default color. + currentColor = defaultColor; + painter->setPen(currentColor); } priv->extended->drawStaticTextItem(&item); -- 1.7.10.3