diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-03-26 09:43:40 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-03-26 10:46:46 (GMT) |
commit | 47472906fd00e0eff820870330d481c4229ee285 (patch) | |
tree | 2543c9449bca6b7148a609567b9aa16f6d910f3d /src/gui/text | |
parent | 075918e796b98155b81871f15bf2eb266a783561 (diff) | |
download | Qt-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.cpp | 6 |
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(); |