diff options
author | Joshua Grauman <jnfo@grauman.com> | 2013-10-26 15:25:03 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-30 09:44:07 +0100 |
commit | f18fd0450c2490bbbe1f59a99580139815a82e2f (patch) | |
tree | f14a17d05ddb70245ee389bd28c77c0bece508af /src/gui | |
parent | 43002e25723e923f035f1507eb5b66312ab708cd (diff) |
Fix finding cursor position in words with accents
In positionInLigature() we were mixing indexes into the script item with
indexes into the entire string. The getClusterLength() function would expect
an attributes array for the current script item and it thus needs to be
adjusted by si->position. In addition, when looking for the next grapheme
boundary, we were comparing pos (which indexed the string) with end (which
indexed the script item). This has also now been fixed by adjusting for
si->position as well.
Task-number: QTBUG-30123
Change-Id: Id02e2eddcc5b7888eacb34bd1e39cc6911880ca1
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextengine.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 2b0f9ffeb6..6345ed7682 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -3100,7 +3100,7 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end, glyph_pos--; } - const QCharAttributes *attrs = attributes(); + const QCharAttributes *attrs = attributes() + si->position; logClusters = this->logClusters(si); clusterLength = getClusterLength(logClusters, attrs, 0, end, glyph_pos, &clusterStart); @@ -3117,11 +3117,11 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end, int closestItem = dist > (perItemWidth / 2) ? n + 1 : n; if (cursorOnCharacter && closestItem > 0) closestItem--; - int pos = si->position + clusterStart + closestItem; + int pos = clusterStart + closestItem; // Jump to the next grapheme boundary while (pos < end && !attrs[pos].graphemeBoundary) pos++; - return pos; + return si->position + pos; } return si->position + end; } |