can i come back to what was asked previously: "The...
# compose-desktop
z
can i come back to what was asked previously: "The latest development version of compose (1.6.0-dev1383) has completely broken my layouts. The default line spacing of multiline text has been drastically increased. Is this by design or is this a bug?" now i am obviously using 1.6.0-rc02 instead of 1.6.0-dev1383 i have read the thread and also https://github.com/JetBrains/compose-multiplatform-core/pull/996/files but i still do NOT understand what exactly do i have to change in my app to make things work again? the lineheight seems to be totally broken. i dont understand how to fix it. can you please help with more details/examples?
i have a slider to change font size and this happens now:
first lineheight size is too large then lineheight is too small
Copy code
Text(
    text = message.text,
    style = MaterialTheme.typography.body1.copy(
        fontSize = ((msg_fontsize * ui_scale).toDouble()).sp,
        letterSpacing = 0.sp
    )
)
d
Is it reproduced on
1.6.0-rc02
?
1.6.0-dev1383 - it is very old version at this moment
z
yes. the screenshots and code sample is happening with 1.6.0-rc02
i
Status: Won't Fix (Intended Behavior)
The release notes documentation has been edited to clarify this change in behavior for line height.
To support non-standard text sizes, we encourage users to follow the Material design system and use a different type scale rather than changing the font size directly. Alternatively, users can overwrite the line height like so:
style = LocalTextStyle.current.copy(lineHeight = TextUnit.Unspecified)
, or create a custom
Typography
entirely.
a
Need non-partner link
1
To make
fontSize
control
lineHeight
you need to provide (override)
LocalTextStyle
with
lineHeight = TextUnit.Unspecified
Basically now
MaterialTheme
specifies
lineHeight
explicitly by default, so changing only
fontSize
doesn't work inside it
z
ok thanks. that seems to work
👍 1
m
Is there any reason not to do this at the theme level rather than each
Text
?
Copy code
@Composable
fun AppTheme(content: @Composable () -> Unit) {
    MaterialTheme(colors = ...) {
        CompositionLocalProvider(
            LocalTextStyle provides LocalTextStyle.current.copy(lineHeight = TextUnit.Unspecified),
            content = content,
        )
    }
}
i
My message above suggests exactly this
To make
fontSize
control
lineHeight
you need to provide (override)
LocalTextStyle
with
lineHeight = TextUnit.Unspecified
m
Oh right. I read that differently. By passing
lineHeight
into the style passed to `Text`’s style arg, you would be overriding `LocalTextStyle`’s
lineHeight
value. So I thought you meant that rather than providing/overriding through
CompositionLocalProvider
. Thanks for the clarification.
👍 1
i
Sorry if my message was unclear, I should have attached a code example
👍 1