summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Adams <chris.adams@jollamobile.com>2012-11-19 04:05:16 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-01 00:54:33 (GMT)
commit607956f6f76de283b22f431d474fbf43de6d2db7 (patch)
tree85b40489a2bb3b22445c345ea0baf825ef20eb44
parent331b7addff6fb8b152eafb893a51550a532837d2 (diff)
downloadQt-607956f6f76de283b22f431d474fbf43de6d2db7.zip
Qt-607956f6f76de283b22f431d474fbf43de6d2db7.tar.gz
Qt-607956f6f76de283b22f431d474fbf43de6d2db7.tar.bz2
Ensure QDeclarativeTextLayout uses the correct pen
Backport of commit: 3a0cec6525be6bf843c597c19693785e2c893ee9 with change id: I6bcc43fbcf7fb2c680959d27b1422364ebb473ae from qt5/qtquick1 to qt4. Task-number: QTBUG-28135 Change-Id: I0d84dcb87b03d7b64797c4d633ae0ae8e6bfcb1e Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextlayout.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
index eac69d6..0c0d1c8 100644
--- a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
@@ -235,7 +235,10 @@ class DrawTextItemDevice: public QPaintDevice
struct InertTextPainter {
InertTextPainter()
- : device(true, true), painter(&device) {}
+ : device(true, true), painter(&device)
+ {
+ painter.setPen(QPen(QColor())); // explicitly invalid color.
+ }
DrawTextItemDevice device;
QPainter painter;
@@ -371,11 +374,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);