Skip to content

Commit

Permalink
Fix lineHeight problems on native with new Text (#3175)
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok authored Mar 11, 2024
1 parent a289e6b commit 3a6e58b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Text as RNText, TextStyle, TextProps as RNTextProps} from 'react-native'
import {UITextView} from 'react-native-ui-text-view'

import {useTheme, atoms, web, flatten} from '#/alf'
import {isIOS} from '#/platform/detection'
import {isIOS, isNative} from '#/platform/detection'

export type TextProps = RNTextProps & {
/**
Expand Down Expand Up @@ -40,11 +40,11 @@ function normalizeTextStyles(styles: TextStyle[]) {
const fontSize = s.fontSize || atoms.text_md.fontSize

if (s?.lineHeight) {
if (s.lineHeight <= 2) {
if (s.lineHeight !== 0 && s.lineHeight <= 2) {
s.lineHeight = Math.round(fontSize * s.lineHeight)
}
} else {
s.lineHeight = fontSize
} else if (!isNative) {
s.lineHeight = s.fontSize
}

return s
Expand Down

0 comments on commit 3a6e58b

Please sign in to comment.