diff options
| author | Fabrice Di Meglio <fdimeglio@google.com> | 2011-08-08 09:45:09 -0700 |
|---|---|---|
| committer | Fabrice Di Meglio <fdimeglio@google.com> | 2011-08-08 09:45:09 -0700 |
| commit | 850dffa01ba9111799f24800ae8550eca457d757 (patch) | |
| tree | 19b4b372962218107d763db9a4912bd77760504f /core/java/android/text/TextLine.java | |
| parent | f2ce877c1dde094ab599f0d3103145c9381ab260 (diff) | |
Follow up to TextView's baseline is correctly computed for empty text
Was bug http://code.google.com/p/android/issues/detail?id=15598
- optimize https://android-git.corp.google.com/g/#/c/107901/1
Change-Id: I20abd82a97adc71f04a5afba54eb679f708236f8
Diffstat (limited to 'core/java/android/text/TextLine.java')
| -rw-r--r-- | core/java/android/text/TextLine.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index f52496116b8c..c114c371a50a 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -706,9 +706,19 @@ class TextLine { Canvas c, float x, int top, int y, int bottom, FontMetricsInt fmi, boolean needWidth) { - float ret = 0; + // Get metrics first (even for empty strings or "0" width runs) + if (fmi != null) { + expandMetricsFromPaint(fmi, wp); + } int runLen = end - start; + // No need to do anything if the run width is "0" + if (runLen == 0) { + return 0f; + } + + float ret = 0; + int contextLen = contextEnd - contextStart; if (needWidth || (c != null && (wp.bgColor != 0 || runIsRtl))) { int flags = runIsRtl ? Paint.DIRECTION_RTL : Paint.DIRECTION_LTR; @@ -723,10 +733,6 @@ class TextLine { } } - if (fmi != null) { - expandMetricsFromPaint(fmi, wp); - } - if (c != null) { if (runIsRtl) { x -= ret; |
