diff options
| author | Fabrice Di Meglio <fdimeglio@google.com> | 2011-09-22 18:49:43 -0700 |
|---|---|---|
| committer | Fabrice Di Meglio <fdimeglio@google.com> | 2011-09-23 13:40:58 -0700 |
| commit | 8a5137a5aeba39cbc2c57c83ef79241b446d0cb7 (patch) | |
| tree | afabcbbfd38a2b8c424b560f518b4bc59d74ec5c /core/java/android/text/TextLine.java | |
| parent | 70a85687b5fae5a28bc786aa5729e87202447fa3 (diff) | |
Fix bug #5349461 TextView: text that ends with an ImageSpan causes line height to shrink to ImageSpan height
- save current metrics values before updating them
Change-Id: I2d88dd7d30e8e01d0c5e2328973f256b689672b2
Diffstat (limited to 'core/java/android/text/TextLine.java')
| -rw-r--r-- | core/java/android/text/TextLine.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index a52d48e630d1..1e17632e08e6 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -679,6 +679,12 @@ class TextLine { wp.getFontMetricsInt(fmi); + updateMetrics(fmi, previousTop, previousAscent, previousDescent, previousBottom, + previousLeading); + } + + static void updateMetrics(FontMetricsInt fmi, int previousTop, int previousAscent, + int previousDescent, int previousBottom, int previousLeading) { fmi.top = Math.min(fmi.top, previousTop); fmi.ascent = Math.min(fmi.ascent, previousAscent); fmi.descent = Math.max(fmi.descent, previousDescent); @@ -809,7 +815,28 @@ class TextLine { int textLimit = mStart + limit; if (needWidth || (c != null && runIsRtl)) { + int previousTop = 0; + int previousAscent = 0; + int previousDescent = 0; + int previousBottom = 0; + int previousLeading = 0; + + boolean needUpdateMetrics = (fmi != null); + + if (needUpdateMetrics) { + previousTop = fmi.top; + previousAscent = fmi.ascent; + previousDescent = fmi.descent; + previousBottom = fmi.bottom; + previousLeading = fmi.leading; + } + ret = replacement.getSize(wp, mText, textStart, textLimit, fmi); + + if (needUpdateMetrics) { + updateMetrics(fmi, previousTop, previousAscent, previousDescent, previousBottom, + previousLeading); + } } if (c != null) { |
