summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextlayout.cpp
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-05-19 10:29:49 +0200
committerJiang Jiang <jiang.jiang@nokia.com>2011-05-23 15:55:03 +0200
commite5f38bb543696813a70995c90cd5450602c0356c (patch)
tree05390f3a3507cc999e05c7526333fd9c5e7f879b /src/gui/text/qtextlayout.cpp
parentd80949eee06ff464d58bd97a6c89bae7e961f3c8 (diff)
Support placing cursor in ligature with mouse or touch
We need to find out the closest element in the ligature to the point we clicked (or tapped), currently we do this by dividing the width of that ligature glyph evenly by the number of characters it covered. We only support Common and Greek script at this point, ligatures in other scripts are still handled as a whole. Task-number: QTBUG-19260 Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r--src/gui/text/qtextlayout.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index de4ca4ff05..5857f33df4 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2622,6 +2622,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
}
int glyph_pos = -1;
+ QFixed edge;
// has to be inside run
if (cpos == QTextLine::CursorOnCharacter) {
if (si.analysis.bidiLevel % 2) {
@@ -2632,6 +2633,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
if (pos < x)
break;
glyph_pos = gs;
+ edge = pos;
break;
}
pos -= glyphs.effectiveAdvance(gs);
@@ -2644,6 +2646,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
if (pos > x)
break;
glyph_pos = gs;
+ edge = pos;
}
pos += glyphs.effectiveAdvance(gs);
++gs;
@@ -2672,15 +2675,10 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
}
}
if (qAbs(x-pos) < dist)
- return si.position + end;
+ return eng->positionInLigature(&si, end, x, pos, -1);
}
Q_ASSERT(glyph_pos != -1);
- int j;
- for (j = 0; j < eng->length(item); ++j)
- if (logClusters[j] == glyph_pos)
- break;
-// qDebug("at pos %d (in run: %d)", si.position + j, j);
- return si.position + j;
+ return eng->positionInLigature(&si, end, x, edge, glyph_pos);
}
}
// right of last item