Hi, I'm currently updating `compose-bom` from ver...
# compose-android
h
Hi, I'm currently updating
compose-bom
from version 2023.10.01 to 2024.06.00 and have noticed significant differences in screenshots involving
Text
components. While I'm aware that
includeFontPadding
now defaults to false, the change I'm seeing seems related to actual font size. I've reviewed compose-ui lib changes but haven't found anything specific to this. Does anyone have insights into what might be causing this?
s
I know it's been a very long time, but I've just checked the channel 😅 Anyways, the change that happened in those versions is more than just
includeFontPadding
. In the
androidx.compose.foundation
layer, that's the only change, but
androidx.compose.material
also had changes, touching
LocalTextStyle
if I remember correctly (which is applied through the
MaterialTheme
composable). Not sure if anything relates to font size, but line height used to be
Unspecificed
, but now it's hardcoded values instead (linked to each typography style). That meant that if you simply changed
fontSize
(instead of using a different pre-built material typography style, or changing the
lineHeight
as well), the lines would either be too far away from each other (if you decrease it) or start to overlap (if you increase it). I forgot the code I used to fix it, I think was basically setting the default`lineHeight` to
Unspecified
again, but I'll take a look right now.
Found the code, here's what it looks like:
Copy code
MaterialTheme(
    colors = colors,
    typography = Typography,
    shapes = Shapes
) {
    val currentStyle = LocalTextStyle.current
    CompositionLocalProvider(
        value = LocalTextStyle provides currentStyle.copy(
            lineHeight = TextUnit.Unspecified,
            platformStyle = PlatformTextStyle(
                spanStyle = currentStyle.platformStyle?.spanStyle,
                paragraphStyle = PlatformParagraphStyle(includeFontPadding = true)
            )
        ),
        content = content
    )
}
(Note that I also re-enabled
includeFontPadding
, as my project is a font preview app and that results in a more accurate representation).
Again, not sure if this is the same thing you're noticing. I've done this a long time ago (I used to move to alpha/beta releases very early on), but you've moved from 2023.10.01 so that seems just about right to me. Hope that helps!