summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tyler Freeman <fuego@google.com> 2023-01-25 17:40:31 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-01-25 17:40:31 +0000
commit04347df896d59aa4d3cbb749ad72811cb31486dd (patch)
tree5b614dd5b7a829cd7b0f7512aba9454e53d9350c
parent5f090c4bb323df0e9ec58e9fbcceec73de23e8b3 (diff)
parentc64189b0c424689d876ed5fcefcc1943077822d7 (diff)
Merge "docs(non linear font scaling): deprecate TypedValue.scaledDensity and add warning on Configuration.fontScale"
-rw-r--r--core/api/current.txt2
-rw-r--r--core/java/android/content/res/Configuration.java8
-rwxr-xr-xcore/java/android/util/DisplayMetrics.java6
3 files changed, 15 insertions, 1 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 8cc166eeb984..2b1616dbb6eb 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -48672,7 +48672,7 @@ package android.util {
field public float density;
field public int densityDpi;
field public int heightPixels;
- field public float scaledDensity;
+ field @Deprecated public float scaledDensity;
field public int widthPixels;
field public float xdpi;
field public float ydpi;
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 0def59f36d80..335975bae393 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -98,6 +98,14 @@ public final class Configuration implements Parcelable, Comparable<Configuration
/**
* Current user preference for the scaling factor for fonts, relative
* to the base density scaling.
+ *
+ * <p>Note: Please do not use this to hardcode font size equations. The equation for font
+ * scaling is now non-linear; this coefficient is no longer used as a direct multiplier to
+ * determine font size. It exists for informational purposes only.
+ *
+ * <p>Please use {@link android.util.TypedValue#applyDimension(int, float, DisplayMetrics)} or
+ * {@link android.util.TypedValue#deriveDimension(int, float, DisplayMetrics)} to convert
+ * between scaled font size dimensions and pixels.
*/
public float fontScale;
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java
index 101a0714bbf4..25ee6aff6ac4 100755
--- a/core/java/android/util/DisplayMetrics.java
+++ b/core/java/android/util/DisplayMetrics.java
@@ -283,7 +283,13 @@ public class DisplayMetrics {
* A scaling factor for fonts displayed on the display. This is the same
* as {@link #density}, except that it may be adjusted in smaller
* increments at runtime based on a user preference for the font size.
+ *
+ * @deprecated this scalar factor is no longer accurate due to adaptive non-linear font scaling.
+ * Please use {@link TypedValue#applyDimension(int, float, DisplayMetrics)} or
+ * {@link TypedValue#deriveDimension(int, float, DisplayMetrics)} to convert between SP font
+ * sizes and pixels.
*/
+ @Deprecated
public float scaledDensity;
/**