diff options
author | Gilles Debunne <debunne@google.com> | 2011-02-03 14:17:05 -0800 |
---|---|---|
committer | Gilles Debunne <debunne@google.com> | 2011-02-18 16:05:15 -0800 |
commit | f3fa0cdbaea109b114f7facbb5d42de3fc12bbc8 (patch) | |
tree | f77a3e54bb69fb71a230da03e536f305e1884f43 /core/java/android/text/StaticLayout.java | |
parent | e7c943926db892d479ba4a0a9b9b314db8abaaee (diff) | |
download | frameworks_base-f3fa0cdbaea109b114f7facbb5d42de3fc12bbc8.zip frameworks_base-f3fa0cdbaea109b114f7facbb5d42de3fc12bbc8.tar.gz frameworks_base-f3fa0cdbaea109b114f7facbb5d42de3fc12bbc8.tar.bz2 |
Bugfixes in StaticLayout.
Bug 3422121
With ellipsize, lines starting with a very long word that does not
fit inside the width were simply ignored. Cut the long word instead.
start - widthStart index offset shift in BiDi.
The original ellipsize-end patch that added '...' after the last
word on end-ellipsized lines has been punted in favor of a true
ellipsize support in I.
I believe the StaticLayout calculateEllipsise is a no-op since textwidth <= avail
by construction: fitWidth and okwidth are < outerWidth. The only exception is the
paraEnd != here case in generate (when not a single character fits in width).
This case is exercised by StaticLayoutTest in cts (width of 8 pixels) and revealed
an offset error in widstart.
All in all, it looks like this code was probably never really tested. I tried some
typical text configuration to make sure these changes improved the situation.
Change-Id: Ibee410bd7db453abf93e10e8beb844eae998922c
Diffstat (limited to 'core/java/android/text/StaticLayout.java')
-rw-r--r-- | core/java/android/text/StaticLayout.java | 70 |
1 files changed, 9 insertions, 61 deletions
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index a4546f0..a826a97 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -355,8 +355,6 @@ public class StaticLayout extends Layout { okBottom = fitBottom; } } else { - if (ellipsize != null) { - // Break only at spaces using ok indexes. if (ok != here) { // Log.e("text", "output ok " + here + " to " +ok); @@ -372,43 +370,7 @@ public class StaticLayout extends Layout { chooseHtv, fm, hasTabOrEmoji, needMultiply, paraStart, chdirs, dir, easy, ok == bufEnd, includepad, trackpad, - chs, widths, here - paraStart, - ellipsize, ellipsizedWidth, okWidth, - paint); - - here = ok; - } else { - // Act like it fit even though it didn't. - - fitWidth = w; - here = fit = j + 1; - - if (fmTop < fitTop) - fitTop = fmTop; - if (fmAscent < fitAscent) - fitAscent = fmAscent; - if (fmDescent > fitDescent) - fitDescent = fmDescent; - if (fmBottom > fitBottom) - fitBottom = fmBottom; - } - } else { - if (ok != here) { - // Log.e("text", "output ok " + here + " to " +ok); - - while (ok < spanEnd && chs[ok - paraStart] == CHAR_SPACE) { - ok++; - } - - v = out(source, - here, ok, - okAscent, okDescent, okTop, okBottom, - v, - spacingmult, spacingadd, chooseHt, - chooseHtv, fm, hasTabOrEmoji, - needMultiply, paraStart, chdirs, dir, easy, - ok == bufEnd, includepad, trackpad, - chs, widths, here - paraStart, + chs, widths, paraStart, ellipsize, ellipsizedWidth, okWidth, paint); @@ -424,7 +386,7 @@ public class StaticLayout extends Layout { chooseHtv, fm, hasTabOrEmoji, needMultiply, paraStart, chdirs, dir, easy, fit == bufEnd, includepad, trackpad, - chs, widths, here - paraStart, + chs, widths, paraStart, ellipsize, ellipsizedWidth, fitWidth, paint); @@ -446,13 +408,12 @@ public class StaticLayout extends Layout { needMultiply, paraStart, chdirs, dir, easy, here + 1 == bufEnd, includepad, trackpad, - chs, widths, here - paraStart, + chs, widths, paraStart, ellipsize, ellipsizedWidth, widths[here - paraStart], paint); here = here + 1; } - } if (here < spanStart) { // didn't output all the text for this span @@ -495,7 +456,7 @@ public class StaticLayout extends Layout { chooseHtv, fm, hasTabOrEmoji, needMultiply, paraStart, chdirs, dir, easy, paraEnd == bufEnd, includepad, trackpad, - chs, widths, here - paraStart, + chs, widths, paraStart, ellipsize, ellipsizedWidth, w, paint); } @@ -614,19 +575,6 @@ public class StaticLayout extends Layout { return false; } -/* - private static void dump(byte[] data, int count, String label) { - if (false) { - System.out.print(label); - - for (int i = 0; i < count; i++) - System.out.print(" " + data[i]); - - System.out.println(); - } - } -*/ - private int out(CharSequence text, int start, int end, int above, int below, int top, int bottom, int v, float spacingmult, float spacingadd, @@ -729,8 +677,8 @@ public class StaticLayout extends Layout { if (easy) { mLineDirections[j] = linedirs; } else { - mLineDirections[j] = AndroidBidi.directions(dir, chdirs, widthStart, chs, - widthStart, end - start); + mLineDirections[j] = AndroidBidi.directions(dir, chdirs, start - widthStart, chs, + start - widthStart, end - start); } // If ellipsize is in marquee mode, do not apply ellipsis on the first line @@ -869,7 +817,7 @@ public class StaticLayout extends Layout { @Override public int getLineDescent(int line) { int descent = mLines[mColumns * line + DESCENT]; - if (mMaximumVisibleLineCount > 0 && line >= mMaximumVisibleLineCount - 1 && + if (mMaximumVisibleLineCount > 0 && line >= mMaximumVisibleLineCount - 1 && // -1 intended line != mLineCount) { descent += getBottomPadding(); } @@ -933,8 +881,8 @@ public class StaticLayout extends Layout { * @hide */ @Override - public void setMaximumVisibleLineCount(int line) { - mMaximumVisibleLineCount = line; + public void setMaximumVisibleLineCount(int lineCount) { + mMaximumVisibleLineCount = lineCount; } private int mLineCount; |