Garrison Henkle
03/11/2025, 12:00 AMText Composables capping the height of lines at the style parameter’s lineHeight instead of letting the line grow to the height of inlined Composables (passed via inlineContent)? Compose Multiplatform’s Skia-based platforms handle it correctly (imo), while Jetpack Compose does not:Garrison Henkle
03/11/2025, 12:01 AMBasicText, Text, etc.
Column(modifier = modifier) {
val density = LocalDensity.current
val boxSizeInTextUnits = remember { 75.sp }
val boxSizeInDp = remember(density) { with(density) { boxSizeInTextUnits.toDp() } }
val text = remember {
buildAnnotatedString {
appendLine("The next line might be problematic:")
append("Hello ")
appendInlineContent(id = "[1]")
appendLine(" World!")
appendLine("Maybe not?")
}
}
val inlineContent = remember(boxSizeInDp) {
mapOf(
"[1]" to InlineTextContent(
placeholder = Placeholder(
width = boxSizeInTextUnits,
height = boxSizeInTextUnits,
placeholderVerticalAlign = PlaceholderVerticalAlign.Center,
),
children = {
Box(modifier = Modifier.size(size = boxSizeInDp).background(color = Color.Red))
}
)
)
}
Spacer(modifier = Modifier.height(height = 20.dp).fillMaxWidth().background(color = Color.LightGray))
BasicText(text = text, inlineContent = inlineContent, style = style)
Spacer(modifier = Modifier.height(height = 20.dp).fillMaxWidth().background(color = Color.LightGray))
Text(text = text, inlineContent = inlineContent, style = style)
Spacer(modifier = Modifier.height(height = 20.dp).fillMaxWidth().background(color = Color.LightGray))
Text(text = "The next line might be problematic:\nHello world!\nMaybe not?", style = style)
Spacer(modifier = Modifier.height(height = 20.dp).fillMaxWidth().background(color = Color.LightGray))
}Garrison Henkle
03/11/2025, 12:06 AM