Skip to content

Commit

Permalink
Fix default line height of our named Compose fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
aabewhite committed Jul 16, 2024
1 parent 8e4bd2b commit 7c3c9aa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/SkipUI/SkipUI/Text/Font.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.sp
#else
import struct CoreGraphics.CGFloat
Expand Down Expand Up @@ -89,7 +90,12 @@ public struct Font : Hashable, Sendable {
})

private static func adjust(_ style: androidx.compose.ui.text.TextStyle, by amount: Float) -> androidx.compose.ui.text.TextStyle {
return amount == Float(0.0) ? style : style.copy(fontSize: (style.fontSize.value + amount).sp)
guard amount != Float(0.0) else {
return style
}
let fontSize = (style.fontSize.value + amount).sp
let lineHeight = style.lineHeight == TextUnit.Unspecified ? style.lineHeight : (style.lineHeight.value + amount).sp
return style.copy(fontSize: fontSize, lineHeight: lineHeight)
}
#endif

Expand Down

0 comments on commit 7c3c9aa

Please sign in to comment.