summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qpainter.cpp21
-rw-r--r--src/gui/text/qstatictext.cpp2
2 files changed, 22 insertions, 1 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 1057893..83f66e2 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5728,11 +5728,30 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static
if (!d->engine || staticText.isEmpty() || pen().style() == Qt::NoPen)
return;
- const QStaticTextPrivate *staticText_d = QStaticTextPrivate::get(&staticText);
+ const QStaticTextPrivate *staticText_d = QStaticTextPrivate::get(&staticText);
+ bool restoreWhenFinished = false;
+
+ if (staticText_d->size.isValid()) {
+ setClipRect(QRectF(position, staticText_d->size));
+
+ save();
+ restoreWhenFinished = true;
+ }
+
+ if (font() != staticText_d->font) {
+ setFont(staticText_d->font);
+
+ save();
+ restoreWhenFinished = true;
+ }
+
for (int i=0; i<staticText_d->itemCount; ++i) {
const QTextItemInt &gf = staticText_d->items[i];
d->engine->drawTextItem(staticText_d->itemPositions[i] + position, gf);
}
+
+ if (restoreWhenFinished)
+ restore();
}
/*!
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 5a8fd9b..70e1c47 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -455,6 +455,7 @@ void QStaticTextPrivate::init()
DrawTextItemDevice counterDevice;
{
QPainter painter(&counterDevice);
+ painter.setFont(font);
if (size.isValid())
painter.drawText(QRectF(QPointF(0, 0), size), text);
@@ -475,6 +476,7 @@ void QStaticTextPrivate::init()
glyphLayoutMemory, logClusterMemory);
{
QPainter painter(&recorderDevice);
+ painter.setFont(font);
if (size.isValid())
painter.drawText(QRectF(QPointF(0, 0), size), text);