Does anyone have any insight into the font padding...
# compose
m
Does anyone have any insight into the font padding changes in 1.6? I’m trying to update our design system typography by transforming the existing text styles to include the font padding:
Copy code
private fun TextStyle.keepDefaultFontPadding(): TextStyle {
    return TextStyle(
        fontFamily = fontFamily,
        fontWeight = fontWeight,
        fontSize = fontSize,
        lineHeight = lineHeight,
        letterSpacing = letterSpacing,
        platformStyle = platformStyle.keepDefaultFontPadding()
    )
}

private fun PlatformTextStyle?.keepDefaultFontPadding() =
    PlatformTextStyle(
        spanStyle = this?.spanStyle ?: PlatformSpanStyle.Default,
        paragraphStyle = PlatformParagraphStyle(
            emojiSupportMatch = this?.paragraphStyle?.emojiSupportMatch ?: EmojiSupportMatch.Default,
            includeFontPadding = true
        )
    )
However, while this seems to work for text paragraphs, it seems like single line text items are now different sizes. There’s a before and after of the paparazzi snapshot. You’ll notice that the padding on top of the $100 in the original is much smaller than the actual as is the size of the buttons. Nothing else about the code has changed other than the compose 1.6 update and the transformation above.
z
a
If you are using m2, note that line height is specified by default for each style in
Typography
, which wasn't before 1.6.
m
@Albert Chang I’m using 1.6.0 (the actual release version). And we specify all of our line heights explicity.
Copy code
TextStyle(
            fontFamily = XDSFonts.DMSans,
            fontWeight = FontWeight.Normal,
            fontSize = 16.sp,
            lineHeight = 24.sp,
            letterSpacing = 0.00000.em
        )
@Zach Klippenstein (he/him) [MOD] i’m not 100% sure what font scaling itself has to do with the internal padding. My understanding of font scaling was that if the user set the font size to 150% in their accessibility settings, that before 1.6.0, something like a 48sp font would end up being like 72dp. With 1.6.0, it’s not scaled at the 150%, but at some other multiplier based on the setting combined with the specified font size. So for larger fonts it may be more like 105% or something like that.
z
Oh, i think i posted the wrong bug. This might be related to includeFontPadding being turned off by default now
m
I think my issue is mostly around how our theme is created and referenced. So i really need to change the theme’s composition local defaults, rather than doing this in the Composable function which sets up our theme. Since we don’t have any real variations in our theme, most people don’t call this composable and just go with the default. That said, i’m kind of surprised that a change that has such a huge visual impact was done in a minor release.