harry248
10/20/2022, 9:22 AMAnnotatedString
with `SpanStyle`'s defining large font sizes the space between lines becomes smaller and smaller. It seems to be fine until font sizes larger then 24 sp. Anyone noticed this too? What could be wrong?Tolriq
10/20/2022, 9:27 AMharry248
10/20/2022, 9:41 AMTolriq
10/20/2022, 9:44 AMAlbert Chang
10/20/2022, 10:47 AMem
instead of sp
to make it based on font size.harry248
10/20/2022, 11:10 AMAlbert Chang
10/20/2022, 12:15 PMTextStyle
is TtextUnit.Unspecified
, which means the line height will depend on the font size. Your problem is because you are specifying line height in sp
, which is an absolute unit.Halil Ozercan
10/20/2022, 12:31 PMharry248
10/20/2022, 12:31 PMHalil Ozercan
10/20/2022, 12:49 PMsp
, then the relativity of it to fontSize will be lost. You need to use em
for that.harry248
10/20/2022, 1:25 PMharry248
10/20/2022, 1:33 PMText(
text = buildAnnotatedString {
withStyle(SpanStyle(fontSize = 36.sp)) {
append("Some text with a font Size of 36.sp and long enough to cause a new line")
}
append("\n\n")
withStyle(SpanStyle(fontSize = 14.sp)) {
append("Some text with a font Size of 14.sp and long enough to cause a new line")
}
},
modifier = Modifier.fillMaxSize(),
style = TextStyle.Default.copy(lineHeight = 2.em)
)
gives the following resultharry248
10/20/2022, 1:43 PMharry248
10/20/2022, 1:48 PM