diff options
author | Vladimir Belyavsky <belyavskyv@gmail.com> | 2023-02-17 19:31:50 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-22 19:39:45 +0000 |
commit | b0d395e27c7bbc6ee34a12ec07426581e013be08 (patch) | |
tree | e3398db963b06b52ad174d5f29dc5ca5fcf990d8 /src/gui | |
parent | 9e39458a0c820d39567d11d3f2559d84e7dae1f2 (diff) | |
download | qtbase-b0d395e27c7bbc6ee34a12ec07426581e013be08.tar.gz |
Text: fix Soft hyphen rendering in QTextLayout::glyphRuns()
When calculating the position offset of QGlyphRuns, either
when fetching substrings or when applying fallback fonts,
we would include the advances of non-printable glyphs,
such as the soft hyphen. This was an oversight, and the
other code which calculates the advance (like in
QFontEngine::getGlyphPositions()) does this correctly. We
apply the same logic as there and only include the advance
if the dontPrint flag is unset.
[ChangeLog][QtGui][Text] Fixed an issue where spaces would
sometimes be shown in soft hyphen positions in a string.
Fixes: QTBUG-46990
Fixes: QTBUG-62620
Fixes: QTBUG-67038
Fixes: QTBUG-102483
Change-Id: I4e583fb74f7a51424f14917d7cc0894beefec48b
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 0fe6f818d23495f07100f82c12e4232b8e56daf4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 752c6180f8..486e04544a 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2492,14 +2492,18 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, // when we're breaking a RTL script item, since the expected position passed into // getGlyphPositions() is the left-most edge of the left-most glyph in an RTL run. if (relativeFrom != (iterator.itemStart - si.position) && !rtl) { - for (int i=itemGlyphsStart; i<glyphsStart; ++i) { - QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6); - pos.rx() += (glyphLayout.advances[i] + justification).toReal(); + for (int i = itemGlyphsStart; i < glyphsStart; ++i) { + if (!glyphLayout.attributes[i].dontPrint) { + QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6); + pos.rx() += (glyphLayout.advances[i] + justification).toReal(); + } } } else if (relativeTo != (iterator.itemEnd - si.position - 1) && rtl) { - for (int i=itemGlyphsEnd; i>glyphsEnd; --i) { - QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6); - pos.rx() += (glyphLayout.advances[i] + justification).toReal(); + for (int i = itemGlyphsEnd; i > glyphsEnd; --i) { + if (!glyphLayout.attributes[i].dontPrint) { + QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6); + pos.rx() += (glyphLayout.advances[i] + justification).toReal(); + } } } @@ -2554,8 +2558,10 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, glyphRuns.append(glyphRun); } for (int i = 0; i < subLayout.numGlyphs; ++i) { - QFixed justification = QFixed::fromFixed(subLayout.justifications[i].space_18d6); - pos.rx() += (subLayout.advances[i] + justification).toReal(); + if (!subLayout.attributes[i].dontPrint) { + QFixed justification = QFixed::fromFixed(subLayout.justifications[i].space_18d6); + pos.rx() += (subLayout.advances[i] + justification).toReal(); + } } if (rtl) |