diff options
Diffstat (limited to 'graphics/java')
| -rw-r--r-- | graphics/java/android/graphics/Canvas.java | 13 | ||||
| -rw-r--r-- | graphics/java/android/graphics/Paint.java | 22 |
2 files changed, 31 insertions, 4 deletions
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index 150f195..48afcbf 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -45,6 +45,8 @@ import javax.microedition.khronos.opengles.GL; * Canvas and Drawables</a> developer guide.</p></div> */ public class Canvas { + /** @hide */ + public static boolean sCompatibilityRestore = false; /** * Should only be assigned in constructors (or setBitmap if software canvas), @@ -557,7 +559,8 @@ public class Canvas { * an error to call restore() more times than save() was called. */ public void restore() { - native_restore(mNativeCanvasWrapper); + boolean throwOnUnderflow = !sCompatibilityRestore || !isHardwareAccelerated(); + native_restore(mNativeCanvasWrapper, throwOnUnderflow); } /** @@ -582,7 +585,8 @@ public class Canvas { * @param saveCount The save level to restore to. */ public void restoreToCount(int saveCount) { - native_restoreToCount(mNativeCanvasWrapper, saveCount); + boolean throwOnUnderflow = !sCompatibilityRestore || !isHardwareAccelerated(); + native_restoreToCount(mNativeCanvasWrapper, saveCount, throwOnUnderflow); } /** @@ -1988,9 +1992,10 @@ public class Canvas { private static native int native_saveLayerAlpha(long nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags); - private static native void native_restore(long canvasHandle); + private static native void native_restore(long canvasHandle, boolean tolerateUnderflow); private static native void native_restoreToCount(long canvasHandle, - int saveCount); + int saveCount, + boolean tolerateUnderflow); private static native int native_getSaveCount(long canvasHandle); private static native void native_translate(long canvasHandle, diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index d3cb9b1..cd5f59d 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -2249,6 +2249,26 @@ public class Paint { bounds); } + /** + * Determine whether the typeface set on the paint has a glyph supporting the string. The + * simplest case is when the string contains a single character, in which this method + * determines whether the font has the character. In the case of multiple characters, the + * method returns true if there is a single glyph representing the ligature. For example, if + * the input is a pair of regional indicator symbols, determine whether there is an emoji flag + * for the pair. + * + * Finally, if the string contains a variation selector, the method only returns true if + * the fonts contains a glyph specific to that variation. + * + * Checking is done on the entire fallback chain, not just the immediate font referenced. + * + * @param string the string to test whether there is glyph support + * @return true if the typeface has a glyph for the string + */ + public boolean hasGlyph(String string) { + return native_hasGlyph(mNativePaint, mNativeTypeface, mBidiFlags, string); + } + @Override protected void finalize() throws Throwable { try { @@ -2334,4 +2354,6 @@ public class Paint { String settings); private static native int native_getHyphenEdit(long native_object); private static native void native_setHyphenEdit(long native_object, int hyphen); + private static native boolean native_hasGlyph(long native_object, long native_typeface, + int bidiFlags, String string); } |
