From f18fd0450c2490bbbe1f59a99580139815a82e2f Mon Sep 17 00:00:00 2001 From: Joshua Grauman Date: Sat, 26 Oct 2013 15:25:03 -0700 Subject: 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 --- src/gui/text/qtextengine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui') 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; } -- cgit v1.2.3