Status Update
Comments
gu...@google.com <gu...@google.com> #2
si...@google.com <si...@google.com> #3
Thanks for the detailed description
This seems like a dup of
si...@google.com <si...@google.com> #5
from
Row(modifier = Modifier.fillMaxWidth()) {
BoxWithText(
Modifier.weight(1f),
"Abc ".repeat(1),
)
BoxWithText(
Modifier.weight(1f),
"Lorem ipsum dolor sit amet",
)
}
Row(modifier = Modifier.fillMaxWidth()) {
BoxWithText(
Modifier.weight(1f),
"Abc ".repeat(1),
)
BoxWithText(
Modifier.weight(1f),
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nibh lacus, finibus vitae nulla ut, tincidunt fringilla arcu.",
)
}
Screenshots attached before/after aosp/2175613
so...@google.com <so...@google.com> #8
re:
we only clipped for Clip overflow. But we fixed this for ellipsis case already in aosp/2170326
no...@google.com <no...@google.com> #9
I debugged why this happens in the framework and here is my result.
In short, the root cause of this issue is that the line width Layout.java calculated at measure time and draw time was different.
On measure time, the letter spacing is not counted for some reasons (
Because we assume this line width is less than constraint's line width but actually not, because the ellipsis point is calculated without letter spacing. For example, the above example on my device has following line widths:
- Constraint line width: 1080px
- Line width until character index 653 without letter spacing (the ellipsis start offset): 1039px
- Line width until character index 653 with letter spacing: 1872px
As the result, this line extent(1082px) is bigger than the constraint line width(1080px), then the drawing offset was shifted 792 px (1872 px - 1080 px).
The correct fix is use the common width calculation when deciding the ellipsis offset and drawing. I agree that this is not fixable in Compose side and workaround is needed.
si...@google.com <si...@google.com> #10
Thanks Nona
work after aosp/2175613
- fix isLineEllipsized
- check if new paddings can be moved into a new object
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit 39222a2f2ffb2a11efcac1e2d2519bbb2bbc0617
Author: siyamed <siyamed@google.com>
Date: Fri Aug 05 18:28:56 2022
Fix letterSpacing with alignment/ellipsis
When letter spacing, align and ellipsize applied to text,
the ellipsized line is indented wrong. For example for
an LTR text, the last line is indented in a way where the
beginning of the line is less than 0 and the text is cut at
the beginning.
This CL fixes the issue by translating canvas for the
ellipsized line accordingly.
Screenshots: go/compose-letterspacing-align-ellipsis
Test: Added tests
Test: ./gradlew text:text:test
Test: ./gradlew text:text:cAT
Test: ./gradlew compose:ui:ui-text:test
Test: ./gradlew compose:ui:ui-text:cAT
RelNote: N/A
Bug: 228463206
Change-Id: I446445949221027e675cb90d2c33a67c55210aad
M compose/ui/ui-text/api/restricted_current.txt
A compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/ParagraphIntegrationIndentationFixTest.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextDemos.kt
M text/text/src/main/java/androidx/compose/ui/text/android/TextLayout.kt
A text/text/src/main/java/androidx/compose/ui/text/android/style/IndentationFixSpan.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/AndroidParagraph.android.kt
M testutils/testutils-fonts/src/commonMain/resources/font/sample_font.ttf
M compose/ui/ui-text/lint-baseline.xml
A compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/EllipsizeWithLetterSpacing.kt
M compose/ui/ui-text/api/public_plus_experimental_current.txt
M testutils/testutils-fonts/src/font_ttx/sample_font.ttx
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeText.kt
M compose/ui/ui-text/api/current.txt
si...@google.com <si...@google.com> #12
fyi: the bug is fixed, there is an internal cleanup waiting.
ca...@gmail.com <ca...@gmail.com> #13
I have updated compose to 1.3.0-beta01, which apparently includes the fix. Now I am encountering a crash if the text is set to an empty string:
java.lang.IndexOutOfBoundsException: setSpan (-1 ... -1) starts before 0
at android.text.SpannableStringInternal.checkRange(SpannableStringInternal.java:499)
at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:199)
at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:186)
at android.text.SpannableString.setSpan(SpannableString.java:60)
at androidx.compose.ui.text.platform.extensions.SpannableExtensions_androidKt.setSpan(SpannableExtensions.android.kt:85)
at androidx.compose.ui.text.AndroidParagraph_androidKt.attachIndentationFixSpan(AndroidParagraph.android.kt:518)
at androidx.compose.ui.text.AndroidParagraph_androidKt.access$attachIndentationFixSpan(AndroidParagraph.android.kt:1)
at androidx.compose.ui.text.AndroidParagraph.<init>(AndroidParagraph.android.kt:118)
...
si...@google.com <si...@google.com> #14
thank you for the prompt feedback will fix asap.
ap...@google.com <ap...@google.com> #15
Branch: androidx-main
commit 9c3edffd83b7f8e76a229fb1e19b347b3161b9dc
Author: siyamed <siyamed@google.com>
Date: Fri Aug 26 15:37:38 2022
Fix empty string exception for indendation span
IndentationFixSpan was added for empty string with length-1.
This CL skips the span addition for empty string.
Test: ./gradlew compose:ui:ui-text:test
Test: ./gradlew compose:ui:ui-text:cAT
Bug: 228463206
Change-Id: I1796a202f4482cd9a34c12afbefaaea693541389
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/ParagraphIntegrationIndentationFixTest.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/AndroidParagraph.android.kt
si...@google.com <si...@google.com>
ap...@google.com <ap...@google.com> #16
Branch: androidx-main
commit c87f79463fba21f76422fb73865186efcd89f64f
Author: siyamed <siyamed@google.com>
Date: Mon Aug 29 10:21:03 2022
Fix isLineEllipsized
isLineEllipsized uses ellipsis start as a signal. This might be
wrong based on the ellipsis type in the future (such as
ellipsis start/mid).
This CL replaces that check with getEllipsisCount > 0.
Test: ./gradlew compose:ui:ui-text:test
Test: ./gradlew compose:ui:ui-text:cAT
Test: ./gradlew text:text:test
Test: ./gradlew text:text:cAT
Bug: 228463206
Change-Id: I29d7eb8fbbe347164bcf3b6a1da1a417f448b79e
A text/text/src/androidTest/java/androidx/compose/ui/text/android/TextLayoutIsLineEllipsizedTest.kt
M text/text/src/main/java/androidx/compose/ui/text/android/TextLayout.kt
M testutils/testutils-fonts/src/font_ttx/sample_font.ttx
M testutils/testutils-fonts/src/commonMain/resources/font/sample_font.ttf
Description
Jetpack Compose version: 1.2.0-alpha05
Jetpack Compose component used: import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.wear.compose.material.Text
Android Studio Build: N/A
Kotlin version: 1.6.10
Devices/Android versions reproduced on: Watch and Phone (pixel2 API 30) Emulator + Physdical Suunto 7 watch
Keyboard (i.e. Gboard, Samsung, etc): N/A
If this is a bug in the library, we would appreciate if you could attach:
If you have Material text with
maxLines = 2, overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center, style = TextStyle( letterSpacing = 0.18.sp )
then the text can get clipped on the left hand side. The issue seems to be related to having letterSpacing. The Wear Material Theme default fonts do have letter spacing and as a result we are seeing clipping of text.
Screenshots attached.
Sample code to reproduce the problem.