From 875062059c4932ddf5649720c26e7f59b6ab9978 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 4 Sep 2014 12:47:03 -0700 Subject: [PATCH] Fix Layout.isRtlCharAt We weren't getting correct results from Layout.isRtlCharAt, because it was only testing half of the correct predicate for whether the argument was inside the run. This patch restores the correct predicate. Bug: 17381011 Change-Id: Ib0a77cc182f4ca4bfe824e85b7aff7268f465d73 --- core/java/android/text/Layout.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index 7dce34875d49..2b53c4862d44 100644 --- a/core/java/android/text/Layout.java +++ b/core/java/android/text/Layout.java @@ -727,10 +727,9 @@ public abstract class Layout { int[] runs = dirs.mDirections; int lineStart = getLineStart(line); for (int i = 0; i < runs.length; i += 2) { - int start = lineStart + (runs[i] & RUN_LENGTH_MASK); - // No need to test the end as an offset after the last run should return the value - // corresponding of the last run - if (offset >= start) { + int start = lineStart + runs[i]; + int limit = start + (runs[i+1] & RUN_LENGTH_MASK); + if (offset >= start && offset < limit) { int level = (runs[i+1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK; return ((level & 1) != 0); } -- 2.11.0