val headlineRegular: TextStyle = TextStyle(
fontWeight = FontWeight.W400,
fontSize = 16.sp,
lineHeight = 22.4.sp,
letterSpacing = 0.3.sp,
platformStyle = PlatformTextStyle(
includeFontPadding = false
),
),

with platformStyle = PlatformTextStyle(includeFontPadding = true):

without:

text is not centered within the container.
So what did they fix exactly?
My code:
TextButton(
modifier = modifier,
enabled = enabled,
colors = colors,
onClick = onClick
) {
Icon(
painter = painterResource(id = R.drawable.ic_logout),
contentDescription = "Logout icon",
modifier = Modifier
)
Spacer(modifier = Modifier.width(4.dp))
Text(
text = stringResource(R.string.logout),
style = LocalAppType.current.headlineRegular
)
}
It has since been un-deprecated and should be OK to use. Also, since compose ui 1.6.0-alpha01 "includeFontPadding" should be false by default.
PlatformTextStyle.includeFontPadding is undeprecated. Our original intent was to remove the field, however the feedback shows that developers need this configuration option. Therefore removing deprecation from the field
https://android-review.googlesource.com/c/platform/frameworks/support/+/2534105
Update June 2023: Compose ui 1.6.0-alpha01 is the first version with includeFontPadding switched to false by default. Use PlatformTextStyle API from Compose 1.2.0 to configure includeFontPadding. For few compose versions it was deprecated on purpose to indicate that it is a compatibility API, but has been undeprecated in compose 1.5 to encourage developers to use it. Test your UI using includeFontPadding set to false and make any necessary adjustments. Use LineHeightStyle API to match your designs easier.
https://medium.com/androiddevelopers/fixing-font-padding-in-compose-text-768cd232425b
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With