TextLayoutResult#isLineEllipsized always returns false
Describe the bug Currently I'm working on ReadMoreTextView library to support Compose Multiplatform. (https://github.com/webtoon/ReadMoreTextView/pull/60)
But I have an issue on Text composables.
When TextLayoutResult is received through onTextLayout of CoreText,
TextLayoutResult#isLineEllipsized always returns false.
Please let me know, if I should report this bug in the Jetpack Compose tracker.
Affected platforms Select one of the platforms below:
- Desktop (working on Android perfectly)
Versions
- Kotlin version*: 1.8.10
- Compose Multiplatform version*: 1.4.0
- OS version(s)* (required for Desktop and iOS issues): macOS Ventura
- OS architecture (x86 or arm64): arm64 (Apple M1 Pro)
- JDK (for desktop issues): JDK 11
To Reproduce Steps and/or the code snippet to reproduce the behavior:
BasicText(
text = currentText,
modifier = Modifier,
style = style,
onTextLayout = { result ->
result.isLineEllipsized(lineIndex = 3) // always returns false
},
overflow = TextOverflow.Ellipsis,
maxLines = 3,
)
Expected behavior
If currentText exceeds maxLines and currentText is ellipsized, result.isLineEllipsized() should return true.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Reproduced:
@Composable
@Preview
fun App() {
var currentText: String by remember { mutableStateOf("") }
Column {
BasicText(
text = currentText,
modifier = Modifier.width(100.dp),
onTextLayout = { result ->
val lastLine = result.lineCount - 1
val isEllipsized = result.isLineEllipsized(lineIndex = lastLine) // always returns false
println("isEllipsized($lastLine) = $isEllipsized")
},
overflow = TextOverflow.Ellipsis,
maxLines = 3,
)
TextField(currentText, onValueChange = { currentText = it })
}
}
@fornewid
Please let me know, if I should report this bug in the
Hi, I found problem in:
androidx.compose.ui.text.SkiaParagraph.skiko.kt override fun isLineEllipsized(lineIndex: Int) = false
This class responses for desktop realisation. Obviosly, the result, which you wait always returns false. You should report about the bug.
@AntonButov Yes, that's right.
However, only the android library is published in Jetpack Compose.
So I thought the SkiaParagraph.skiko.kt code should be modified in compose-multiplatform-core project.
Did I think wrong?
compose-multiplatform-core is fork of JetPack Compose. Yes, it's really strange why the desktop implementation placed in Android's Jatpack and called AndroidX. But I am sure that AndroidParagraph.android.kt::isLineEllipsized works when launching the Android application. Work good. The desktop application uses SkiaParagraph.skiko.kt::isLineEllipsized. Work bad. Both of these classes resolve interface. Perhaps androidx is not being renamed becouse not to break compatibility.