aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Perez <diegoperez@google.com>2017-06-29 12:20:44 +0100
committerDiego Perez <diegoperez@google.com>2017-06-29 12:26:29 +0100
commit4ac825cd1a24be836a6716a27db03f93bd6d6ab3 (patch)
tree99b19d9bc1bdc35203389a97cad30d4b6cdd1f52
parentfedef05e4541a5a163a781ab35ccdc1c6d04bdd5 (diff)
downloadlayoutlib-4ac825cd1a24be836a6716a27db03f93bd6d6ab3.tar.gz
Fix RTL bidi flags
Pass the bidi flags down the stack to allow correctly rendering RTL text. In some cases the meaning of Paint.BIDI_DEFAULT_LTR was lost and transformed into Paint.BIDI_LTR. That broke some cases where the text was RTL and the flag was BIDI_DEFAULT_LTR (so it shouldn't be forced). Bug: 37136729 Test: Existing tests pass (BIDI_DEFAULT_LTR is used from the support lib) Change-Id: I8e78528d87d714de57c080d623411a8afea31614
-rw-r--r--bridge/src/android/graphics/BaseCanvas_Delegate.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/bridge/src/android/graphics/BaseCanvas_Delegate.java b/bridge/src/android/graphics/BaseCanvas_Delegate.java
index cc71053fce..01860049d6 100644
--- a/bridge/src/android/graphics/BaseCanvas_Delegate.java
+++ b/bridge/src/android/graphics/BaseCanvas_Delegate.java
@@ -479,7 +479,7 @@ public class BaseCanvas_Delegate {
@LayoutlibDelegate
/*package*/ static void nDrawText(long nativeCanvas, char[] text, int index, int count,
float startX, float startY, int flags, long paint, long typeface) {
- drawText(nativeCanvas, text, index, count, startX, startY, (flags & 1) != 0,
+ drawText(nativeCanvas, text, index, count, startX, startY, flags,
paint, typeface);
}
@@ -502,14 +502,16 @@ public class BaseCanvas_Delegate {
char[] buffer = TemporaryBuffer.obtain(count);
TextUtils.getChars(text, start, end, buffer, 0);
- drawText(nativeCanvas, buffer, 0, count, x, y, isRtl, paint, typeface);
+ drawText(nativeCanvas, buffer, 0, count, x, y, isRtl ? Paint.BIDI_RTL : Paint.BIDI_LTR,
+ paint,
+ typeface);
}
@LayoutlibDelegate
/*package*/ static void nDrawTextRun(long nativeCanvas, char[] text,
int start, int count, int contextStart, int contextCount,
float x, float y, boolean isRtl, long paint, long typeface) {
- drawText(nativeCanvas, text, start, count, x, y, isRtl, paint, typeface);
+ drawText(nativeCanvas, text, start, count, x, y, isRtl ? Paint.BIDI_RTL : Paint.BIDI_LTR, paint, typeface);
}
@LayoutlibDelegate
@@ -574,7 +576,7 @@ public class BaseCanvas_Delegate {
}
private static void drawText(long nativeCanvas, final char[] text, final int index,
- final int count, final float startX, final float startY, final boolean isRtl,
+ final int count, final float startX, final float startY, final int bidiFlags,
long paint, final long typeface) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
@@ -591,7 +593,7 @@ public class BaseCanvas_Delegate {
int limit = index + count;
if (paintDelegate.getTextAlign() != Paint.Align.LEFT.nativeInt) {
RectF bounds =
- paintDelegate.measureText(text, index, count, null, 0, isRtl);
+ paintDelegate.measureText(text, index, count, null, 0, bidiFlags);
float m = bounds.right - bounds.left;
if (paintDelegate.getTextAlign() == Paint.Align.CENTER.nativeInt) {
x -= m / 2;
@@ -601,7 +603,7 @@ public class BaseCanvas_Delegate {
}
new BidiRenderer(graphics, paintDelegate, text).setRenderLocation(x,
- startY).renderText(index, limit, isRtl, null, 0, true);
+ startY).renderText(index, limit, bidiFlags, null, 0, true);
});
}