Merge "Make LineHeightStyle.Alignment constructor public" into androidx-main
diff --git a/compose/ui/ui-text/api/current.txt b/compose/ui/ui-text/api/current.txt
index 82a4c5f..9e181d6 100644
--- a/compose/ui/ui-text/api/current.txt
+++ b/compose/ui/ui-text/api/current.txt
@@ -1280,10 +1280,10 @@
   }
 
   public final class LineHeightStyle {
-    ctor public LineHeightStyle(int alignment, int trim);
-    method public int getAlignment();
+    ctor public LineHeightStyle(float alignment, int trim);
+    method public float getAlignment();
     method public int getTrim();
-    property public final int alignment;
+    property public final float alignment;
     property public final int trim;
     field public static final androidx.compose.ui.text.style.LineHeightStyle.Companion Companion;
   }
@@ -1293,14 +1293,14 @@
   }
 
   public static final class LineHeightStyle.Alignment.Companion {
-    method public int getBottom();
-    method public int getCenter();
-    method public int getProportional();
-    method public int getTop();
-    property public final int Bottom;
-    property public final int Center;
-    property public final int Proportional;
-    property public final int Top;
+    method public float getBottom();
+    method public float getCenter();
+    method public float getProportional();
+    method public float getTop();
+    property public final float Bottom;
+    property public final float Center;
+    property public final float Proportional;
+    property public final float Top;
   }
 
   public static final class LineHeightStyle.Companion {
diff --git a/compose/ui/ui-text/api/public_plus_experimental_current.txt b/compose/ui/ui-text/api/public_plus_experimental_current.txt
index 9b75211..fb80120 100644
--- a/compose/ui/ui-text/api/public_plus_experimental_current.txt
+++ b/compose/ui/ui-text/api/public_plus_experimental_current.txt
@@ -1344,27 +1344,28 @@
   }
 
   public final class LineHeightStyle {
-    ctor public LineHeightStyle(int alignment, int trim);
-    method public int getAlignment();
+    ctor public LineHeightStyle(float alignment, int trim);
+    method public float getAlignment();
     method public int getTrim();
-    property public final int alignment;
+    property public final float alignment;
     property public final int trim;
     field public static final androidx.compose.ui.text.style.LineHeightStyle.Companion Companion;
   }
 
   @kotlin.jvm.JvmInline public static final value class LineHeightStyle.Alignment {
+    ctor @androidx.compose.ui.text.ExperimentalTextApi public LineHeightStyle.Alignment(float topRatio);
     field public static final androidx.compose.ui.text.style.LineHeightStyle.Alignment.Companion Companion;
   }
 
   public static final class LineHeightStyle.Alignment.Companion {
-    method public int getBottom();
-    method public int getCenter();
-    method public int getProportional();
-    method public int getTop();
-    property public final int Bottom;
-    property public final int Center;
-    property public final int Proportional;
-    property public final int Top;
+    method public float getBottom();
+    method public float getCenter();
+    method public float getProportional();
+    method public float getTop();
+    property public final float Bottom;
+    property public final float Center;
+    property public final float Proportional;
+    property public final float Top;
   }
 
   public static final class LineHeightStyle.Companion {
diff --git a/compose/ui/ui-text/api/restricted_current.txt b/compose/ui/ui-text/api/restricted_current.txt
index 82a4c5f..9e181d6 100644
--- a/compose/ui/ui-text/api/restricted_current.txt
+++ b/compose/ui/ui-text/api/restricted_current.txt
@@ -1280,10 +1280,10 @@
   }
 
   public final class LineHeightStyle {
-    ctor public LineHeightStyle(int alignment, int trim);
-    method public int getAlignment();
+    ctor public LineHeightStyle(float alignment, int trim);
+    method public float getAlignment();
     method public int getTrim();
-    property public final int alignment;
+    property public final float alignment;
     property public final int trim;
     field public static final androidx.compose.ui.text.style.LineHeightStyle.Companion Companion;
   }
