diff options
| author | 2012-04-12 19:07:57 -0700 | |
|---|---|---|
| committer | 2012-04-12 19:07:57 -0700 | |
| commit | 069c4f3f0c8190289d60296ec54fafa56abb4776 (patch) | |
| tree | 089320bba4a4068c4c212edce119dcb4f2961fea /graphics/java/android | |
| parent | 882735972e9e7ee52a3116a3aba0440968b2da1a (diff) | |
| parent | 029b6330380a21787647ed9faa9aa2d6ee93da82 (diff) | |
Merge "Improve Paint.setTextLocale()"
Diffstat (limited to 'graphics/java/android')
| -rw-r--r-- | graphics/java/android/graphics/Paint.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index 8cb8466ba71d..f68f9dce8eff 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -352,7 +352,7 @@ public class Paint { // setHinting(DisplayMetrics.DENSITY_DEVICE >= DisplayMetrics.DENSITY_TV // ? HINTING_OFF : HINTING_ON); mCompatScaling = mInvCompatScaling = 1; - mLocale = Locale.getDefault(); + setTextLocale(Locale.getDefault()); } /** @@ -365,7 +365,6 @@ public class Paint { public Paint(Paint paint) { mNativePaint = native_initWithPaint(paint.mNativePaint); setClassVariablesFrom(paint); - mLocale = paint.mLocale; } /** Restores the paint to its default settings. */ @@ -379,7 +378,7 @@ public class Paint { mHasCompatScaling = false; mCompatScaling = mInvCompatScaling = 1; mBidiFlags = BIDI_DEFAULT_LTR; - mLocale = Locale.getDefault(); + setTextLocale(Locale.getDefault()); } /** @@ -1064,12 +1063,26 @@ public class Paint { /** * 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. + * The text locale affects how the text is drawn for some languages. + * + * For example, if the locale is {@link Locale#CHINESE} or {@link Locale#CHINA}, + * then the text renderer will prefer to draw text using a Chinese font. Likewise, + * if the locale is {@link Locale#JAPANESE} or {@link Locale#JAPAN}, then the text + * renderer will prefer to draw text using a Japanese font. + * + * This distinction is important because Chinese and Japanese text both use many + * of the same Unicode code points but their appearance is subtly different for + * each language. + * + * By default, the text locale is initialized to the system locale (as returned + * by {@link Locale#getDefault}). This assumes that the text to be rendered will + * most likely be in the user's preferred language. * - * 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. + * If the actual language of the text is known, then it can be provided to the + * text renderer using this method. The text renderer may attempt to guess the + * language script based on the contents of the text to be drawn independent of + * the text locale here. Specifying the text locale just helps it do a better + * job in certain ambiguous cases * * @param locale the paint's locale value for drawing text, must not be null. */ |