Merge "Make ellipsis START and MIDDLE grapheme cluster aware."

This commit is contained in:
Keisuke Kuroyanagi
2016-09-20 08:05:57 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 3 deletions

View File

@@ -279,7 +279,9 @@ class MeasuredText {
if (width < 0.0f) break;
i--;
}
while (i < limit - 1 && mChars[i + 1] == ' ') i++;
while (i < limit - 1 && (mChars[i + 1] == ' ' || w[i + 1] == 0.0f)) {
i++;
}
return limit - i - 1;
}
}

View File

@@ -1029,8 +1029,10 @@ public class StaticLayout extends Layout {
for (i = len; i > 0; i--) {
float w = widths[i - 1 + lineStart - widthStart];
if (w + sum + ellipsisWidth > avail) {
while (i < len && widths[i + lineStart - widthStart] == 0.0f) {
i++;
}
break;
}
@@ -1076,9 +1078,11 @@ public class StaticLayout extends Layout {
float w = widths[right - 1 + lineStart - widthStart];
if (w + rsum > ravail) {
while (right < len && widths[right + lineStart - widthStart] == 0.0f) {
right++;
}
break;
}
rsum += w;
}