@@ -1293,14 +1293,14 @@
   }
 
   public static final class LineHeightStyle.Alignment.Companion {
-    method public int getBottom();
-    method public int getCenter();
-    method public int getProportional();
-    method public int getTop();
-    property public final int Bottom;
-    property public final int Center;
-    property public final int Proportional;
-    property public final int Top;
+    method public float getBottom();
+    method public float getCenter();
+    method public float getProportional();
+    method public float getTop();
+    property public final float Bottom;
+    property public final float Center;
+    property public final float Proportional;
+    property public final float Top;
   }
 
   public static final class LineHeightStyle.Companion {
diff --git a/compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt b/compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
index f07c68b..ee8ff19 100644
--- a/compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
+++ b/compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
@@ -136,7 +136,7 @@
                 endIndex = endIndex,
                 trimFirstLineTop = lineHeightStyle.trim.isTrimFirstLineTop(),
                 trimLastLineBottom = lineHeightStyle.trim.isTrimLastLineBottom(),
-                topPercentage = lineHeightStyle.alignment.topPercentage
+                topRatio = lineHeightStyle.alignment.topRatio
             ),
             start = 0,
             end = length
diff --git a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/LineHeightStyle.kt b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/LineHeightStyle.kt
index 0e010e9..bb6949a 100644
--- a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/LineHeightStyle.kt
+++ b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/LineHeightStyle.kt
@@ -16,6 +16,7 @@
 
 package androidx.compose.ui.text.style
 
+import androidx.compose.ui.text.ExperimentalTextApi
 import androidx.compose.ui.text.PlatformParagraphStyle
 
 /**
@@ -189,23 +190,26 @@
 
     /**
      * Defines how to align the line in the space provided by the line height.
+     *
+     * @param topRatio the ratio of ascent to ascent+descent in percentage. Valid values are
+     * integers between 0f (inclusive) to 1f (inclusive).
      */
     @kotlin.jvm.JvmInline
-    value class Alignment private constructor(internal val topPercentage: Int) {
+    value class Alignment @ExperimentalTextApi constructor(internal val topRatio: Float) {
 
         init {
-            check(topPercentage in 0..100 || topPercentage == -1) {
-                "topRatio should be in [0..100] range or -1"
+            check(topRatio in 0f..1f || topRatio == -1f) {
+                "topRatio should be in [0..1] range or -1"
             }
         }
 
         override fun toString(): String {
-            return when (topPercentage) {
-                Top.topPercentage -> "LineHeightStyle.Alignment.Top"
-                Center.topPercentage -> "LineHeightStyle.Alignment.Center"
-                Proportional.topPercentage -> "LineHeightStyle.Alignment.Proportional"
-                Bottom.topPercentage -> "LineHeightStyle.Alignment.Bottom"
-                else -> "LineHeightStyle.Alignment(topPercentage = $topPercentage)"
+            return when (topRatio) {
+                Top.topRatio -> "LineHeightStyle.Alignment.Top"
+                Center.topRatio -> "LineHeightStyle.Alignment.Center"
+                Proportional.topRatio -> "LineHeightStyle.Alignment.Proportional"
+                Bottom.topRatio -> "LineHeightStyle.Alignment.Bottom"
+                else -> "LineHeightStyle.Alignment(topPercentage = $topRatio)"
             }
         }
 
@@ -231,7 +235,8 @@
              * +--------+
              * </pre>
              */
-            val Top = Alignment(topPercentage = 0)
+            @OptIn(ExperimentalTextApi::class)
+            val Top = Alignment(topRatio = 0f)
 
             /**
              * Align the line to the center of the space reserved for the line. This configuration
@@ -251,7 +256,8 @@
              * +--------+
              * </pre>
              */
-            val Center = Alignment(topPercentage = 50)
+            @OptIn(ExperimentalTextApi::class)
+            val Center = Alignment(topRatio = 0.5f)
 
             /**
              * Align the line proportional to the ascent and descent values of the line. For example
@@ -259,7 +265,8 @@
              * will be distributed as 8 units to top, and 2 units to the bottom of the line. This is
              * the default behavior.
              */
-            val Proportional = Alignment(topPercentage = -1)
+            @OptIn(ExperimentalTextApi::class)
+            val Proportional = Alignment(topRatio = -1f)
 
             /**
              * Align the line to the bottom of the space reserved for that line. This means that all
@@ -282,7 +289,8 @@
              * +--------+
              * </pre>
              */
-            val Bottom = Alignment(topPercentage = 100)
+            @OptIn(ExperimentalTextApi::class)
+            val Bottom = Alignment(topRatio = 1f)
         }
     }
 }
diff --git a/text/text/src/androidTest/java/androidx/compose/ui/text/android/TextLayoutTest.kt b/text/text/src/androidTest/java/androidx/compose/ui/text/android/TextLayoutTest.kt
index c9b9858..2621b1e 100644
--- a/text/text/src/androidTest/java/androidx/compose/ui/text/android/TextLayoutTest.kt
+++ b/text/text/src/androidTest/java/androidx/compose/ui/text/android/TextLayoutTest.kt
@@ -429,7 +429,7 @@
                 endIndex = text.length,
                 trimFirstLineTop = false,
                 trimLastLineBottom = false,
-                topPercentage = 50
+                topRatio = 0.5f
             ), 0, text.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
         )
 
