summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-26 09:43:40 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-26 10:46:46 (GMT)
commit47472906fd00e0eff820870330d481c4229ee285 (patch)
tree2543c9449bca6b7148a609567b9aa16f6d910f3d /src/gui/text
parent075918e796b98155b81871f15bf2eb266a783561 (diff)
downloadQt-47472906fd00e0eff820870330d481c4229ee285.zip
Qt-47472906fd00e0eff820870330d481c4229ee285.tar.gz
Qt-47472906fd00e0eff820870330d481c4229ee285.tar.bz2
Synchronize rich text and plain text code paths in QStaticText
Drawing a string as plain text and rich text should have identical results unless special formatting information is added in the html. This means we should not have any implicit margin on the QTextDocument used to paint the text, and we should make up for the fact that the drawStaticText() call currently takes the position of the baseline and QTextDocument::drawContents() takes the top-left corner. Reviewed-by: Gunnar
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qstatictext.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 1fabf12..d685cd9 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -553,12 +553,14 @@ void QStaticTextPrivate::paintText(const QPointF &pos, QPainter *p)
} else {
QTextDocument document;
document.setDefaultFont(font);
+ document.setDocumentMargin(0.0);
document.setHtml(text);
- QRectF rect = maximumSize.isValid() ? QRectF(pos, maximumSize) : QRectF();
+ QPointF adjustedPos = pos - QPointF(0, QFontMetricsF(font).ascent());
+ QRectF rect = maximumSize.isValid() ? QRectF(adjustedPos, maximumSize) : QRectF();
document.adjustSize();
p->save();
- p->translate(pos);
+ p->translate(adjustedPos);
document.drawContents(p, rect);
p->restore();
actualSize = document.size();