Skip to content

Commit

Permalink
Fix height of an empty line
Browse files Browse the repository at this point in the history
SkiaParagraph doesn't use span style to determine the height of the empty/blank line. It uses main style of the paragraph, which we haven't set.

Fixes JetBrains/compose-multiplatform#1781

# Conflicts:
#	compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/platform/SkiaParagraph.skiko.kt
  • Loading branch information
igordmn committed Mar 30, 2022
1 parent e9a7f4e commit 38c0226
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,19 @@ class DesktopParagraphTest {
Truth.assertThat(paragraphWithoutStyles.getLineBottom(1)).isNotEqualTo(secondLineBottom)
}

@Test
fun `line heights`() {
val paragraph = simpleParagraph(
text = "aaa\n\naaa\n\n\naaa\n \naaa",
style = TextStyle(fontSize = 50.sp)
)
val firstLineHeight = paragraph.getLineHeight(0)

for (i in 1 until paragraph.lineCount) {
Truth.assertThat(paragraph.getLineHeight(i)).isEqualTo(firstLineHeight)
}
}

private fun simpleParagraph(
text: String = "",
style: TextStyle? = null,
Expand Down

0 comments on commit 38c0226

Please sign in to comment.