Created
February 19, 2018 21:30
-
-
Save natestone/69b04c8725ef39893c3c5d1a7ca9f7f7 to your computer and use it in GitHub Desktop.
React Native - Unrecognized Font on tvOS
This file contains 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
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
Platform, | |
StyleSheet, | |
Text, | |
View | |
} from 'react-native'; | |
const instructions = Platform.select({ | |
ios: 'Press Cmd+R to reload,\n' + | |
'Cmd+D or shake for dev menu', | |
android: 'Double tap R on your keyboard to reload,\n' + | |
'Shake or press menu button for dev menu', | |
}); | |
type Props = {}; | |
export default class App extends Component<Props> { | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.welcome}> | |
Welcome to React Native! | |
</Text> | |
<Text style={styles.instructions}> | |
To get started, edit App.js | |
</Text> | |
<Text style={styles.instructions}> | |
{instructions} | |
</Text> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center', | |
backgroundColor: '#F5FCFF', | |
}, | |
welcome: { | |
fontSize: 20, | |
textAlign: 'center', | |
margin: 10, | |
fontFamily: 'BioRhymeExpanded-Regular' | |
}, | |
instructions: { | |
textAlign: 'center', | |
color: '#333333', | |
marginBottom: 5, | |
}, | |
}); |
This file contains 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
react-native init AwesomeProject | |
replace package.json with package.json from above | |
replace App.js with App.js from above | |
make directory ./resources/fonts | |
Download https://fonts.google.com/specimen/BioRhyme+Expanded | |
expand archive and copy fonts to ./resources/fonts | |
react-native link | |
open Xcode project (./ios) in Xcode | |
run on iOS Simulator - will work - "Welcome to React Native!" will show in custom font | |
run on tvOS Simulator - will not work - Unrecognized font family 'BioRhymeExpanded-Regular' |
This file contains 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
{ | |
"name": "AwesomeProject", | |
"version": "0.0.1", | |
"private": true, | |
"rnpm": { | |
"assets": [ | |
"resources/fonts" | |
] | |
}, | |
"scripts": { | |
"start": "node node_modules/react-native/local-cli/cli.js start", | |
"test": "jest" | |
}, | |
"dependencies": { | |
"react": "16.2.0", | |
"react-native": "0.53.2" | |
}, | |
"devDependencies": { | |
"babel-jest": "22.2.2", | |
"babel-preset-react-native": "4.0.0", | |
"jest": "22.3.0", | |
"react-test-renderer": "16.2.0" | |
}, | |
"jest": { | |
"preset": "react-native" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment