summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/current.txt4
-rw-r--r--core/java/android/text/flags/flags.aconfig7
-rw-r--r--graphics/java/android/graphics/Paint.java46
3 files changed, 55 insertions, 2 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 13e12101b3d5..a134683efa1a 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -16704,7 +16704,7 @@ package android.graphics {
method public boolean hasGlyph(String);
method public final boolean isAntiAlias();
method public final boolean isDither();
- method public boolean isElegantTextHeight();
+ method @Deprecated @FlaggedApi("com.android.text.flags.deprecate_elegant_text_height_api") public boolean isElegantTextHeight();
method public final boolean isFakeBoldText();
method public final boolean isFilterBitmap();
method public final boolean isLinearText();
@@ -16725,7 +16725,7 @@ package android.graphics {
method public void setColor(@ColorLong long);
method public android.graphics.ColorFilter setColorFilter(android.graphics.ColorFilter);
method public void setDither(boolean);
- method public void setElegantTextHeight(boolean);
+ method @Deprecated @FlaggedApi("com.android.text.flags.deprecate_elegant_text_height_api") public void setElegantTextHeight(boolean);
method public void setEndHyphenEdit(int);
method public void setFakeBoldText(boolean);
method public void setFilterBitmap(boolean);
diff --git a/core/java/android/text/flags/flags.aconfig b/core/java/android/text/flags/flags.aconfig
index 09b2201efb4e..e830d89d3116 100644
--- a/core/java/android/text/flags/flags.aconfig
+++ b/core/java/android/text/flags/flags.aconfig
@@ -195,3 +195,10 @@ flag {
description: "Feature flag for adding a TYPE_DURATION to TtsSpan"
bug: "337103893"
}
+
+flag {
+ name: "deprecate_elegant_text_height_api"
+ namespace: "text"
+ description: "Deprecate the Paint#elegantTextHeight API and stick it to true"
+ bug: "349519475"
+}
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 68d8ebbbdabf..b7a1c13c75c7 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -18,6 +18,8 @@ package android.graphics;
import static com.android.text.flags.Flags.FLAG_FIX_LINE_HEIGHT_FOR_LOCALE;
import static com.android.text.flags.Flags.FLAG_LETTER_SPACING_JUSTIFICATION;
+import static com.android.text.flags.Flags.FLAG_DEPRECATE_ELEGANT_TEXT_HEIGHT_API;
+
import android.annotation.ColorInt;
import android.annotation.ColorLong;
@@ -39,6 +41,7 @@ import android.text.GraphicsOperations;
import android.text.SpannableString;
import android.text.SpannedString;
import android.text.TextUtils;
+import android.util.Log;
import com.android.internal.annotations.GuardedBy;
import com.android.text.flags.Flags;
@@ -61,6 +64,7 @@ import java.util.Objects;
* geometries, text and bitmaps.
*/
public class Paint {
+ private static final String TAG = "Paint";
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private long mNativePaint;
@@ -1803,8 +1807,18 @@ public class Paint {
/**
* Get the elegant metrics flag.
*
+ * Note:
+ * For applications target API 35 or later, this function returns true by default.
+ * For applications target API 36 or later, the function call will be ignored and the elegant
+ * text height is always enabled.
+ *
* @return true if elegant metrics are enabled for text drawing.
+ * @deprecated The underlying UI fonts are deprecated and will be removed from the system image.
+ * Applications supporting scripts with large vertical metrics should adapt their UI by using
+ * fonts designed with corresponding vertical metrics.
*/
+ @Deprecated
+ @FlaggedApi(FLAG_DEPRECATE_ELEGANT_TEXT_HEIGHT_API)
public boolean isElegantTextHeight() {
return nGetElegantTextHeight(mNativePaint) != ELEGANT_TEXT_HEIGHT_DISABLED;
}
@@ -1819,9 +1833,28 @@ public class Paint {
* variants that have not been compacted to fit Latin-based vertical
* metrics, and also increases top and bottom bounds to provide more space.
*
+ * <p>
+ * Note:
+ * For applications target API 35 or later, the default value will be true by default.
+ * For applications target API 36 or later, the function call will be ignored and the elegant
+ * text height is always enabled.
+ *
* @param elegant set the paint's elegant metrics flag for drawing text.
+ * @deprecated This API will be no-op at some point in the future. The underlying UI fonts is
+ * deprecated and will be removed from the system image. Applications supporting scripts with
+ * large vertical metrics should adapt their UI by using fonts designed with corresponding
+ * vertical metrics.
*/
+ @Deprecated
+ @FlaggedApi(FLAG_DEPRECATE_ELEGANT_TEXT_HEIGHT_API)
public void setElegantTextHeight(boolean elegant) {
+ if (Flags.deprecateElegantTextHeightApi() && !elegant
+ && CompatChanges.isChangeEnabled(DEPRECATE_UI_FONT_ENFORCE)) {
+ if (!elegant) {
+ Log.w(TAG, "The elegant text height cannot be turned off.");
+ }
+ return;
+ }
nSetElegantTextHeight(mNativePaint,
elegant ? ELEGANT_TEXT_HEIGHT_ENABLED : ELEGANT_TEXT_HEIGHT_DISABLED);
}
@@ -1839,6 +1872,19 @@ public class Paint {
@EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
public static final long DEPRECATE_UI_FONT = 279646685L;
+ /**
+ * A change ID for deprecating UI fonts enforced.
+ *
+ * From API 36, the elegant text height will not be able to be overridden and always true if the
+ * app has a target SDK of API 36 or later.
+ *
+ * @hide
+ */
+ @ChangeId
+ @EnabledSince(targetSdkVersion = 36)
+ public static final long DEPRECATE_UI_FONT_ENFORCE = 349519475L;
+
+
private void resetElegantTextHeight() {
if (CompatChanges.isChangeEnabled(DEPRECATE_UI_FONT)) {
nSetElegantTextHeight(mNativePaint, ELEGANT_TEXT_HEIGHT_UNSET);