Loading core/java/android/widget/TextView.java +52 −1 Original line number Diff line number Diff line Loading @@ -658,6 +658,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener float dx = 0, dy = 0, r = 0; boolean elegant = false; float letterSpacing = 0; String fontFeatureSettings = null; final Resources.Theme theme = context.getTheme(); Loading Loading @@ -742,6 +743,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case com.android.internal.R.styleable.TextAppearance_letterSpacing: letterSpacing = appearance.getFloat(attr, 0); break; case com.android.internal.R.styleable.TextAppearance_fontFeatureSettings: fontFeatureSettings = appearance.getString(attr); break; } } Loading Loading @@ -1087,6 +1092,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case com.android.internal.R.styleable.TextView_letterSpacing: letterSpacing = a.getFloat(attr, 0); break; case com.android.internal.R.styleable.TextView_fontFeatureSettings: fontFeatureSettings = a.getString(attr); break; } } a.recycle(); Loading Loading @@ -1269,6 +1278,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setRawTextSize(textSize); setElegantTextHeight(elegant); setLetterSpacing(letterSpacing); setFontFeatureSettings(fontFeatureSettings); if (allCaps) { setTransformationMethod(new AllCapsTransformationMethod(getContext())); Loading Loading @@ -2502,6 +2512,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener com.android.internal.R.styleable.TextAppearance_letterSpacing, 0)); } if (appearance.hasValue(com.android.internal.R.styleable.TextAppearance_fontFeatureSettings)) { setFontFeatureSettings(appearance.getString( com.android.internal.R.styleable.TextAppearance_fontFeatureSettings)); } appearance.recycle(); } Loading Loading @@ -2686,6 +2701,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * This will normally be 0. * * @see #setLetterSpacing(float) * @see Paint#setLetterSpacing * @hide */ public float getLetterSpacing() { Loading @@ -2697,7 +2713,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * for slight expansion will be around 0.05. Negative values tighten text. * * @see #getLetterSpacing() * @see Paint#setFlags * @see Paint#getLetterSpacing * * @attr ref android.R.styleable#TextView_letterSpacing * @hide Loading @@ -2715,6 +2731,41 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } /** * @return the currently set font feature settings. Default is null. * * @see #setFontFeatureSettings(String) * @see Paint#setFontFeatureSettings * @hide */ public String getFontFeatureSettings() { return mTextPaint.getFontFeatureSettings(); } /** * Sets font feature settings. The format is the same as the CSS * font-feature-settings attribute: * http://dev.w3.org/csswg/css-fonts/#propdef-font-feature-settings * * @see #getFontFeatureSettings() * @see Paint#getFontFeatureSettings * * @attr ref android.R.styleable#TextView_fontFeatureSettings * @hide */ @android.view.RemotableViewMethod public void setFontFeatureSettings(String fontFeatureSettings) { if (fontFeatureSettings != mTextPaint.getFontFeatureSettings()) { mTextPaint.setFontFeatureSettings(fontFeatureSettings); if (mLayout != null) { nullLayouts(); requestLayout(); invalidate(); } } } /** * Sets the text color for all the states (normal, selected, Loading core/jni/android/graphics/Paint.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -430,9 +430,9 @@ public: static void setFontFeatureSettings(JNIEnv* env, jobject clazz, jlong paintHandle, jstring settings) { Paint* paint = reinterpret_cast<Paint*>(paintHandle); if (!settings) if (!settings) { paint->setFontFeatureSettings(std::string()); else { } else { ScopedUtfChars settingsChars(env, settings); paint->setFontFeatureSettings(std::string(settingsChars.c_str(), settingsChars.size())); } Loading core/res/res/values/attrs.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3784,6 +3784,8 @@ <attr name="elegantTextHeight" format="boolean" /> <!-- Text letter-spacing. --> <attr name="letterSpacing" format="float" /> <!-- Font feature settings. --> <attr name="fontFeatureSettings" format="string" /> </declare-styleable> <declare-styleable name="TextClock"> <!-- Specifies the formatting pattern used to show the time and/or date Loading Loading @@ -4079,6 +4081,8 @@ <attr name="elegantTextHeight" /> <!-- Text letter-spacing. --> <attr name="letterSpacing" /> <!-- Font feature settings. --> <attr name="fontFeatureSettings" /> </declare-styleable> <declare-styleable name="TextViewAppearance"> <!-- Base text color, typeface, size, and style. --> Loading graphics/java/android/graphics/Paint.java +5 −2 Original line number Diff line number Diff line Loading @@ -1305,10 +1305,13 @@ public class Paint { * @hide */ public void setFontFeatureSettings(String settings) { if (settings != null && settings.equals("")) if (settings != null && settings.equals("")) { settings = null; } if ((settings == null && mFontFeatureSettings == null) || (settings != null && settings.equals(mFontFeatureSettings))) return; || (settings != null && settings.equals(mFontFeatureSettings))) { return; } mFontFeatureSettings = settings; native_setFontFeatureSettings(mNativePaint, settings); } Loading Loading
core/java/android/widget/TextView.java +52 −1 Original line number Diff line number Diff line Loading @@ -658,6 +658,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener float dx = 0, dy = 0, r = 0; boolean elegant = false; float letterSpacing = 0; String fontFeatureSettings = null; final Resources.Theme theme = context.getTheme(); Loading Loading @@ -742,6 +743,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case com.android.internal.R.styleable.TextAppearance_letterSpacing: letterSpacing = appearance.getFloat(attr, 0); break; case com.android.internal.R.styleable.TextAppearance_fontFeatureSettings: fontFeatureSettings = appearance.getString(attr); break; } } Loading Loading @@ -1087,6 +1092,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case com.android.internal.R.styleable.TextView_letterSpacing: letterSpacing = a.getFloat(attr, 0); break; case com.android.internal.R.styleable.TextView_fontFeatureSettings: fontFeatureSettings = a.getString(attr); break; } } a.recycle(); Loading Loading @@ -1269,6 +1278,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setRawTextSize(textSize); setElegantTextHeight(elegant); setLetterSpacing(letterSpacing); setFontFeatureSettings(fontFeatureSettings); if (allCaps) { setTransformationMethod(new AllCapsTransformationMethod(getContext())); Loading Loading @@ -2502,6 +2512,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener com.android.internal.R.styleable.TextAppearance_letterSpacing, 0)); } if (appearance.hasValue(com.android.internal.R.styleable.TextAppearance_fontFeatureSettings)) { setFontFeatureSettings(appearance.getString( com.android.internal.R.styleable.TextAppearance_fontFeatureSettings)); } appearance.recycle(); } Loading Loading @@ -2686,6 +2701,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * This will normally be 0. * * @see #setLetterSpacing(float) * @see Paint#setLetterSpacing * @hide */ public float getLetterSpacing() { Loading @@ -2697,7 +2713,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * for slight expansion will be around 0.05. Negative values tighten text. * * @see #getLetterSpacing() * @see Paint#setFlags * @see Paint#getLetterSpacing * * @attr ref android.R.styleable#TextView_letterSpacing * @hide Loading @@ -2715,6 +2731,41 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } /** * @return the currently set font feature settings. Default is null. * * @see #setFontFeatureSettings(String) * @see Paint#setFontFeatureSettings * @hide */ public String getFontFeatureSettings() { return mTextPaint.getFontFeatureSettings(); } /** * Sets font feature settings. The format is the same as the CSS * font-feature-settings attribute: * http://dev.w3.org/csswg/css-fonts/#propdef-font-feature-settings * * @see #getFontFeatureSettings() * @see Paint#getFontFeatureSettings * * @attr ref android.R.styleable#TextView_fontFeatureSettings * @hide */ @android.view.RemotableViewMethod public void setFontFeatureSettings(String fontFeatureSettings) { if (fontFeatureSettings != mTextPaint.getFontFeatureSettings()) { mTextPaint.setFontFeatureSettings(fontFeatureSettings); if (mLayout != null) { nullLayouts(); requestLayout(); invalidate(); } } } /** * Sets the text color for all the states (normal, selected, Loading
core/jni/android/graphics/Paint.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -430,9 +430,9 @@ public: static void setFontFeatureSettings(JNIEnv* env, jobject clazz, jlong paintHandle, jstring settings) { Paint* paint = reinterpret_cast<Paint*>(paintHandle); if (!settings) if (!settings) { paint->setFontFeatureSettings(std::string()); else { } else { ScopedUtfChars settingsChars(env, settings); paint->setFontFeatureSettings(std::string(settingsChars.c_str(), settingsChars.size())); } Loading
core/res/res/values/attrs.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3784,6 +3784,8 @@ <attr name="elegantTextHeight" format="boolean" /> <!-- Text letter-spacing. --> <attr name="letterSpacing" format="float" /> <!-- Font feature settings. --> <attr name="fontFeatureSettings" format="string" /> </declare-styleable> <declare-styleable name="TextClock"> <!-- Specifies the formatting pattern used to show the time and/or date Loading Loading @@ -4079,6 +4081,8 @@ <attr name="elegantTextHeight" /> <!-- Text letter-spacing. --> <attr name="letterSpacing" /> <!-- Font feature settings. --> <attr name="fontFeatureSettings" /> </declare-styleable> <declare-styleable name="TextViewAppearance"> <!-- Base text color, typeface, size, and style. --> Loading
graphics/java/android/graphics/Paint.java +5 −2 Original line number Diff line number Diff line Loading @@ -1305,10 +1305,13 @@ public class Paint { * @hide */ public void setFontFeatureSettings(String settings) { if (settings != null && settings.equals("")) if (settings != null && settings.equals("")) { settings = null; } if ((settings == null && mFontFeatureSettings == null) || (settings != null && settings.equals(mFontFeatureSettings))) return; || (settings != null && settings.equals(mFontFeatureSettings))) { return; } mFontFeatureSettings = settings; native_setFontFeatureSettings(mNativePaint, settings); } Loading