@Chris Sinco [G] took me a while, but it seems I've uncovered some text rendering related bug in Compose.
The key is to have some multiple lines spanning button
and an external Roboto.ttf font (from Google fonts).
Here's the code
private val Roboto = FontFamily(
Font(R.font.roboto_medium, FontWeight.Medium),
)
@Composable
fun CustomButton(
text: String,
) {
androidx.compose.material.Button(
onClick = { },
modifier = Modifier.heightIn(min = 56.dp).fillMaxWidth(),
shape = MaterialTheme.shapes.medium,
) {
Text(
text = text,
textAlign = TextAlign.Center,
style = TextStyle(
fontFamily = Roboto,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
)
)
Icon(
Icons.Filled.Face,
contentDescription = null
)
}
}
@Preview(showBackground = true, widthDp = 360)
@Composable
fun StoryBookButtons1() {
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
CustomButton(
text = "A very very very long button not fitting one one line",
)
CustomButton(
text = "Continue",
)
}
}