diff options
| author | 2024-04-05 15:12:33 +0000 | |
|---|---|---|
| committer | 2024-04-05 15:12:33 +0000 | |
| commit | c8f57e170ada2495b79f16fc7bf5fc17c53ec12e (patch) | |
| tree | 39e5e6da75c4418d406d1395f007413c75b13535 | |
| parent | 30da9b259b693082ee6558442739dd86973dbf39 (diff) | |
| parent | cb85253c098989c393fb9cd9ba450fdeaa55b9d8 (diff) | |
Merge "Add 1.05 and 1.2 as new possible font scale values" into 24D1-dev
| -rw-r--r-- | core/java/android/content/res/FontScaleConverterFactory.java | 22 | ||||
| -rw-r--r-- | core/tests/coretests/src/android/content/res/FontScaleConverterFactoryTest.kt | 2 |
2 files changed, 23 insertions, 1 deletions
diff --git a/core/java/android/content/res/FontScaleConverterFactory.java b/core/java/android/content/res/FontScaleConverterFactory.java index 625d7cb66900..c7237ea35c2a 100644 --- a/core/java/android/content/res/FontScaleConverterFactory.java +++ b/core/java/android/content/res/FontScaleConverterFactory.java @@ -58,6 +58,16 @@ public class FontScaleConverterFactory { synchronized (LOOKUP_TABLES_WRITE_LOCK) { putInto( sLookupTables, + /* scaleKey= */ 1.05f, + new FontScaleConverterImpl( + /* fromSp= */ + new float[] { 8f, 10f, 12f, 14f, 18f, 20f, 24f, 30f, 100}, + /* toDp= */ + new float[] { 8.4f, 10.5f, 12.6f, 14.8f, 18.6f, 20.6f, 24.4f, 30f, 100}) + ); + + putInto( + sLookupTables, /* scaleKey= */ 1.1f, new FontScaleConverterImpl( /* fromSp= */ @@ -78,6 +88,16 @@ public class FontScaleConverterFactory { putInto( sLookupTables, + /* scaleKey= */ 1.2f, + new FontScaleConverterImpl( + /* fromSp= */ + new float[] { 8f, 10f, 12f, 14f, 18f, 20f, 24f, 30f, 100}, + /* toDp= */ + new float[] { 9.6f, 12f, 14.4f, 17.2f, 20.4f, 22.4f, 25.6f, 30f, 100}) + ); + + putInto( + sLookupTables, /* scaleKey= */ 1.3f, new FontScaleConverterImpl( /* fromSp= */ @@ -117,7 +137,7 @@ public class FontScaleConverterFactory { ); } - sMinScaleBeforeCurvesApplied = getScaleFromKey(sLookupTables.keyAt(0)) - 0.02f; + sMinScaleBeforeCurvesApplied = getScaleFromKey(sLookupTables.keyAt(0)) - 0.01f; if (sMinScaleBeforeCurvesApplied <= 1.0f) { throw new IllegalStateException( "You should only apply non-linear scaling to font scales > 1" diff --git a/core/tests/coretests/src/android/content/res/FontScaleConverterFactoryTest.kt b/core/tests/coretests/src/android/content/res/FontScaleConverterFactoryTest.kt index a2a5433eca24..c7d5825733ae 100644 --- a/core/tests/coretests/src/android/content/res/FontScaleConverterFactoryTest.kt +++ b/core/tests/coretests/src/android/content/res/FontScaleConverterFactoryTest.kt @@ -175,10 +175,12 @@ class FontScaleConverterFactoryTest { assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(-1f)).isFalse() assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(0.85f)).isFalse() assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(1.02f)).isFalse() + assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(1.05f)).isTrue() assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(1.10f)).isTrue() assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(1.15f)).isTrue() assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(1.1499999f)) .isTrue() + assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(1.2f)).isTrue() assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(1.5f)).isTrue() assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(2f)).isTrue() assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(3f)).isTrue() |