summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib/bridge/src/android/text/AndroidBidi_Delegate.java
diff options
context:
space:
mode:
authorDeepanshu Gupta <deepanshu@google.com>2013-09-05 11:52:48 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-09-05 11:52:48 -0700
commitdd4efc22c736973ecfa1b7b4af9e71f971dd48b3 (patch)
treede97a8d08b015b121d861946c826a9b6f6e40571 /tools/layoutlib/bridge/src/android/text/AndroidBidi_Delegate.java
parentc78d173b730dcfdf107e6ac2bc959d459fe3eedd (diff)
parent3a762d8bfbe6b2d4066bc5cc90301063c19976c4 (diff)
downloadframeworks_base-dd4efc22c736973ecfa1b7b4af9e71f971dd48b3.zip
frameworks_base-dd4efc22c736973ecfa1b7b4af9e71f971dd48b3.tar.gz
frameworks_base-dd4efc22c736973ecfa1b7b4af9e71f971dd48b3.tar.bz2
am 3a762d8b: Merge "Fix text rendering" into jb-mr2-dev
* commit '3a762d8bfbe6b2d4066bc5cc90301063c19976c4': Fix text rendering
Diffstat (limited to 'tools/layoutlib/bridge/src/android/text/AndroidBidi_Delegate.java')
-rw-r--r--tools/layoutlib/bridge/src/android/text/AndroidBidi_Delegate.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/tools/layoutlib/bridge/src/android/text/AndroidBidi_Delegate.java b/tools/layoutlib/bridge/src/android/text/AndroidBidi_Delegate.java
index 52b8f34..973fa0e 100644
--- a/tools/layoutlib/bridge/src/android/text/AndroidBidi_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/text/AndroidBidi_Delegate.java
@@ -16,7 +16,10 @@
package android.text;
+import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.layoutlib.bridge.Bridge;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
+import com.ibm.icu.text.Bidi;
/**
@@ -29,9 +32,29 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
public class AndroidBidi_Delegate {
@LayoutlibDelegate
- /*package*/ static int runBidi(int dir, char[] chs, byte[] chInfo, int n, boolean haveInfo) {
- // return the equivalent of Layout.DIR_LEFT_TO_RIGHT
- // TODO: actually figure the direction.
- return 0;
+ /*package*/ static int runBidi(int dir, char[] chars, byte[] charInfo, int count,
+ boolean haveInfo) {
+
+ switch (dir) {
+ case 0: // Layout.DIR_REQUEST_LTR
+ case 1: // Layout.DIR_REQUEST_RTL
+ break; // No change.
+ case -1:
+ dir = Bidi.LEVEL_DEFAULT_LTR;
+ break;
+ case -2:
+ dir = Bidi.LEVEL_DEFAULT_RTL;
+ break;
+ default:
+ // Invalid code. Log error, assume LEVEL_DEFAULT_LTR and continue.
+ Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Invalid direction flag", null);
+ dir = Bidi.LEVEL_DEFAULT_LTR;
+ }
+ Bidi bidi = new Bidi(chars, 0, null, 0, count, dir);
+ if (charInfo != null) {
+ for (int i = 0; i < count; ++i)
+ charInfo[i] = bidi.getLevelAt(i);
+ }
+ return bidi.getParaLevel();
}
}