Skip to content

Instantly share code, notes, and snippets.

@hugows
Last active December 11, 2019 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugows/e4d1be3a2163d2521ea3a5c665bb1edb to your computer and use it in GitHub Desktop.
Save hugows/e4d1be3a2163d2521ea3a5c665bb1edb to your computer and use it in GitHub Desktop.
Easy way to replace use custom font in React Native projet
// 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