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

enter image description here

with platformStyle = PlatformTextStyle(includeFontPadding = true):

enter image description here

without:

enter image description here

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
    )
}
user924
  • 8,146
  • 7
  • 57
  • 139

1 Answers1

0

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

Telmo Marques
  • 5,066
  • 1
  • 24
  • 34