summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Raph Levien <raph@google.com> 2015-06-24 09:36:31 -0700
committer Raph Levien <raph@google.com> 2015-06-24 14:05:52 -0700
commit1149cdc84b77d0cbe3c44a7ec6abd29fc63913b5 (patch)
treee7d3f71601610051dddb01c9b42964f1b1816eec
parent838a29a659c2b7ee244140ea4042d90d48181145 (diff)
Make measureText(String, int, int) not use context
The measureText method when applied to a string should just measure the substring, rather than treat the entire string as context. It was less likely to cause problems than the similar issues with char arrays, but still wrong. This patch makes the behavior consistent. Bug: 20087437 Change-Id: I1c6e07a694b151f4fb097edae8e271805e996d06
-rw-r--r--core/jni/android/graphics/Paint.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp
index d14fc0f7e3fb..b9fd65f0116c 100644
--- a/core/jni/android/graphics/Paint.cpp
+++ b/core/jni/android/graphics/Paint.cpp
@@ -606,7 +606,9 @@ public:
Layout layout;
TypefaceImpl* typeface = getNativeTypeface(env, jpaint);
- MinikinUtils::doLayout(&layout, paint, bidiFlags, typeface, textArray, start, count, textLength);
+ // Only the substring is used for measurement, so no additional context is passed in. This
+ // behavior is consistent between char[] and String specializations.
+ MinikinUtils::doLayout(&layout, paint, bidiFlags, typeface, textArray + start, 0, count, count);
width = layout.getAdvance();
env->ReleaseStringChars(text, textArray);