From 1bdd2553b744de425b5952d2e9ab31753cd5b110 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 6 May 2010 11:15:31 +0200 Subject: 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 --- src/gui/painting/qpainter.cpp | 9 +++++++-- 1 file 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