Skip to content

Commit 8d44fff

Browse files
author
Fabrice Di Meglio
committed
Fix bug #6661824 Hebrew Text can be clipped
- use the correct ellipsis char in both measurement and rendered string Change-Id: Ia00285fc16da528f18702719026503b5d0610642
1 parent 68cefd2 commit 8d44fff

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

core/java/android/text/Layout.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,8 +1695,14 @@ protected final boolean isSpanned() {
16951695
return text.getSpans(start, end, type);
16961696
}
16971697

1698+
private char getEllipsisChar(TextUtils.TruncateAt method) {
1699+
return (method == TextUtils.TruncateAt.END_SMALL) ?
1700+
ELLIPSIS_TWO_DOTS[0] :
1701+
ELLIPSIS_NORMAL[0];
1702+
}
1703+
16981704
private void ellipsize(int start, int end, int line,
1699-
char[] dest, int destoff) {
1705+
char[] dest, int destoff, TextUtils.TruncateAt method) {
17001706
int ellipsisCount = getEllipsisCount(line);
17011707

17021708
if (ellipsisCount == 0) {
@@ -1710,7 +1716,7 @@ private void ellipsize(int start, int end, int line,
17101716
char c;
17111717

17121718
if (i == ellipsisStart) {
1713-
c = '\u2026'; // ellipsis
1719+
c = getEllipsisChar(method); // ellipsis
17141720
} else {
17151721
c = '\uFEFF'; // 0-width space
17161722
}
@@ -1784,7 +1790,7 @@ public void getChars(int start, int end, char[] dest, int destoff) {
17841790
TextUtils.getChars(mText, start, end, dest, destoff);
17851791

17861792
for (int i = line1; i <= line2; i++) {
1787-
mLayout.ellipsize(start, end, i, dest, destoff);
1793+
mLayout.ellipsize(start, end, i, dest, destoff, mMethod);
17881794
}
17891795
}
17901796

@@ -1889,4 +1895,6 @@ public enum Alignment {
18891895
/* package */ static final Directions DIRS_ALL_RIGHT_TO_LEFT =
18901896
new Directions(new int[] { 0, RUN_LENGTH_MASK | RUN_RTL_FLAG });
18911897

1898+
/* package */ static final char[] ELLIPSIS_NORMAL = { '\u2026' }; // this is "..."
1899+
/* package */ static final char[] ELLIPSIS_TWO_DOTS = { '\u2025' }; // this is ".."
18921900
}

core/java/android/text/StaticLayout.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,8 @@ private void calculateEllipsis(int lineStart, int lineEnd,
745745
}
746746

747747
float ellipsisWidth = paint.measureText(
748-
(where == TextUtils.TruncateAt.END_SMALL) ? ELLIPSIS_TWO_DOTS : ELLIPSIS_NORMAL);
748+
(where == TextUtils.TruncateAt.END_SMALL) ?
749+
ELLIPSIS_TWO_DOTS : ELLIPSIS_NORMAL, 0, 1);
749750
int ellipsisStart = 0;
750751
int ellipsisCount = 0;
751752
int len = lineEnd - lineStart;
@@ -985,9 +986,6 @@ void finish() {
985986

986987
private static final double EXTRA_ROUNDING = 0.5;
987988

988-
private static final String ELLIPSIS_NORMAL = "\u2026"; // this is "..."
989-
private static final String ELLIPSIS_TWO_DOTS = "\u2025"; // this is ".."
990-
991989
private static final int CHAR_FIRST_HIGH_SURROGATE = 0xD800;
992990
private static final int CHAR_LAST_LOW_SURROGATE = 0xDFFF;
993991

0 commit comments

Comments
 (0)