[go: nahoru, domu]

Fix LayoutIntrinsics maxIntrinsicWidth

Here is a setup for the failure:
* Pixel 4
* Android 11
* density=3.051f
* fontScale=1.15f
* letterSpacing has to be set
* lineHeight has to be set

When those values are set:
* Layout.getDesiredWith calculates 441 to be the
  width
* StaticLayout is created, but it still produces
  2 lines with 441 max width.
* When 442 is passed to StaticLayout it correctly
  creates a 1 line layout.

This causes a two line layout instead of 1 line,
which becomes very visible for TextField labels.

The issue reproduces on Android 11 and above.

This CL introduces a change when the exact
conditions are met, returns +0.1 for the
maxIntrinsicWidth so that 1 line can be produced.
- tested with same size: fails
- tested with 0.1: passes
- tested with 0.0001: passes
- tested with 0.00001: fails

Test: ./gradlew text:text:cAT
Test: ./gradlew text:text:test
Test: ./gradlew compose:ui:ui-text:test
Test: ./gradlew compose:ui:ui-text:cAT
Test: ./gradlew compose:foundation:foundation:cAT
Test: ./gradlew compose:foundation:foundation:test

RelNote: N/A

Bug: 173574230
Change-Id: Ic81e532d00de67af5ad88946052f835e56afcaf0
diff --git a/compose/ui/ui-text/api/current.txt b/compose/ui/ui-text/api/current.txt
index 6c4d62d..43d56d1 100644
--- a/compose/ui/ui-text/api/current.txt
+++ b/compose/ui/ui-text/api/current.txt
@@ -482,6 +482,9 @@
   public final class LayoutIntrinsicsKt {
   }
 
+  public final class SpannedExtensionsKt {
+  }
+
   public final class TempListUtilsKt {
   }