summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-06 09:15:31 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-06 09:15:31 (GMT)
commit1bdd2553b744de425b5952d2e9ab31753cd5b110 (patch)
treefb9ffcd026544465ada6dc6ff8558d26b9c83186 /src
parent2cc7a785eff228f414faa09ff882c2f0a2092cfd (diff)
downloadQt-1bdd2553b744de425b5952d2e9ab31753cd5b110.zip
Qt-1bdd2553b744de425b5952d2e9ab31753cd5b110.tar.gz
Qt-1bdd2553b744de425b5952d2e9ab31753cd5b110.tar.bz2
Recalculate script item widths when forcing justification
When going through the special WebKit code path for text drawing and forcing justification for text, we would set the justification in the text engine, but never actually update the widths of the script items. Since the width of the script item is used to position the text, the text would be drawn with the correct justification, but the position would be set based on the non-justified text width. The result was overlapping text whenever the script of the text changed. The fix goes through the justified glyphs and sets the width and position based on the new effective advance. Task-number: QTBUG-10421 Reviewed-by: Simon Hausmann
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpainter.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 075c457..96981af 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5773,12 +5773,17 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif
gf.glyphs = engine.shapedGlyphs(&si);
gf.chars = engine.layoutData->string.unicode() + si.position;
gf.num_chars = engine.length(item);
- gf.width = si.width;
+ if (engine.forceJustification) {
+ for (int j=0; j<gf.glyphs.numGlyphs; ++j)
+ gf.width += gf.glyphs.effectiveAdvance(j);
+ } else {
+ gf.width = si.width;
+ }
gf.logClusters = engine.logClusters(&si);
drawTextItem(QPointF(x.toReal(), p.y()), gf);
- x += si.width;
+ x += gf.width;
}
}