Skip to content

Commit 7c3255f

Browse files
committed
Fix bug 7054190 line breaks at inappropriate places
We were doing line breaks after punctuation as long as they weren't surrounded by digits. This is a misinterpretation of the Unicode line breaking algorithm. Punctuation (class IS) is not hugely different than the default classes (NU and AL) - there are breaks after punctuation that are allowed (for example, followed by an open parenthesis), but we're not implementing the algorithm with anything near that level of fidelity. The long term fix is to really implement the algorithm. In the shorter term, the easiest thing to do is to remove the special case altogether. Change-Id: Ic4dc3216c2a4191fbb7cfa06e9dc038d1a56398c
1 parent 1552586 commit 7c3255f

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

core/java/android/text/StaticLayout.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,6 @@ public StaticLayout(CharSequence source, int bufstart, int bufend,
357357

358358
// From the Unicode Line Breaking Algorithm (at least approximately)
359359
boolean isLineBreak = isSpaceOrTab ||
360-
// .,:; are class IS breakpoints, except when adjacent to digits
361-
((c == CHAR_DOT || c == CHAR_COMMA ||
362-
c == CHAR_COLON || c == CHAR_SEMICOLON) &&
363-
(j - 1 < here || !Character.isDigit(chs[j - 1 - paraStart])) &&
364-
(j + 1 >= spanEnd || !Character.isDigit(chs[j + 1 - paraStart]))) ||
365360
// / is class SY and - is class HY, except when followed by a digit
366361
((c == CHAR_SLASH || c == CHAR_HYPHEN) &&
367362
(j + 1 >= spanEnd || !Character.isDigit(chs[j + 1 - paraStart]))) ||
@@ -959,10 +954,6 @@ void finish() {
959954
private static final char CHAR_NEW_LINE = '\n';
960955
private static final char CHAR_TAB = '\t';
961956
private static final char CHAR_SPACE = ' ';
962-
private static final char CHAR_DOT = '.';
963-
private static final char CHAR_COMMA = ',';
964-
private static final char CHAR_COLON = ':';
965-
private static final char CHAR_SEMICOLON = ';';
966957
private static final char CHAR_SLASH = '/';
967958
private static final char CHAR_HYPHEN = '-';
968959

0 commit comments

Comments
 (0)