diff options
author | Gilles Debunne <debunne@google.com> | 2011-03-08 14:22:34 -0800 |
---|---|---|
committer | Gilles Debunne <debunne@google.com> | 2011-03-09 17:17:40 -0800 |
commit | 1e3ac18e7ad03e02819f3e1a89d6a80a2bb7645f (patch) | |
tree | 90212407ae4e340dd01024d93aa8de4a057adeea /core/java/android/text/TextLine.java | |
parent | e888b25fb54d2079a784da2b72a950aaafb844dc (diff) | |
download | frameworks_base-1e3ac18e7ad03e02819f3e1a89d6a80a2bb7645f.zip frameworks_base-1e3ac18e7ad03e02819f3e1a89d6a80a2bb7645f.tar.gz frameworks_base-1e3ac18e7ad03e02819f3e1a89d6a80a2bb7645f.tar.bz2 |
Empty spans are not considered in text layout/rendering process.
Bug http://code.google.com/p/android/issues/detail?id=14786
Empty spans are affecting the text before and after them. See the
comment in TextUtils.removeEmptySpans for details.
Change-Id: I40376c32fd56a17efde6219f9b2593e4b4ab1ba1
Diffstat (limited to 'core/java/android/text/TextLine.java')
-rw-r--r-- | core/java/android/text/TextLine.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index 90279d1..1b7f2f3 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -127,12 +127,12 @@ class TextLine { boolean hasReplacement = false; if (text instanceof Spanned) { mSpanned = (Spanned) text; - hasReplacement = mSpanned.getSpans(start, limit, - ReplacementSpan.class).length > 0; + ReplacementSpan[] spans = mSpanned.getSpans(start, limit, ReplacementSpan.class); + spans = TextUtils.removeEmptySpans(spans, mSpanned, ReplacementSpan.class); + hasReplacement = spans.length > 0; } - mCharsValid = hasReplacement || hasTabs || - directions != Layout.DIRS_ALL_LEFT_TO_RIGHT; + mCharsValid = hasReplacement || hasTabs || directions != Layout.DIRS_ALL_LEFT_TO_RIGHT; if (mCharsValid) { if (mChars == null || mChars.length < mLen) { @@ -147,10 +147,11 @@ class TextLine { // zero-width characters. char[] chars = mChars; for (int i = start, inext; i < limit; i = inext) { - inext = mSpanned.nextSpanTransition(i, limit, - ReplacementSpan.class); - if (mSpanned.getSpans(i, inext, ReplacementSpan.class) - .length > 0) { // transition into a span + inext = mSpanned.nextSpanTransition(i, limit, ReplacementSpan.class); + ReplacementSpan[] spans = mSpanned.getSpans(i, inext, ReplacementSpan.class); + spans = TextUtils.removeEmptySpans(spans, mSpanned, ReplacementSpan.class); + if (spans.length > 0) { + // transition into a span chars[i - start] = '\ufffc'; for (int j = i - start + 1, e = inext - start; j < e; ++j) { chars[j] = '\ufeff'; // used as ZWNBS, marks positions to skip @@ -197,7 +198,6 @@ class TextLine { boolean runIsRtl = (runs[i+1] & Layout.RUN_RTL_FLAG) != 0; int segstart = runStart; - char[] chars = mChars; for (int j = mHasTabs ? runStart : runLimit; j <= runLimit; j++) { int codept = 0; Bitmap bm = null; @@ -629,6 +629,7 @@ class TextLine { MetricAffectingSpan[] spans = mSpanned.getSpans(mStart + spanStart, mStart + spanLimit, MetricAffectingSpan.class); + spans = TextUtils.removeEmptySpans(spans, mSpanned, MetricAffectingSpan.class); if (spans.length > 0) { ReplacementSpan replacement = null; @@ -835,6 +836,7 @@ class TextLine { mlimit = inext < measureLimit ? inext : measureLimit; MetricAffectingSpan[] spans = mSpanned.getSpans(mStart + i, mStart + mlimit, MetricAffectingSpan.class); + spans = TextUtils.removeEmptySpans(spans, mSpanned, MetricAffectingSpan.class); if (spans.length > 0) { ReplacementSpan replacement = null; @@ -868,6 +870,7 @@ class TextLine { CharacterStyle[] spans = mSpanned.getSpans(mStart + j, mStart + jnext, CharacterStyle.class); + spans = TextUtils.removeEmptySpans(spans, mSpanned, CharacterStyle.class); wp.set(mPaint); for (int k = 0; k < spans.length; k++) { |