diff options
author | Doug Felt <dougfelt@google.com> | 2011-07-07 11:57:48 -0700 |
---|---|---|
committer | Doug Felt <dougfelt@google.com> | 2011-07-14 11:24:33 -0700 |
commit | cb379120456d8065d742021fc5c66748fc8a11a8 (patch) | |
tree | 980cb4378ded06d096f8606073a2f32245f6df87 /core/java/android/text/BoringLayout.java | |
parent | ad3f935ce9f3308edc62d56a0059e0761c720077 (diff) | |
download | frameworks_base-cb379120456d8065d742021fc5c66748fc8a11a8.zip frameworks_base-cb379120456d8065d742021fc5c66748fc8a11a8.tar.gz frameworks_base-cb379120456d8065d742021fc5c66748fc8a11a8.tar.bz2 |
Implement textDirection heuristic selection.
Change-Id: I2fcf18de573f2d66494fa5ed61e4273c3c6078c7
Diffstat (limited to 'core/java/android/text/BoringLayout.java')
-rw-r--r-- | core/java/android/text/BoringLayout.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/core/java/android/text/BoringLayout.java b/core/java/android/text/BoringLayout.java index 757a8c3..5a244f1 100644 --- a/core/java/android/text/BoringLayout.java +++ b/core/java/android/text/BoringLayout.java @@ -226,7 +226,17 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback */ public static Metrics isBoring(CharSequence text, TextPaint paint) { - return isBoring(text, paint, null); + return isBoring(text, paint, TextDirectionHeuristics.FIRSTSTRONG_LTR, null); + } + + /** + * Returns null if not boring; the width, ascent, and descent if boring. + * @hide + */ + public static Metrics isBoring(CharSequence text, + TextPaint paint, + TextDirectionHeuristic textDir) { + return isBoring(text, paint, textDir, null); } /** @@ -235,6 +245,17 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback * if boring. */ public static Metrics isBoring(CharSequence text, TextPaint paint, Metrics metrics) { + return isBoring(text, paint, TextDirectionHeuristics.FIRSTSTRONG_LTR, metrics); + } + + /** + * Returns null if not boring; the width, ascent, and descent in the + * provided Metrics object (or a new one if the provided one was null) + * if boring. + * @hide + */ + public static Metrics isBoring(CharSequence text, TextPaint paint, + TextDirectionHeuristic textDir, Metrics metrics) { char[] temp = TextUtils.obtain(500); int length = text.length(); boolean boring = true; @@ -258,6 +279,11 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback break outer; } } + + if (textDir.isRtl(temp, 0, n)) { + boring = false; + break outer; + } } TextUtils.recycle(temp); |