diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2012-04-12 17:37:44 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-12 17:37:44 -0700 |
commit | 62901af52a118c61579a81c84608c9f1118931a3 (patch) | |
tree | d2d75659a8fc09d36ff3975cd3154dc49ae11013 /graphics/java | |
parent | f98c8b32e87483adbfb739023ca9070559441138 (diff) | |
parent | 517825f1a9f14f92908bd7859b91b927c2eec6d9 (diff) | |
download | frameworks_base-62901af52a118c61579a81c84608c9f1118931a3.zip frameworks_base-62901af52a118c61579a81c84608c9f1118931a3.tar.gz frameworks_base-62901af52a118c61579a81c84608c9f1118931a3.tar.bz2 |
Merge "Add Paint.setTextLocale()"
Diffstat (limited to 'graphics/java')
-rw-r--r-- | graphics/java/android/graphics/Paint.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index c97785e..8cb8466 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -21,6 +21,8 @@ import android.text.SpannableString; import android.text.SpannedString; import android.text.TextUtils; +import java.util.Locale; + /** * The Paint class holds the style and color information about how to draw * geometries, text and bitmaps. @@ -44,6 +46,8 @@ public class Paint { private float mCompatScaling; private float mInvCompatScaling; + private Locale mLocale; + /** * @hide */ @@ -348,6 +352,7 @@ public class Paint { // setHinting(DisplayMetrics.DENSITY_DEVICE >= DisplayMetrics.DENSITY_TV // ? HINTING_OFF : HINTING_ON); mCompatScaling = mInvCompatScaling = 1; + mLocale = Locale.getDefault(); } /** @@ -360,6 +365,7 @@ public class Paint { public Paint(Paint paint) { mNativePaint = native_initWithPaint(paint.mNativePaint); setClassVariablesFrom(paint); + mLocale = paint.mLocale; } /** Restores the paint to its default settings. */ @@ -373,6 +379,7 @@ public class Paint { mHasCompatScaling = false; mCompatScaling = mInvCompatScaling = 1; mBidiFlags = BIDI_DEFAULT_LTR; + mLocale = Locale.getDefault(); } /** @@ -412,6 +419,7 @@ public class Paint { shadowColor = paint.shadowColor; mBidiFlags = paint.mBidiFlags; + mLocale = paint.mLocale; } /** @hide */ @@ -1045,6 +1053,36 @@ public class Paint { } /** + * Get the text Locale. + * + * @return the paint's Locale used for drawing text, never null. + */ + public Locale getTextLocale() { + return mLocale; + } + + /** + * Set the text locale. + * + * This controls how the text will be drawn. Providing the ROOT Locale (default case) + * means that the text will be drawn with the font corresponding to its script. + * + * Using the CHINESE or CHINA Locale means that the text will be drawn with a Chinese font. + * Using the JAPANESE or JAPAN Locale means that the text will be drawn with a Japanese font. + * Using the KOREAN or KOREA Locale means that the text will be drawn with a Korean font. + * + * @param locale the paint's locale value for drawing text, must not be null. + */ + public void setTextLocale(Locale locale) { + if (locale == null) { + throw new IllegalArgumentException("locale cannot be null"); + } + if (locale.equals(mLocale)) return; + mLocale = locale; + native_setTextLocale(mNativePaint, locale.toString()); + } + + /** * Return the paint's text size. * * @return the paint's text size. @@ -2144,6 +2182,9 @@ public class Paint { private static native void native_setTextAlign(int native_object, int align); + private static native void native_setTextLocale(int native_object, + String locale); + private static native int native_getTextWidths(int native_object, char[] text, int index, int count, float[] widths); private static native int native_getTextWidths(int native_object, |