Last active
December 11, 2019 12:55
-
-
Save hugows/e4d1be3a2163d2521ea3a5c665bb1edb to your computer and use it in GitHub Desktop.
Easy way to replace use custom font in React Native projet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First install font like: https://blog.bam.tech/developer-news/add-a-custom-font-to-your-react-native-app | |
import React from 'react'; | |
import {Text as RNText, StyleSheet} from 'react-native'; | |
export default class Text extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
render() { | |
return ( | |
<RNText style={[styles.defaultStyle, this.props.style]}> | |
{this.props.children} | |
</RNText> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
defaultStyle: { | |
fontFamily: 'BrandonGrotesque-Regular', | |
}, | |
}); | |
// Then just remove regular Text import and import this component instead! Profit. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment