Skip to content

Commit 42ef515

Browse files
committed
Fix for bug: Gmail (and other places): cursor placed on top of letter
This patch fixes bug 7346656. In this particular case, the text line in the EditText was split into multiple spans, with the boundary between the "r" and "," in "r,". These were being drawn as two separate runs, but measured as a single run, leading to inconsistent measurements because this is a kern pair in Roboto. The fix is to eliminate the special-case code for measuring. This will actually improve efficiency, as the value computed in one pass is now more likely to be reused in another. Change-Id: I04142a0ec98f280fc1027c7cbdbf903e3096f8e4
1 parent cc0106c commit 42ef515

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

core/java/android/text/TextLine.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -939,27 +939,22 @@ private float handleRun(int start, int measureLimit,
939939
continue;
940940
}
941941

942-
if (c == null) {
943-
x += handleText(wp, i, mlimit, i, inext, runIsRtl, c, x, top,
944-
y, bottom, fmi, needWidth || mlimit < measureLimit);
945-
} else {
946-
for (int j = i, jnext; j < mlimit; j = jnext) {
947-
jnext = mCharacterStyleSpanSet.getNextTransition(mStart + j, mStart + mlimit) -
948-
mStart;
949-
950-
wp.set(mPaint);
951-
for (int k = 0; k < mCharacterStyleSpanSet.numberOfSpans; k++) {
952-
// Intentionally using >= and <= as explained above
953-
if ((mCharacterStyleSpanSet.spanStarts[k] >= mStart + jnext) ||
954-
(mCharacterStyleSpanSet.spanEnds[k] <= mStart + j)) continue;
955-
956-
CharacterStyle span = mCharacterStyleSpanSet.spans[k];
957-
span.updateDrawState(wp);
958-
}
942+
for (int j = i, jnext; j < mlimit; j = jnext) {
943+
jnext = mCharacterStyleSpanSet.getNextTransition(mStart + j, mStart + mlimit) -
944+
mStart;
945+
946+
wp.set(mPaint);
947+
for (int k = 0; k < mCharacterStyleSpanSet.numberOfSpans; k++) {
948+
// Intentionally using >= and <= as explained above
949+
if ((mCharacterStyleSpanSet.spanStarts[k] >= mStart + jnext) ||
950+
(mCharacterStyleSpanSet.spanEnds[k] <= mStart + j)) continue;
959951

960-
x += handleText(wp, j, jnext, i, inext, runIsRtl, c, x,
961-
top, y, bottom, fmi, needWidth || jnext < measureLimit);
952+
CharacterStyle span = mCharacterStyleSpanSet.spans[k];
953+
span.updateDrawState(wp);
962954
}
955+
956+
x += handleText(wp, j, jnext, i, inext, runIsRtl, c, x,
957+
top, y, bottom, fmi, needWidth || jnext < measureLimit);
963958
}
964959
}
965960

0 commit comments

Comments
 (0)