diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2009-09-22 12:12:25 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2009-09-22 12:13:31 (GMT) |
commit | 0d830dc5b0716bdb4fa7130f724ba5c9593411fa (patch) | |
tree | d409e211a8aa3e339946b290f0ad0cf6718c4358 /src/gui/text | |
parent | 6e6dcc1575188751a730cdc3376b036b3df1f08e (diff) | |
download | Qt-0d830dc5b0716bdb4fa7130f724ba5c9593411fa.zip Qt-0d830dc5b0716bdb4fa7130f724ba5c9593411fa.tar.gz Qt-0d830dc5b0716bdb4fa7130f724ba5c9593411fa.tar.bz2 |
Fix breaking on fixed column width when text has tabs
When a text in QTextLayout contained tabs, these would be counted as
single glyphs when breaking the text on a fixed number of columns,
rather than the number of characters they span.
The patch calculates the number of characters represented by a tab by
using the average character width of the font engine.
Task-number: QTBUG-4468
Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index f8b0cbc..39a8bb8 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1720,10 +1720,15 @@ void QTextLine::layout_helper(int maxGlyphs) goto found; QFixed x = line.x + line.textWidth + lbh.tmpData.textWidth + lbh.spaceData.textWidth; - lbh.spaceData.textWidth += eng->calculateTabWidth(item, x); + QFixed tabWidth = eng->calculateTabWidth(item, x); + + lbh.spaceData.textWidth += tabWidth; lbh.spaceData.length++; newItem = item + 1; - ++lbh.glyphCount; + + QFixed averageCharWidth = eng->fontEngine(current)->averageCharWidth(); + lbh.glyphCount += qRound(tabWidth / averageCharWidth); + if (lbh.checkFullOtherwiseExtend(line)) goto found; } else if (current.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator) { |