Has anyone run into issues with `Text` Composables...
# compose
g
Has anyone run into issues with
Text
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:
Not exactly a minimum reproducer, but this is the code I used for above. I was trying different Composables to see if it was a problem with just
BasicText
,
Text
, etc.
Copy code
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))
}
Might not be a bug, but it’s definitely annoying behavior.