diff options
| author | Gilles Debunne <debunne@google.com> | 2010-12-02 15:50:26 -0800 |
|---|---|---|
| committer | Gilles Debunne <debunne@google.com> | 2010-12-02 16:18:54 -0800 |
| commit | 0bb000931bb841e75903d655552d1626ae158707 (patch) | |
| tree | 4cee560a61d3c37fb619719e4e9214bfe135b128 /core/java/android/text/TextLine.java | |
| parent | dcafdb2e9babeaa7aafd1cb15be6423a656de996 (diff) | |
Fix in vertical measurement in text lines with different text sizes
The last span of the TextLine was defining the FontMetrics, instead of
min/maxing the different values.
Bug 3220698
Change-Id: I7394b1699a15aeee4cc38462d561faf329d3e1f6
Diffstat (limited to 'core/java/android/text/TextLine.java')
| -rw-r--r-- | core/java/android/text/TextLine.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index 2f7482c2f15d..a6fd2f11ab38 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -663,6 +663,25 @@ class TextLine { } /** + * @param wp + */ + private static void expandMetricsFromPaint(FontMetricsInt fmi, TextPaint wp) { + final int previousTop = fmi.top; + final int previousAscent = fmi.ascent; + final int previousDescent = fmi.descent; + final int previousBottom = fmi.bottom; + final int previousLeading = fmi.leading; + + wp.getFontMetricsInt(fmi); + + fmi.top = Math.min(fmi.top, previousTop); + fmi.ascent = Math.min(fmi.ascent, previousAscent); + fmi.descent = Math.max(fmi.descent, previousDescent); + fmi.bottom = Math.max(fmi.bottom, previousBottom); + fmi.leading = Math.max(fmi.leading, previousLeading); + } + + /** * Utility function for measuring and rendering text. The text must * not include a tab or emoji. * @@ -703,7 +722,7 @@ class TextLine { } if (fmi != null) { - wp.getFontMetricsInt(fmi); + expandMetricsFromPaint(fmi, wp); } if (c != null) { |