diff --git a/text/text/src/androidTest/java/androidx/compose/ui/text/android/style/LineHeightStyleSpanTest.kt b/text/text/src/androidTest/java/androidx/compose/ui/text/android/style/LineHeightStyleSpanTest.kt
index 502b37a7..3509ecd 100644
--- a/text/text/src/androidTest/java/androidx/compose/ui/text/android/style/LineHeightStyleSpanTest.kt
+++ b/text/text/src/androidTest/java/androidx/compose/ui/text/android/style/LineHeightStyleSpanTest.kt
@@ -41,7 +41,7 @@
         val fontMetrics = FontMetricsInt(ascent = 1, descent = 1)
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -54,11 +54,11 @@
     /* single line, top percentage 0 */
 
     @Test
-    fun singleLine_topPercentage_0_trimFirstLineTop_false_trimLastLineBottom_false() {
+    fun singleLine_topRatio_0_trimFirstLineTop_false_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 0,
+            topRatio = 0f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -69,11 +69,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_0_trimFirstLineTop_false_trimLastLineBottom_true() {
+    fun singleLine_topRatio_0_trimFirstLineTop_false_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 0,
+            topRatio = 0f,
             trimFirstLineTop = false,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -84,11 +84,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_0_trimFirstLineTop_true_trimLastLineBottom_false() {
+    fun singleLine_topRatio_0_trimFirstLineTop_true_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 0,
+            topRatio = 0f,
             trimFirstLineTop = true,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -99,11 +99,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_0_trimFirstLineTop_true_trimLastLineBottom_true() {
+    fun singleLine_topRatio_0_trimFirstLineTop_true_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 0,
+            topRatio = 0f,
             trimFirstLineTop = true,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -116,11 +116,11 @@
     /* single line, top percentage 100 */
 
     @Test
-    fun singleLine_topPercentage_100_trimFirstLineTop_false_trimLastLineBottom_false() {
+    fun singleLine_topRatio_100_trimFirstLineTop_false_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 100,
+            topRatio = 1f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -131,11 +131,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_100_trimFirstLineTop_false_trimLastLineBottom_true() {
+    fun singleLine_topRatio_100_trimFirstLineTop_false_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 100,
+            topRatio = 1f,
             trimFirstLineTop = false,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -146,11 +146,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_100_trimFirstLineTop_true_trimLastLineBottom_false() {
+    fun singleLine_topRatio_100_trimFirstLineTop_true_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 100,
+            topRatio = 1f,
             trimFirstLineTop = true,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -161,11 +161,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_100_trimFirstLineTop_true_trimLastLineBottom_true() {
+    fun singleLine_topRatio_100_trimFirstLineTop_true_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 100,
+            topRatio = 1f,
             trimFirstLineTop = true,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -178,11 +178,11 @@
     /* single line, top percentage 50 */
 
     @Test
-    fun singleLine_topPercentage_50_trimFirstLineTop_false_trimLastLineBottom_false() {
+    fun singleLine_topRatio_50_trimFirstLineTop_false_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -194,11 +194,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_50_trimFirstLineTop_false_trimLastLineBottom_true() {
+    fun singleLine_topRatio_50_trimFirstLineTop_false_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = false,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -210,11 +210,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_50_trimFirstLineTop_true_trimLastLineBottom_false() {
+    fun singleLine_topRatio_50_trimFirstLineTop_true_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = true,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -226,11 +226,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_50_trimFirstLineTop_true_trimLastLineBottom_true() {
+    fun singleLine_topRatio_50_trimFirstLineTop_true_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = true,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -240,14 +240,14 @@
         assertThat(newFontMetrics.descent).isEqualTo(fontMetrics.descent)
     }
 
-    /* single line, proportional (topPercentage -1) */
+    /* single line, proportional (topRatio -1) */
 
     @Test
-    fun singleLine_topPercentage_proportional_trimFirstLineTop_false_trimLastLineBottom_false() {
+    fun singleLine_topRatio_proportional_trimFirstLineTop_false_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = -1,
+            topRatio = -1f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -260,11 +260,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_proportional_trimFirstLineTop_false_trimLastLineBottom_true() {
+    fun singleLine_topRatio_proportional_trimFirstLineTop_false_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = -1,
+            topRatio = -1f,
             trimFirstLineTop = false,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -277,11 +277,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_proportional_trimFirstLineTop_true_trimLastLineBottom_false() {
+    fun singleLine_topRatio_proportional_trimFirstLineTop_true_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = -1,
+            topRatio = -1f,
             trimFirstLineTop = true,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -293,11 +293,11 @@
     }
 
     @Test
-    fun singleLine_topPercentage_proportional_trimFirstLineTop_true_trimLastLineBottom_true() {
+    fun singleLine_topRatio_proportional_trimFirstLineTop_true_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val newFontMetrics = runSingleLine(
-            topPercentage = -1,
+            topRatio = -1f,
             trimFirstLineTop = true,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -310,11 +310,11 @@
     /* multi line, top percentage = 0 */
 
     @Test
-    fun multiLine_topPercentage_0_trimFirstLineTop_false_trimLastLineBottom_false() {
+    fun multiLine_topRatio_0_trimFirstLineTop_false_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 0,
+            topRatio = 0f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -334,11 +334,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_0_trimFirstLineTop_false_trimLastLineBottom_true() {
+    fun multiLine_topRatio_0_trimFirstLineTop_false_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 0,
+            topRatio = 0f,
             trimFirstLineTop = false,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -358,11 +358,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_0_trimFirstLineTop_true_trimLastLineBottom_false() {
+    fun multiLine_topRatio_0_trimFirstLineTop_true_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 0,
+            topRatio = 0f,
             trimFirstLineTop = true,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -382,11 +382,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_0_trimFirstLineTop_true_trimLastLineBottom_true() {
+    fun multiLine_topRatio_0_trimFirstLineTop_true_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 0,
+            topRatio = 0f,
             trimFirstLineTop = true,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -408,11 +408,11 @@
     /* multi line, top percentage = 100 */
 
     @Test
-    fun multiLine_topPercentage_100_trimFirstLineTop_false_trimLastLineBottom_false() {
+    fun multiLine_topRatio_100_trimFirstLineTop_false_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 100,
+            topRatio = 1f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -432,11 +432,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_100_trimFirstLineTop_false_trimLastLineBottom_true() {
+    fun multiLine_topRatio_100_trimFirstLineTop_false_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 100,
+            topRatio = 1f,
             trimFirstLineTop = false,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -456,11 +456,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_100_trimFirstLineTop_true_trimLastLineBottom_false() {
+    fun multiLine_topRatio_100_trimFirstLineTop_true_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 100,
+            topRatio = 1f,
             trimFirstLineTop = true,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -480,11 +480,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_100_trimFirstLineTop_true_trimLastLineBottom_true() {
+    fun multiLine_topRatio_100_trimFirstLineTop_true_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 100,
+            topRatio = 1f,
             trimFirstLineTop = true,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -506,11 +506,11 @@
     /* multi line, top percentage = 50 */
 
     @Test
-    fun multiLine_topPercentage_50_trimFirstLineTop_false_trimLastLineBottom_false() {
+    fun multiLine_topRatio_50_trimFirstLineTop_false_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -531,11 +531,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_50_trimFirstLineTop_false_trimLastLineBottom_true() {
+    fun multiLine_topRatio_50_trimFirstLineTop_false_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = false,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -556,11 +556,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_50_trimFirstLineTop_true_trimLastLineBottom_false() {
+    fun multiLine_topRatio_50_trimFirstLineTop_true_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = true,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -581,11 +581,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_50_trimFirstLineTop_true_trimLastLineBottom_true() {
+    fun multiLine_topRatio_50_trimFirstLineTop_true_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = true,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -605,14 +605,14 @@
         assertThat(newFontMetrics.descent).isEqualTo(fontMetrics.descent)
     }
 
-    /* multi line, proportional (topPercentage -1) */
+    /* multi line, proportional (topRatio -1) */
 
     @Test
-    fun multiLine_topPercentage_proportional_trimFirstLineTop_false_trimLastLineBottom_false() {
+    fun multiLine_topRatio_proportional_trimFirstLineTop_false_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = -1,
+            topRatio = -1f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -635,11 +635,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_proportional_trimFirstLineTop_false_trimLastLineBottom_true() {
+    fun multiLine_topRatio_proportional_trimFirstLineTop_false_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = -1,
+            topRatio = -1f,
             trimFirstLineTop = false,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -662,11 +662,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_proportional_trimFirstLineTop_true_trimLastLineBottom_false() {
+    fun multiLine_topRatio_proportional_trimFirstLineTop_true_trimLastLineBottom_false() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = -1,
+            topRatio = -1f,
             trimFirstLineTop = true,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -689,11 +689,11 @@
     }
 
     @Test
-    fun multiLine_topPercentage_proportional_trimFirstLineTop_true_trimLastLineBottom_true() {
+    fun multiLine_topRatio_proportional_trimFirstLineTop_true_trimLastLineBottom_true() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = -1,
+            topRatio = -1f,
             trimFirstLineTop = true,
             trimLastLineBottom = true,
             fontMetrics = fontMetrics
@@ -718,11 +718,11 @@
     /* first ascent & last descent diff */
 
     @Test
-    fun singleLine_with_firstLineTop_and_lastLineBottom_topPercentage_50_larger_line_height() {
+    fun singleLine_with_firstLineTop_and_lastLineBottom_topRatio_50_larger_line_height() {
         val fontMetrics = createFontMetrics()
 
         val span = createSingleLineSpan(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             newLineHeight = fontMetrics.doubleLineHeight()
@@ -736,11 +736,11 @@
     }
 
     @Test
-    fun multiLine_with_firstLineTop_and_lastLineBottom_topPercentage_50_larger_line_height() {
+    fun multiLine_with_firstLineTop_and_lastLineBottom_topRatio_50_larger_line_height() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             fontMetrics = fontMetrics
@@ -756,11 +756,11 @@
     }
 
     @Test
-    fun singleLine_with_firstLineTop_and_lastLineBottom_topPercentage_50_smaller_line_height() {
+    fun singleLine_with_firstLineTop_and_lastLineBottom_topRatio_50_smaller_line_height() {
         val fontMetrics = createFontMetrics()
 
         val span = createSingleLineSpan(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             newLineHeight = fontMetrics.lineHeight() / 2
@@ -774,11 +774,11 @@
     }
 
     @Test
-    fun multiLine_with_firstLineTop_and_lastLineBottom_topPercentage_50_smaller_line_height() {
+    fun multiLine_with_firstLineTop_and_lastLineBottom_topRatio_50_smaller_line_height() {
         val fontMetrics = createFontMetrics()
 
         val span = createMultiLineSpan(
-            topPercentage = 50,
+            topRatio = 0.5f,
             trimFirstLineTop = false,
             trimLastLineBottom = false,
             newLineHeight = fontMetrics.lineHeight() / 2
@@ -804,13 +804,13 @@
      * the updated font metrics.
      */
     private fun runSingleLine(
-        topPercentage: Int,
+        topRatio: Float,
         trimFirstLineTop: Boolean,
         trimLastLineBottom: Boolean,
         fontMetrics: FontMetricsInt
     ): FontMetricsInt {
         val span = createSingleLineSpan(
-            topPercentage = topPercentage,
+            topRatio = topRatio,
             trimFirstLineTop = trimFirstLineTop,
             trimLastLineBottom = trimLastLineBottom,
             newLineHeight = fontMetrics.doubleLineHeight()
@@ -823,7 +823,7 @@
      * Creates a LineHeightSpan that covers [SingleLineStartIndex, SingleLineEndIndex].
      */
     private fun createSingleLineSpan(
-        topPercentage: Int,
+        topRatio: Float,
         trimFirstLineTop: Boolean,
         trimLastLineBottom: Boolean,
         newLineHeight: Int
@@ -833,19 +833,19 @@
         endIndex = SingleLineEndIndex,
         trimFirstLineTop = trimFirstLineTop,
         trimLastLineBottom = trimLastLineBottom,
-        topPercentage = topPercentage
+        topRatio = topRatio
     )
 
     /**
      * Creates a LineHeightSpan that covers [MultiLineStartIndex, MultiLineEndIndex].
      */
     private fun createMultiLineSpan(
-        topPercentage: Int,
+        topRatio: Float,
         trimFirstLineTop: Boolean,
         trimLastLineBottom: Boolean,
         fontMetrics: FontMetricsInt
     ): LineHeightStyleSpan = createMultiLineSpan(
-        topPercentage = topPercentage,
+        topRatio = topRatio,
         trimFirstLineTop = trimFirstLineTop,
         trimLastLineBottom = trimLastLineBottom,
         newLineHeight = fontMetrics.doubleLineHeight()
@@ -855,7 +855,7 @@
      * Creates a LineHeightSpan that covers [MultiLineStartIndex, MultiLineEndIndex].
      */
     private fun createMultiLineSpan(
-        topPercentage: Int,
+        topRatio: Float,
         trimFirstLineTop: Boolean,
         trimLastLineBottom: Boolean,
         newLineHeight: Int
@@ -865,7 +865,7 @@
         endIndex = MultiLineEndIndex,
         trimFirstLineTop = trimFirstLineTop,
         trimLastLineBottom = trimLastLineBottom,
-        topPercentage = topPercentage
+        topRatio = topRatio
     )
 
     /**
diff --git a/text/text/src/main/java/androidx/compose/ui/text/android/style/LineHeightStyleSpan.kt b/text/text/src/main/java/androidx/compose/ui/text/android/style/LineHeightStyleSpan.kt
index 55e164a..d0a755a 100644
--- a/text/text/src/main/java/androidx/compose/ui/text/android/style/LineHeightStyleSpan.kt
+++ b/text/text/src/main/java/androidx/compose/ui/text/android/style/LineHeightStyleSpan.kt
@@ -16,7 +16,7 @@
 package androidx.compose.ui.text.android.style
 
 import android.graphics.Paint.FontMetricsInt
-import androidx.annotation.IntRange
+import androidx.annotation.FloatRange
 import androidx.compose.ui.text.android.InternalPlatformTextApi
 import kotlin.math.abs
 import kotlin.math.ceil
@@ -37,7 +37,7 @@
  * as a result of the line height is not added.  Single line text is both the first and last line.
  * @param lineHeight The specified line height in pixel units, which is the space between the
  * baseline of adjacent lines.
- * @param topPercentage The percentage on how to distribute the line height for a given line.
+ * @param topRatio The percentage on how to distribute the line height for a given line.
  * 0 means all space as a result of line height is applied to the bottom. Similarly, 100 means
  * all space as a result of line height is applied to the top.
  *
@@ -50,7 +50,7 @@
     private val endIndex: Int,
     private val trimFirstLineTop: Boolean,
     val trimLastLineBottom: Boolean,
-    @IntRange(from = 0, to = 100) val topPercentage: Int
+    @FloatRange(from = 0.0, to = 1.0) private val topRatio: Float
 ) : android.text.style.LineHeightSpan {
 
     private var firstAscent: Int = 0
@@ -67,8 +67,8 @@
         private set
 
     init {
-        check(topPercentage in 0..100 || topPercentage == -1) {
-            "topRatio should be in [0..100] range or -1"
+        check(topRatio in 0f..1f || topRatio == -1f) {
+            "topRatio should be in [0..1] range or -1"
         }
     }
 
@@ -103,18 +103,18 @@
         // calculate the difference between the current line lineHeight and the requested lineHeight
         val diff = ceiledLineHeight - currentHeight
 
-        val ascentRatio = if (topPercentage == -1) {
-            (abs(fontMetricsInt.ascent.toFloat()) / fontMetricsInt.lineHeight() * 100f).toInt()
+        val ascentRatio = if (topRatio == -1f) {
+            abs(fontMetricsInt.ascent.toFloat()) / fontMetricsInt.lineHeight()
         } else {
-            topPercentage
+            topRatio
         }
 
         val descentDiff = if (diff <= 0) {
-            // diff * topPercentage is the amount that should go to below the baseline
-            ceil(diff * ascentRatio / 100f).toInt()
+            // diff * topRatio is the amount that should go to below the baseline
+            ceil(diff * ascentRatio).toInt()
         } else {
-            // diff * (100 - topPercentage) is the amount that should go to below the baseline
-            ceil(diff * (100 - ascentRatio) / 100f).toInt()
+            // diff * (1f - topRatio) is the amount that should go to below the baseline
+            ceil(diff * (1f - ascentRatio)).toInt()
         }
 
         descent = fontMetricsInt.descent + descentDiff
@@ -136,7 +136,7 @@
         endIndex = endIndex,
         trimFirstLineTop = trimFirstLineTop,
         trimLastLineBottom = trimLastLineBottom,
-        topPercentage = topPercentage
+        topRatio = topRatio
     )
 }