You can try trimming both directions of the text
Text(
text = "Hello world",
modifier = modifier
.border(
width = 1.dp,
color = Color.Red
).padding(0.dp),
style = MaterialTheme.typography.displaySmall.copy(
lineHeightStyle = LineHeightStyle(
alignment = LineHeightStyle.Alignment.Center,
trim = LineHeightStyle.Trim.Both,
),
platformStyle = PlatformTextStyle(
includeFontPadding = false
),
)
)