DO NOT MERGE Fix line breaking for clusters in narrow views

Clusters were broken incorrectly when in narrow views (when the width of
the cluster was greater than the width of a view). Also, out() calls
were modifying fm, so clusters that were too wide were not positioned
correctly.

Change-Id: I521f8dc6338f5f1de6858af3f0c0bd320aa46bc0
(cherry picked from commit 162713dd0b72af79c1b2286985f7e79f043cd915)
This commit is contained in:
Anish Athalye
2014-06-27 14:37:53 -07:00
committed by Alan Lau
parent a0bb44efe9
commit a28e476499

View File

@ -379,7 +379,7 @@ public class StaticLayout extends Layout {
okBottom = fitBottom;
}
} else {
final boolean moreChars = (j + 1 < spanEnd);
final boolean moreChars;
int endPos;
int above, below, top, bottom;
float currentTextWidth;
@ -391,6 +391,7 @@ public class StaticLayout extends Layout {
top = okTop;
bottom = okBottom;
currentTextWidth = okWidth;
moreChars = (j + 1 < spanEnd);
} else if (fit != here) {
endPos = fit;
above = fitAscent;
@ -398,13 +399,21 @@ public class StaticLayout extends Layout {
top = fitTop;
bottom = fitBottom;
currentTextWidth = fitWidth;
moreChars = (j + 1 < spanEnd);
} else {
// must make progress, so take next character
endPos = here + 1;
above = fm.ascent;
below = fm.descent;
top = fm.top;
bottom = fm.bottom;
// but to deal properly with clusters
// take all zero width characters following that
while (endPos < spanEnd && widths[endPos - paraStart] == 0) {
endPos++;
}
above = fmAscent;
below = fmDescent;
top = fmTop;
bottom = fmBottom;
currentTextWidth = widths[here - paraStart];
moreChars = (endPos < spanEnd);
}
v = out(source, here, endPos,