summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Kohen <kohen.d@gmail.com>2010-08-05 20:15:04 +0300
committerDavid Kohen <kohen.d@gmail.com>2010-08-06 01:40:27 +0300
commit99977d30ec46148fba1f3aa7ab3c47f5043c76f4 (patch)
treee2439b0221009e1de3aed65479f17a88f7de0281
parentbe6dbddf0fcd0e368f2d0277b747b0c99189b3bd (diff)
downloadframeworks_base-99977d30ec46148fba1f3aa7ab3c47f5043c76f4.zip
frameworks_base-99977d30ec46148fba1f3aa7ab3c47f5043c76f4.tar.gz
frameworks_base-99977d30ec46148fba1f3aa7ab3c47f5043c76f4.tar.bz2
Handle RTL in Paint.getTextPath
-rw-r--r--graphics/java/android/graphics/Canvas.java6
-rw-r--r--graphics/java/android/graphics/Paint.java18
2 files changed, 19 insertions, 5 deletions
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index b291451..f74921a 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -1237,7 +1237,7 @@ public class Canvas {
* Since the reshaping algorithm does not test for arabic prior to starting, this is made to
* @hide
**/
- public boolean bidiTest(char[] text,int start,int srcCount) {
+ public static boolean bidiTest(char[] text,int start,int srcCount) {
boolean hasBidi=false;
@@ -1254,7 +1254,7 @@ public class Canvas {
* Since the reshaping algorithm does not test for arabic prior to starting, this is made to
* @hide
**/
- public boolean bidiTest(String text,int start,int srcCount) {
+ public static boolean bidiTest(String text,int start,int srcCount) {
boolean hasBidi=false;
@@ -1272,7 +1272,7 @@ public class Canvas {
* written from scratch by David Kohen (kohen dot d at gmail dot com) - 2010
* @hide
**/
- public char[] bidiProcess(char[] text,int start,int srcCount) {
+ public static char[] bidiProcess(char[] text,int start,int srcCount) {
boolean hasBidi=false;
char[] destCharArray=new char[srcCount];
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 3e3f87b..c65e5cf 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -1299,7 +1299,14 @@ public class Paint {
if ((index | count) < 0 || index + count > text.length) {
throw new ArrayIndexOutOfBoundsException();
}
- native_getTextPath(mNativePaint, text, index, count, x, y, path.ni());
+ boolean hasBidi=Canvas.bidiTest(text,index,count);
+ if (hasBidi) {
+ char[] bidiText;
+ bidiText=Canvas.bidiProcess(text,index,count);
+ native_getTextPath(mNativePaint, ArabicReshape.reshape(new String(bidiText)).toCharArray(), 0, count, x, y, path.ni());
+ } else {
+ native_getTextPath(mNativePaint, text, index, count, x, y, path.ni());
+ }
}
/**
@@ -1320,7 +1327,14 @@ public class Paint {
if ((start | end | (end - start) | (text.length() - end)) < 0) {
throw new IndexOutOfBoundsException();
}
- native_getTextPath(mNativePaint, text, start, end, x, y, path.ni());
+ boolean hasBidi=Canvas.bidiTest(text,start,start+end);
+ if (hasBidi) {
+ char[] bidiText;
+ bidiText=Canvas.bidiProcess(text.toCharArray(),start,start+end);
+ native_getTextPath(mNativePaint, ArabicReshape.reshape(new String(bidiText)), 0, end-start, x, y, path.ni());
+ } else {
+ native_getTextPath(mNativePaint, text, start, end, x, y, path.ni());
+ }
}
/**