From df8ef4b139a8918895f8a5c62536123da06e81fe Mon Sep 17 00:00:00 2001 From: Victoria Lease Date: Fri, 17 Aug 2012 15:34:01 -0700 Subject: DO NOT MERGE LocaleSpan makes Han disambiguation easy! Cherry-pick of I7f1b0d49a2ece957a7b9b5d65d48385bf2c2a668 from master. I've also provided TextView.setTextLocale() for use in single-language TextViews. Change-Id: I5692859bfd2aafc284172454d943afc250b22535 --- core/java/android/widget/TextView.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'core/java/android/widget/TextView.java') diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 5be9899f29bc..f502de450c74 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -2202,6 +2202,27 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener appearance.recycle(); } + /** + * Get the default {@link Locale} of the text in this TextView. + * @return the default {@link Locale} of the text in this TextView. + */ + public Locale getTextLocale() { + return mTextPaint.getTextLocale(); + } + + /** + * Set the default {@link Locale} of the text in this TextView to the given value. This value + * is used to choose appropriate typefaces for ambiguous characters. Typically used for CJK + * locales to disambiguate Hanzi/Kanji/Hanja characters. + * + * @param locale the {@link Locale} for drawing text, must not be null. + * + * @see Paint#setTextLocale + */ + public void setTextLocale(Locale locale) { + mTextPaint.setTextLocale(locale); + } + /** * @return the size (in pixels) of the default text size in this TextView. */ -- cgit v1.2.3