So we have this weird bug when the users change the font type to Bold. it ruin the app’s layout, and the icons fail to load, instead of icons it show [x] symbol or some Chinese characters (I think this behavior depends on the user’s phone).
3
To disable scale app’s font size by system’s font size, just disable allowFontScaling props in Text tag, example:
allowFontScaling
Text
<Text allowFontScaling={false}>Demo</Text>
For the Bold text’s setting, i don’t have any idea for this.
You can add this code to index.js
index.js
AppRegistry.registerComponent(appName, () => App); if (Text.defaultProps == null) { Text.defaultProps = {}; Text.defaultProps.allowFontScaling = false; }
It will disable all the text in app to scaling.
Other way, you can use custom componets to control this issue. for example,
import React from 'react'; import {StyleSheet, Text, TextStyle} from 'react-native'; type Props = { children: any; color: string; fontSize: number; style?: TextStyle; }; export default function TextNormal({ children, color, style, fontSize, }: Props) { return ( <Text style={[styles.text, {color, fontSize}, style]}>{children}</Text> ); } const styles = StyleSheet.create({ text: { fontWeight: 'normal', }, });
Click here to cancel reply.
3
Answers
To disable scale app’s font size by system’s font size, just disable
allowFontScaling
props inText
tag, example:For the Bold text’s setting, i don’t have any idea for this.
You can add this code to
index.js
It will disable all the text in app to scaling.
Other way, you can use custom componets to control this issue. for example,