diff options
author | Vladimir Belyavsky <belyavskyv@gmail.com> | 2022-09-26 19:32:50 +0300 |
---|---|---|
committer | Vladimir Belyavsky <belyavskyv@gmail.com> | 2022-10-06 08:43:11 +0000 |
commit | 4945fd93f13d2fc34adf260fd0e0325d0794f3f7 (patch) | |
tree | a6e96dd90f56a16ae77a5f75986bd295008716cf /src/gui/text | |
parent | fd28c970750e0570bf1d107922fa29eae161e93d (diff) |
QTextLayout: fix maximumWidth() for a text containing spaces
When laying out a text and calculating maxWidth, we must _always_ take
into account the accumulated width of spaces (lbh.spaceData.textWidth)
regardless of wrapMode, other text content, spaces position, etc.
Fixes: QTBUG-106947
Change-Id: I2ac9af92ed7dd07c1e040bfcf83949a358d1c9c9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 32fac09f33..286722fc4c 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1976,7 +1976,6 @@ void QTextLine::layout_helper(int maxGlyphs) } if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) { - lbh.spaceData.textWidth = line.width; // ignore spaces that fall out of the line. goto found; } } else { @@ -2162,12 +2161,9 @@ found: eng->maxWidth = qMax(eng->maxWidth, line.textWidth); } else { eng->minWidth = qMax(eng->minWidth, lbh.minw); - eng->maxWidth += line.textWidth; + eng->maxWidth += line.textWidth + lbh.spaceData.textWidth; } - if (line.textWidth > 0 && item < eng->layoutData->items.size()) - eng->maxWidth += lbh.spaceData.textWidth; - line.textWidth += trailingSpace; if (lbh.spaceData.length) { line.trailingSpaces = lbh.spaceData.length; |