Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font Size React native

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;
like image 716
devedv Avatar asked Feb 09 '18 15:02

devedv


People also ask

How do you handle font scaling in React Native?

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.

What is default font size in React Native?

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.


1 Answers

Adding allowFontScaling={false} to Text ignores the device font scaling.

 <Text allowFontScaling={false}  style={styles.TitleText}>
           {this.state.testLabel.toUpperCase()}
            </Text>
like image 142
devedv Avatar answered Nov 15 '22 08:11

devedv