Kevin Worth
04/28/2023, 2:45 PM.copy
// don't make any change in Type.kt
...
Text(
text = ...
style = MaterialTheme.typography.displayLarge.copy(fontSize = 50.sp)
)
// Will this have a line height of 64, or will line height be "auto"?
• Override in Type.kt
displayMedium = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.SemiBold
fontSize = 40.sp,
// don't set lineHeight
// don't set letterSpacing
),
...
Text(
text = ...,
MaterialTheme.typography.displayMedium
)
// Will this have a line height of 52, or something like Unspecified, which then means "auto"? Or...?
Our designers are taking advantage of Figma's ability to set line height to "auto"(which ends up being odd values like 51.74) and they ask, "Wait, you mean Android doesn't have auto line height?" So, does it?Filip Wiesner
04/28/2023, 2:49 PMAlbert Chang
04/28/2023, 3:29 PMTextUnit.Unspecified
means auto line height, and if the text style had a specified line height, copying it will not change the line height unless you set lineHeight = TextUnit.Unspecified
.Filip Wiesner
04/28/2023, 3:47 PMKevin Worth
04/28/2023, 3:57 PMChris Sinco [G]
04/28/2023, 4:11 PMincludeFontPadding
is set to true
by default in Compose for historical reasons. That will change in the future, which should make the auto line heights more consistent with Figma. If you don’t set it to false
, your designers may find it doesn’t match their specs.Kevin Worth
04/28/2023, 4:46 PMletterSpacing
? Looks like I can set that to Unspecified
, and then it will use an auto letterSpacing
for Roboto?Chris Sinco [G]
04/28/2023, 4:48 PMSiyamed
04/28/2023, 5:09 PMKevin Worth
04/28/2023, 5:32 PMincludeFontPadding
is new to me and I've now found it as a parameter of PlatformTextStyle
which is deprecated and says
'constructor PlatformTextStyle(Boolean = ...)' is deprecated. includeFontPadding was added to Android in order to prevent clipping issues on tall scripts. However that issue has been fixed since Android 28. Compose backports the fix for Android versions prior to Android 28. Therefore the original reason why includeFontPadding was needed is invalid on Compose.This configuration was added for migration of the apps in case some code or design was relying includeFontPadding=true behavior; and will be removed.
So, sounds like we no longer need to worry about it? Or am I missing something?Chris Sinco [G]
04/28/2023, 5:50 PMKevin Worth
04/28/2023, 6:06 PMtitleMedium = TextStyle(
....
lineHeight = TextUnit.Unspecified,
...
platformStyle = PlatformTextStyle(
includeFontPadding = false
)
),
And then we'll keep an eye out for when it is removed, so then we can remove platformStyle
. Yes?Chris Sinco [G]
04/28/2023, 6:12 PMUseAPI fromPlatformTextStyle
to configureCompose 1.2.0
It is deprecated on purpose to indicate that it is a compatibility API.includeFontPadding
Joel Denke
04/30/2023, 5:37 AMSiyamed
05/01/2023, 1:54 PMKevin Worth
05/01/2023, 4:19 PMJoel Denke
05/01/2023, 4:32 PM