From ea2b4a40f7236172398ebcaa273612e00340d847 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Mon, 20 Jul 2015 16:22:01 -0700 Subject: [PATCH] Respect style boundaries when measuring text The existing implementation of handleText() in TextLine laid out text to the end of the context. However, in cases where the text is broken into multiple style spans, it's only valid to lay out up to the end of the style span. This can lead to inconsistent measurements, especially in the presence of legitimate zero-width characters such as bidi control characters and zero width space. This patch changes the invocation of getRunAdvance to measure only within the style span. Bug: 22589743 Change-Id: I027f5e77db27ddf9596ef20adcad7e62a82b41de --- core/java/android/text/TextLine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index 605b91dee9c0b..39e86948d187f 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -741,11 +741,11 @@ class TextLine { if (needWidth || (c != null && (wp.bgColor != 0 || wp.underlineColor != 0 || runIsRtl))) { if (mCharsValid) { - ret = wp.getRunAdvance(mChars, start, contextEnd, contextStart, contextEnd, + ret = wp.getRunAdvance(mChars, start, end, contextStart, contextEnd, runIsRtl, end); } else { int delta = mStart; - ret = wp.getRunAdvance(mText, delta + start, delta + contextEnd, + ret = wp.getRunAdvance(mText, delta + start, delta + end, delta + contextStart, delta + contextEnd, runIsRtl, delta + end); } }