In react native app whats the best way to deal with font size.
I've a kind of weird issue, if font size is increased from mobile device display settings it changes the fontSize of app as well. I have used fontSize:14(whatever value), so it picks the size 14 according to mobile device font size & the font size of entire app get increased and UI looks horrible.
I've also tried to adjust the fontSize using width and height but it also not looks good on all devices.
const WIDTH = Dimensions.get('window').width;
const HEIGHT = Dimensions.get('window').height;
Restrict device font scaling. The last method to scale your React Native app allows you to apply an app-wide maximum font scale that any text element can reach. This means that whatever maximum font multiplier you set, the text in your app will never exceed that maximum size.
I've been testing in an iPhone 8 simulator running iOS 11, and through experimentation have come to the conclusion the default font displayed is 14 logical pixels (as in a brand-new element with no styling). However, checking the iOS style guidelines it would seem the default body text on iOS is intended to be 17pt.
Adding allowFontScaling={false} to Text ignores the device font scaling.
<Text allowFontScaling={false} style={styles.TitleText}>
{this.state.testLabel.toUpperCase()}
</Text>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With