summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2013-03-15 11:26:56 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2013-03-15 11:26:56 -0700
commitda12f389eb4be0c08ca3fa9ca7663f4977858df5 (patch)
treeb1bf0853765bb1bb4728073b8f08982131d1cc04 /graphics
parent19f46b0d7a1cdba362bc3d6fc8e9251307e96bd4 (diff)
downloadframeworks_base-da12f389eb4be0c08ca3fa9ca7663f4977858df5.zip
frameworks_base-da12f389eb4be0c08ca3fa9ca7663f4977858df5.tar.gz
frameworks_base-da12f389eb4be0c08ca3fa9ca7663f4977858df5.tar.bz2
Revert "Clean Paint.mBidiFlags as it is no longer used"
This reverts commit 6d9fe5bd22b531bfce69b146254a4791c76acddc.
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/Canvas.java64
-rw-r--r--graphics/java/android/graphics/Paint.java290
2 files changed, 305 insertions, 49 deletions
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 9bb90f1..4df5c24 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -62,6 +62,18 @@ public class Canvas {
@SuppressWarnings({"UnusedDeclaration"})
private int mSurfaceFormat;
+ /**
+ * Flag for drawTextRun indicating left-to-right run direction.
+ * @hide
+ */
+ public static final int DIRECTION_LTR = 0;
+
+ /**
+ * Flag for drawTextRun indicating right-to-left run direction.
+ * @hide
+ */
+ public static final int DIRECTION_RTL = 1;
+
// Maximum bitmap size as defined in Skia's native code
// (see SkCanvas.cpp, SkDraw.cpp)
private static final int MAXMIMUM_BITMAP_SIZE = 32766;
@@ -1333,7 +1345,8 @@ public class Canvas {
(text.length - index - count)) < 0) {
throw new IndexOutOfBoundsException();
}
- native_drawText(mNativeCanvas, text, index, count, x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, text, index, count, x, y, paint.mBidiFlags,
+ paint.mNativePaint);
}
/**
@@ -1346,7 +1359,8 @@ public class Canvas {
* @param paint The paint used for the text (e.g. color, size, style)
*/
public void drawText(String text, float x, float y, Paint paint) {
- native_drawText(mNativeCanvas, text, 0, text.length(), x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, text, 0, text.length(), x, y, paint.mBidiFlags,
+ paint.mNativePaint);
}
/**
@@ -1364,7 +1378,8 @@ public class Canvas {
if ((start | end | (end - start) | (text.length() - end)) < 0) {
throw new IndexOutOfBoundsException();
}
- native_drawText(mNativeCanvas, text, start, end, x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, text, start, end, x, y, paint.mBidiFlags,
+ paint.mNativePaint);
}
/**
@@ -1383,14 +1398,16 @@ public class Canvas {
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
- native_drawText(mNativeCanvas, text.toString(), start, end, x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, text.toString(), start, end, x, y,
+ paint.mBidiFlags, paint.mNativePaint);
} else if (text instanceof GraphicsOperations) {
((GraphicsOperations) text).drawText(this, start, end, x, y,
paint);
} else {
char[] buf = TemporaryBuffer.obtain(end - start);
TextUtils.getChars(text, start, end, buf, 0);
- native_drawText(mNativeCanvas, buf, 0, end - start, x, y, paint.mNativePaint);
+ native_drawText(mNativeCanvas, buf, 0, end - start, x, y,
+ paint.mBidiFlags, paint.mNativePaint);
TemporaryBuffer.recycle(buf);
}
}
@@ -1411,11 +1428,13 @@ public class Canvas {
* + count.
* @param x the x position at which to draw the text
* @param y the y position at which to draw the text
+ * @param dir the run direction, either {@link #DIRECTION_LTR} or
+ * {@link #DIRECTION_RTL}.
* @param paint the paint
* @hide
*/
public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
- float x, float y, Paint paint) {
+ float x, float y, int dir, Paint paint) {
if (text == null) {
throw new NullPointerException("text is null");
@@ -1426,9 +1445,12 @@ public class Canvas {
if ((index | count | text.length - index - count) < 0) {
throw new IndexOutOfBoundsException();
}
+ if (dir != DIRECTION_LTR && dir != DIRECTION_RTL) {
+ throw new IllegalArgumentException("unknown dir: " + dir);
+ }
native_drawTextRun(mNativeCanvas, text, index, count,
- contextIndex, contextCount, x, y, paint.mNativePaint);
+ contextIndex, contextCount, x, y, dir, paint.mNativePaint);
}
/**
@@ -1444,11 +1466,12 @@ public class Canvas {
* position can be used for shaping context.
* @param x the x position at which to draw the text
* @param y the y position at which to draw the text
+ * @param dir the run direction, either 0 for LTR or 1 for RTL.
* @param paint the paint
* @hide
*/
public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd,
- float x, float y, Paint paint) {
+ float x, float y, int dir, Paint paint) {
if (text == null) {
throw new NullPointerException("text is null");
@@ -1460,20 +1483,22 @@ public class Canvas {
throw new IndexOutOfBoundsException();
}
+ int flags = dir == 0 ? 0 : 1;
+
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
native_drawTextRun(mNativeCanvas, text.toString(), start, end,
- contextStart, contextEnd, x, y, paint.mNativePaint);
+ contextStart, contextEnd, x, y, flags, paint.mNativePaint);
} else if (text instanceof GraphicsOperations) {
((GraphicsOperations) text).drawTextRun(this, start, end,
- contextStart, contextEnd, x, y, paint);
+ contextStart, contextEnd, x, y, flags, paint);
} else {
int contextLen = contextEnd - contextStart;
int len = end - start;
char[] buf = TemporaryBuffer.obtain(contextLen);
TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
native_drawTextRun(mNativeCanvas, buf, start - contextStart, len,
- 0, contextLen, x, y, paint.mNativePaint);
+ 0, contextLen, x, y, flags, paint.mNativePaint);
TemporaryBuffer.recycle(buf);
}
}
@@ -1539,7 +1564,8 @@ public class Canvas {
throw new ArrayIndexOutOfBoundsException();
}
native_drawTextOnPath(mNativeCanvas, text, index, count,
- path.ni(), hOffset, vOffset, paint.mNativePaint);
+ path.ni(), hOffset, vOffset,
+ paint.mBidiFlags, paint.mNativePaint);
}
/**
@@ -1558,7 +1584,7 @@ public class Canvas {
public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) {
if (text.length() > 0) {
native_drawTextOnPath(mNativeCanvas, text, path.ni(), hOffset, vOffset,
- paint.mNativePaint);
+ paint.mBidiFlags, paint.mNativePaint);
}
}
@@ -1720,18 +1746,18 @@ public class Canvas {
private static native void native_drawText(int nativeCanvas, char[] text,
int index, int count, float x,
- float y, int paint);
+ float y, int flags, int paint);
private static native void native_drawText(int nativeCanvas, String text,
int start, int end, float x,
- float y, int paint);
+ float y, int flags, int paint);
private static native void native_drawTextRun(int nativeCanvas, String text,
int start, int end, int contextStart, int contextEnd,
- float x, float y, int paint);
+ float x, float y, int flags, int paint);
private static native void native_drawTextRun(int nativeCanvas, char[] text,
int start, int count, int contextStart, int contextCount,
- float x, float y, int paint);
+ float x, float y, int flags, int paint);
private static native void native_drawPosText(int nativeCanvas,
char[] text, int index,
@@ -1744,13 +1770,13 @@ public class Canvas {
char[] text, int index,
int count, int path,
float hOffset,
- float vOffset,
+ float vOffset, int bidiFlags,
int paint);
private static native void native_drawTextOnPath(int nativeCanvas,
String text, int path,
float hOffset,
float vOffset,
- int paint);
+ int flags, int paint);
private static native void native_drawPicture(int nativeCanvas,
int nativePicture);
private static native void finalizer(int nativeCanvas);
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index fd45409..216dc6c 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -69,6 +69,11 @@ public class Paint {
*/
public int shadowColor;
+ /**
+ * @hide
+ */
+ public int mBidiFlags = BIDI_DEFAULT_LTR;
+
static final Style[] sStyleArray = {
Style.FILL, Style.STROKE, Style.FILL_AND_STROKE
};
@@ -115,6 +120,74 @@ public class Paint {
public static final int HINTING_ON = 0x1;
/**
+ * Bidi flag to set LTR paragraph direction.
+ *
+ * @hide
+ */
+ public static final int BIDI_LTR = 0x0;
+
+ /**
+ * Bidi flag to set RTL paragraph direction.
+ *
+ * @hide
+ */
+ public static final int BIDI_RTL = 0x1;
+
+ /**
+ * Bidi flag to detect paragraph direction via heuristics, defaulting to
+ * LTR.
+ *
+ * @hide
+ */
+ public static final int BIDI_DEFAULT_LTR = 0x2;
+
+ /**
+ * Bidi flag to detect paragraph direction via heuristics, defaulting to
+ * RTL.
+ *
+ * @hide
+ */
+ public static final int BIDI_DEFAULT_RTL = 0x3;
+
+ /**
+ * Bidi flag to override direction to all LTR (ignore bidi).
+ *
+ * @hide
+ */
+ public static final int BIDI_FORCE_LTR = 0x4;
+
+ /**
+ * Bidi flag to override direction to all RTL (ignore bidi).
+ *
+ * @hide
+ */
+ public static final int BIDI_FORCE_RTL = 0x5;
+
+ /**
+ * Maximum Bidi flag value.
+ * @hide
+ */
+ private static final int BIDI_MAX_FLAG_VALUE = BIDI_FORCE_RTL;
+
+ /**
+ * Mask for bidi flags.
+ * @hide
+ */
+ private static final int BIDI_FLAG_MASK = 0x7;
+
+ /**
+ * Flag for getTextRunAdvances indicating left-to-right run direction.
+ * @hide
+ */
+ public static final int DIRECTION_LTR = 0;
+
+ /**
+ * Flag for getTextRunAdvances indicating right-to-left run direction.
+ * @hide
+ */
+ public static final int DIRECTION_RTL = 1;
+
+ /**
* Option for getTextRunCursor to compute the valid cursor after
* offset or the limit of the context, whichever is less.
* @hide
@@ -322,6 +395,7 @@ public class Paint {
shadowRadius = 0;
shadowColor = 0;
+ mBidiFlags = BIDI_DEFAULT_LTR;
setTextLocale(Locale.getDefault());
}
@@ -361,6 +435,7 @@ public class Paint {
shadowRadius = paint.shadowRadius;
shadowColor = paint.shadowColor;
+ mBidiFlags = paint.mBidiFlags;
mLocale = paint.mLocale;
}
@@ -377,6 +452,29 @@ public class Paint {
}
/**
+ * Return the bidi flags on the paint.
+ *
+ * @return the bidi flags on the paint
+ * @hide
+ */
+ public int getBidiFlags() {
+ return mBidiFlags;
+ }
+
+ /**
+ * Set the bidi flags on the paint.
+ * @hide
+ */
+ public void setBidiFlags(int flags) {
+ // only flag value is the 3-bit BIDI control setting
+ flags &= BIDI_FLAG_MASK;
+ if (flags > BIDI_MAX_FLAG_VALUE) {
+ throw new IllegalArgumentException("unknown bidi flag: " + flags);
+ }
+ mBidiFlags = flags;
+ }
+
+ /**
* Return the paint's flags. Use the Flag enum to test flag values.
*
* @return the paint's flags (see enums ending in _Flag for bit masks)
@@ -1570,19 +1668,76 @@ public class Paint {
}
/**
+ * Return the glyph Ids for the characters in the string.
+ *
+ * @param text The text to measure
+ * @param start The index of the first char to to measure
+ * @param end The end of the text slice to measure
+ * @param contextStart the index of the first character to use for shaping context,
+ * must be <= start
+ * @param contextEnd the index past the last character to use for shaping context,
+ * must be >= end
+ * @param flags the flags to control the advances, either {@link #DIRECTION_LTR}
+ * or {@link #DIRECTION_RTL}
+ * @param glyphs array to receive the glyph Ids of the characters.
+ * Must be at least a large as the text.
+ * @return the number of glyphs in the returned array
+ *
+ * @hide
+ *
+ * Used only for BiDi / RTL Tests
+ */
+ public int getTextGlyphs(String text, int start, int end, int contextStart, int contextEnd,
+ int flags, char[] glyphs) {
+ if (text == null) {
+ throw new IllegalArgumentException("text cannot be null");
+ }
+ if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
+ throw new IllegalArgumentException("unknown flags value: " + flags);
+ }
+ if ((start | end | contextStart | contextEnd | (end - start)
+ | (start - contextStart) | (contextEnd - end) | (text.length() - end)
+ | (text.length() - contextEnd)) < 0) {
+ throw new IndexOutOfBoundsException();
+ }
+ if (end - start > glyphs.length) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ return native_getTextGlyphs(mNativePaint, text, start, end, contextStart, contextEnd,
+ flags, glyphs);
+ }
+
+ /**
* Convenience overload that takes a char array instead of a
* String.
*
- * @see #getTextRunAdvances(String, int, int, int, int, float[], int)
+ * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int)
* @hide
*/
public float getTextRunAdvances(char[] chars, int index, int count,
- int contextIndex, int contextCount, float[] advances,
+ int contextIndex, int contextCount, int flags, float[] advances,
int advancesIndex) {
+ return getTextRunAdvances(chars, index, count, contextIndex, contextCount, flags,
+ advances, advancesIndex, 0 /* use Harfbuzz*/);
+ }
+
+ /**
+ * Convenience overload that takes a char array instead of a
+ * String.
+ *
+ * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int, int)
+ * @hide
+ */
+ public float getTextRunAdvances(char[] chars, int index, int count,
+ int contextIndex, int contextCount, int flags, float[] advances,
+ int advancesIndex, int reserved) {
if (chars == null) {
throw new IllegalArgumentException("text cannot be null");
}
+ if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
+ throw new IllegalArgumentException("unknown flags value: " + flags);
+ }
if ((index | count | contextIndex | contextCount | advancesIndex
| (index - contextIndex) | (contextCount - count)
| ((contextIndex + contextCount) - (index + count))
@@ -1597,13 +1752,13 @@ public class Paint {
}
if (!mHasCompatScaling) {
return native_getTextRunAdvances(mNativePaint, chars, index, count,
- contextIndex, contextCount, advances, advancesIndex);
+ contextIndex, contextCount, flags, advances, advancesIndex, reserved);
}
final float oldSize = getTextSize();
setTextSize(oldSize * mCompatScaling);
float res = native_getTextRunAdvances(mNativePaint, chars, index, count,
- contextIndex, contextCount, advances, advancesIndex);
+ contextIndex, contextCount, flags, advances, advancesIndex, reserved);
setTextSize(oldSize);
if (advances != null) {
@@ -1618,12 +1773,26 @@ public class Paint {
* Convenience overload that takes a CharSequence instead of a
* String.
*
- * @see #getTextRunAdvances(String, int, int, int, int, float[], int)
+ * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int)
* @hide
*/
public float getTextRunAdvances(CharSequence text, int start, int end,
- int contextStart, int contextEnd, float[] advances,
+ int contextStart, int contextEnd, int flags, float[] advances,
int advancesIndex) {
+ return getTextRunAdvances(text, start, end, contextStart, contextEnd, flags,
+ advances, advancesIndex, 0 /* use Harfbuzz */);
+ }
+
+ /**
+ * Convenience overload that takes a CharSequence instead of a
+ * String.
+ *
+ * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int)
+ * @hide
+ */
+ public float getTextRunAdvances(CharSequence text, int start, int end,
+ int contextStart, int contextEnd, int flags, float[] advances,
+ int advancesIndex, int reserved) {
if (text == null) {
throw new IllegalArgumentException("text cannot be null");
@@ -1638,16 +1807,16 @@ public class Paint {
if (text instanceof String) {
return getTextRunAdvances((String) text, start, end,
- contextStart, contextEnd, advances, advancesIndex);
+ contextStart, contextEnd, flags, advances, advancesIndex, reserved);
}
if (text instanceof SpannedString ||
text instanceof SpannableString) {
return getTextRunAdvances(text.toString(), start, end,
- contextStart, contextEnd, advances, advancesIndex);
+ contextStart, contextEnd, flags, advances, advancesIndex, reserved);
}
if (text instanceof GraphicsOperations) {
return ((GraphicsOperations) text).getTextRunAdvances(start, end,
- contextStart, contextEnd, advances, advancesIndex, this);
+ contextStart, contextEnd, flags, advances, advancesIndex, this);
}
if (text.length() == 0 || end == start) {
return 0f;
@@ -1658,7 +1827,7 @@ public class Paint {
char[] buf = TemporaryBuffer.obtain(contextLen);
TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
float result = getTextRunAdvances(buf, start - contextStart, len,
- 0, contextLen, advances, advancesIndex);
+ 0, contextLen, flags, advances, advancesIndex, reserved);
TemporaryBuffer.recycle(buf);
return result;
}
@@ -1695,20 +1864,74 @@ public class Paint {
* must be <= start
* @param contextEnd the index past the last character to use for shaping context,
* must be >= end
+ * @param flags the flags to control the advances, either {@link #DIRECTION_LTR}
+ * or {@link #DIRECTION_RTL}
+ * @param advances array to receive the advances, must have room for all advances,
+ * can be null if only total advance is needed
+ * @param advancesIndex the position in advances at which to put the
+ * advance corresponding to the character at start
+ * @return the total advance
+ *
+ * @hide
+ */
+ public float getTextRunAdvances(String text, int start, int end, int contextStart,
+ int contextEnd, int flags, float[] advances, int advancesIndex) {
+ return getTextRunAdvances(text, start, end, contextStart, contextEnd, flags,
+ advances, advancesIndex, 0 /* use Harfbuzz*/);
+ }
+
+ /**
+ * Returns the total advance width for the characters in the run
+ * between start and end, and if advances is not null, the advance
+ * assigned to each of these characters (java chars).
+ *
+ * <p>The trailing surrogate in a valid surrogate pair is assigned
+ * an advance of 0. Thus the number of returned advances is
+ * always equal to count, not to the number of unicode codepoints
+ * represented by the run.
+ *
+ * <p>In the case of conjuncts or combining marks, the total
+ * advance is assigned to the first logical character, and the
+ * following characters are assigned an advance of 0.
+ *
+ * <p>This generates the sum of the advances of glyphs for
+ * characters in a reordered cluster as the width of the first
+ * logical character in the cluster, and 0 for the widths of all
+ * other characters in the cluster. In effect, such clusters are
+ * treated like conjuncts.
+ *
+ * <p>The shaping bounds limit the amount of context available
+ * outside start and end that can be used for shaping analysis.
+ * These bounds typically reflect changes in bidi level or font
+ * metrics across which shaping does not occur.
+ *
+ * @param text the text to measure. Cannot be null.
+ * @param start the index of the first character to measure
+ * @param end the index past the last character to measure
+ * @param contextStart the index of the first character to use for shaping context,
+ * must be <= start
+ * @param contextEnd the index past the last character to use for shaping context,
+ * must be >= end
+ * @param flags the flags to control the advances, either {@link #DIRECTION_LTR}
+ * or {@link #DIRECTION_RTL}
* @param advances array to receive the advances, must have room for all advances,
* can be null if only total advance is needed
* @param advancesIndex the position in advances at which to put the
* advance corresponding to the character at start
+ * @param reserved int reserved value
* @return the total advance
*
* @hide
*/
public float getTextRunAdvances(String text, int start, int end, int contextStart,
- int contextEnd, float[] advances, int advancesIndex) {
+ int contextEnd, int flags, float[] advances, int advancesIndex, int reserved) {
if (text == null) {
throw new IllegalArgumentException("text cannot be null");
}
+ if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
+ throw new IllegalArgumentException("unknown flags value: " + flags);
+ }
if ((start | end | contextStart | contextEnd | advancesIndex | (end - start)
| (start - contextStart) | (contextEnd - end)
| (text.length() - contextEnd)
@@ -1723,13 +1946,13 @@ public class Paint {
if (!mHasCompatScaling) {
return native_getTextRunAdvances(mNativePaint, text, start, end,
- contextStart, contextEnd, advances, advancesIndex);
+ contextStart, contextEnd, flags, advances, advancesIndex, reserved);
}
final float oldSize = getTextSize();
setTextSize(oldSize * mCompatScaling);
float totalAdvance = native_getTextRunAdvances(mNativePaint, text, start, end,
- contextStart, contextEnd, advances, advancesIndex);
+ contextStart, contextEnd, flags, advances, advancesIndex, reserved);
setTextSize(oldSize);
if (advances != null) {
@@ -1758,6 +1981,7 @@ public class Paint {
* @param text the text
* @param contextStart the start of the context
* @param contextLength the length of the context
+ * @param flags either {@link #DIRECTION_RTL} or {@link #DIRECTION_LTR}
* @param offset the cursor position to move from
* @param cursorOpt how to move the cursor, one of {@link #CURSOR_AFTER},
* {@link #CURSOR_AT_OR_AFTER}, {@link #CURSOR_BEFORE},
@@ -1766,7 +1990,7 @@ public class Paint {
* @hide
*/
public int getTextRunCursor(char[] text, int contextStart, int contextLength,
- int offset, int cursorOpt) {
+ int flags, int offset, int cursorOpt) {
int contextEnd = contextStart + contextLength;
if (((contextStart | contextEnd | offset | (contextEnd - contextStart)
| (offset - contextStart) | (contextEnd - offset)
@@ -1776,7 +2000,7 @@ public class Paint {
}
return native_getTextRunCursor(mNativePaint, text,
- contextStart, contextLength, offset, cursorOpt);
+ contextStart, contextLength, flags, offset, cursorOpt);
}
/**
@@ -1797,6 +2021,7 @@ public class Paint {
* @param text the text
* @param contextStart the start of the context
* @param contextEnd the end of the context
+ * @param flags either {@link #DIRECTION_RTL} or {@link #DIRECTION_LTR}
* @param offset the cursor position to move from
* @param cursorOpt how to move the cursor, one of {@link #CURSOR_AFTER},
* {@link #CURSOR_AT_OR_AFTER}, {@link #CURSOR_BEFORE},
@@ -1805,22 +2030,22 @@ public class Paint {
* @hide
*/
public int getTextRunCursor(CharSequence text, int contextStart,
- int contextEnd, int offset, int cursorOpt) {
+ int contextEnd, int flags, int offset, int cursorOpt) {
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
return getTextRunCursor(text.toString(), contextStart, contextEnd,
- offset, cursorOpt);
+ flags, offset, cursorOpt);
}
if (text instanceof GraphicsOperations) {
return ((GraphicsOperations) text).getTextRunCursor(
- contextStart, contextEnd, offset, cursorOpt, this);
+ contextStart, contextEnd, flags, offset, cursorOpt, this);
}
int contextLen = contextEnd - contextStart;
char[] buf = TemporaryBuffer.obtain(contextLen);
TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
- int result = getTextRunCursor(buf, 0, contextLen, offset - contextStart, cursorOpt);
+ int result = getTextRunCursor(buf, 0, contextLen, flags, offset - contextStart, cursorOpt);
TemporaryBuffer.recycle(buf);
return result;
}
@@ -1843,6 +2068,7 @@ public class Paint {
* @param text the text
* @param contextStart the start of the context
* @param contextEnd the end of the context
+ * @param flags either {@link #DIRECTION_RTL} or {@link #DIRECTION_LTR}
* @param offset the cursor position to move from
* @param cursorOpt how to move the cursor, one of {@link #CURSOR_AFTER},
* {@link #CURSOR_AT_OR_AFTER}, {@link #CURSOR_BEFORE},
@@ -1860,7 +2086,7 @@ public class Paint {
}
return native_getTextRunCursor(mNativePaint, text,
- contextStart, contextEnd, offset, cursorOpt);
+ contextStart, contextEnd, flags, offset, cursorOpt);
}
/**
@@ -1881,7 +2107,7 @@ public class Paint {
if ((index | count) < 0 || index + count > text.length) {
throw new ArrayIndexOutOfBoundsException();
}
- native_getTextPath(mNativePaint, text, index, count, x, y,
+ native_getTextPath(mNativePaint, mBidiFlags, text, index, count, x, y,
path.ni());
}
@@ -1903,7 +2129,7 @@ public class Paint {
if ((start | end | (end - start) | (text.length() - end)) < 0) {
throw new IndexOutOfBoundsException();
}
- native_getTextPath(mNativePaint, text, start, end, x, y,
+ native_getTextPath(mNativePaint, mBidiFlags, text, start, end, x, y,
path.ni());
}
@@ -1995,22 +2221,26 @@ public class Paint {
private static native int native_getTextWidths(int native_object,
String text, int start, int end, float[] widths);
+ private static native int native_getTextGlyphs(int native_object,
+ String text, int start, int end, int contextStart, int contextEnd,
+ int flags, char[] glyphs);
+
private static native float native_getTextRunAdvances(int native_object,
char[] text, int index, int count, int contextIndex, int contextCount,
- float[] advances, int advancesIndex);
+ int flags, float[] advances, int advancesIndex, int reserved);
private static native float native_getTextRunAdvances(int native_object,
String text, int start, int end, int contextStart, int contextEnd,
- float[] advances, int advancesIndex);
+ int flags, float[] advances, int advancesIndex, int reserved);
private native int native_getTextRunCursor(int native_object, char[] text,
- int contextStart, int contextLength, int offset, int cursorOpt);
+ int contextStart, int contextLength, int flags, int offset, int cursorOpt);
private native int native_getTextRunCursor(int native_object, String text,
- int contextStart, int contextEnd, int offset, int cursorOpt);
+ int contextStart, int contextEnd, int flags, int offset, int cursorOpt);
- private static native void native_getTextPath(int native_object, char[] text,
- int index, int count, float x, float y, int path);
- private static native void native_getTextPath(int native_object, String text,
- int start, int end, float x, float y, int path);
+ private static native void native_getTextPath(int native_object, int bidiFlags,
+ char[] text, int index, int count, float x, float y, int path);
+ private static native void native_getTextPath(int native_object, int bidiFlags,
+ String text, int start, int end, float x, float y, int path);
private static native void nativeGetStringBounds(int nativePaint,
String text, int start, int end, Rect bounds);
private static native void nativeGetCharArrayBounds(int nativePaint,