diff options
| author | 2024-07-23 12:17:29 +0000 | |
|---|---|---|
| committer | 2024-07-23 12:19:49 +0000 | |
| commit | 6b77d9c1c7eb79d6168ca04f72f497e842057c54 (patch) | |
| tree | 1e742c0c3a6e3179415e04fc8b5811f61b1da64b | |
| parent | 10d1fca8b6e07e94056488067983353a348cc9ec (diff) | |
Revert "Clear variation settings when setTypeface is called"
Revert submission 28370361-clear_variation_settings
Reason for revert: b/354737113
Reverted changes: /q/submissionid:28370361-clear_variation_settings
Change-Id: Ice8bdc3e4f0c105e615db5e4a390a2cb8e514fd3
| -rw-r--r-- | core/java/android/text/ClientFlags.java | 7 | ||||
| -rw-r--r-- | core/java/android/text/TextFlags.java | 2 | ||||
| -rw-r--r-- | graphics/java/android/graphics/Paint.java | 29 |
3 files changed, 3 insertions, 35 deletions
diff --git a/core/java/android/text/ClientFlags.java b/core/java/android/text/ClientFlags.java index b07534f5fe52..5d84d17bdb6e 100644 --- a/core/java/android/text/ClientFlags.java +++ b/core/java/android/text/ClientFlags.java @@ -68,11 +68,4 @@ public class ClientFlags { public static boolean fixMisalignedContextMenu() { return TextFlags.isFeatureEnabled(Flags.FLAG_FIX_MISALIGNED_CONTEXT_MENU); } - - /** - * @see Flags#clearFontVariationSettings() - */ - public static boolean clearFontVariationSettings() { - return TextFlags.isFeatureEnabled(Flags.FLAG_CLEAR_FONT_VARIATION_SETTINGS); - } } diff --git a/core/java/android/text/TextFlags.java b/core/java/android/text/TextFlags.java index 4dca284b8a4d..9e02460d2637 100644 --- a/core/java/android/text/TextFlags.java +++ b/core/java/android/text/TextFlags.java @@ -61,7 +61,6 @@ public final class TextFlags { Flags.FLAG_FIX_LINE_HEIGHT_FOR_LOCALE, Flags.FLAG_ICU_BIDI_MIGRATION, Flags.FLAG_FIX_MISALIGNED_CONTEXT_MENU, - Flags.FLAG_CLEAR_FONT_VARIATION_SETTINGS, }; /** @@ -76,7 +75,6 @@ public final class TextFlags { Flags.fixLineHeightForLocale(), Flags.icuBidiMigration(), Flags.fixMisalignedContextMenu(), - Flags.clearFontVariationSettings(), }; /** diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index b83931fa0615..df95a91d72d7 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -35,7 +35,6 @@ import android.compat.annotation.UnsupportedAppUsage; import android.graphics.fonts.FontVariationAxis; import android.os.Build; import android.os.LocaleList; -import android.text.ClientFlags; import android.text.GraphicsOperations; import android.text.SpannableString; import android.text.SpannedString; @@ -1541,21 +1540,8 @@ public class Paint { * @return typeface */ public Typeface setTypeface(Typeface typeface) { - return setTypefaceInternal(typeface, true); - } - - private Typeface setTypefaceInternal(Typeface typeface, boolean clearFontVariationSettings) { final long typefaceNative = typeface == null ? 0 : typeface.native_instance; nSetTypeface(mNativePaint, typefaceNative); - - if (ClientFlags.clearFontVariationSettings()) { - if (clearFontVariationSettings && !Objects.equals(mTypeface, typeface)) { - // We cannot call setFontVariationSetting with empty string or null because it calls - // setTypeface method. To avoid recursive setTypeface call, manually resetting - // mFontVariationSettings. - mFontVariationSettings = null; - } - } mTypeface = typeface; return typeface; } @@ -2051,14 +2037,6 @@ public class Paint { * </li> * </ul> * - * Note: This method replaces the Typeface previously set to this instance. - * Until API {@link Build.VERSION_CODES.VANILLA_ICE_CREAM}, any caller of - * {@link #setTypeface(Typeface)} should call this method with empty settings, then call - * {@link #setTypeface(Typeface)}, then call this method with preferred variation settings. - * The device API more than {@link Build.VERSION_CODES.VANILLA_ICE_CREAM}, the - * {@link #setTypeface(Typeface)} method clears font variation settings. So caller of - * {@link #setTypeface(Typeface)} should call this method again for applying variation settings. - * * @param fontVariationSettings font variation settings. You can pass null or empty string as * no variation settings. * @@ -2081,8 +2059,8 @@ public class Paint { if (settings == null || settings.length() == 0) { mFontVariationSettings = null; - setTypefaceInternal(Typeface.createFromTypefaceWithVariation(mTypeface, - Collections.emptyList()), false); + setTypeface(Typeface.createFromTypefaceWithVariation(mTypeface, + Collections.emptyList())); return true; } @@ -2100,8 +2078,7 @@ public class Paint { return false; } mFontVariationSettings = settings; - setTypefaceInternal(Typeface.createFromTypefaceWithVariation(targetTypeface, filteredAxes), - false); + setTypeface(Typeface.createFromTypefaceWithVariation(targetTypeface, filteredAxes)); return true; } |