내 앱에서 Google 글꼴의 글꼴을 사용하고 싶습니다. Here is the font.사용자 정의 글꼴이 React Native에서 작동하지 않습니다.
나는 app/fonts
에 TTF 파일에 놓여있다.
package.json는 :
{
"name": "xxx",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"rnpm": {
"assets": ["./app/fonts"]
},
"jest": {
"preset": "react-native",
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
}
},
"dependencies": {
"flow-typed": "^2.0.0",
"immutable": "^3.8.1",
"react": "~15.4.1",
"react-native": "0.42.0",
"react-native-vector-icons": "^4.0.0",
"react-redux": "^5.0.3",
"redux": "^3.6.0",
"redux-immutable": "^4.0.0",
"redux-observable": "^0.14.1",
"rxjs": "^5.2.0"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"babel-jest": "19.0.0",
"babel-preset-react-native": "1.9.1",
"eslint": "^3.17.0",
"eslint-plugin-flowtype": "^2.30.3",
"eslint-plugin-jsx": "^0.0.2",
"eslint-plugin-react": "^6.10.0",
"eslint-plugin-react-native": "^2.3.1",
"flow-bin": "^0.42.0",
"jest": "19.0.2",
"jest-cli": "^19.0.2",
"react-test-renderer": "~15.4.1",
"redux-devtools": "^3.3.2",
"remote-redux-devtools": "^0.5.7"
}
}
는
react-native link
을 달렸다.
그런 다음 내 응용 프로그램에서 글꼴을 사용합니다
import { View, Text } from 'react-native'
import React from 'react'
import Width from '../width/Width'
import Shape from '../shape/Shape'
import Height from '../height/Height'
import Thickness from '../thickness/Thickness'
export const Volcalc =() => (
<View style={styles.container}>
<Text style={styles.text}>SHAPE</Text>
<Shape />
<Text style={styles.text}>HEIGHT</Text>
<Height />
<Text style={styles.text}>WIDTH</Text>
<Width />
<Text style={styles.text}>THICKNESS</Text>
<Thickness />
</View>
)
const $mainColor = '#00d1b2'
const styles = {
container: {
flex: 1,
padding: 20,
backgroundColor: $mainColor
},
text: {
textAlign: 'center',
color: 'rgba(255, 255, 255, 0.9)',
fontSize: 15,
fontFamily: 'Orbitron'
}
}
안드로이드에서는 새로운 글꼴을 보여하지만 오류가하지 않습니다. 오류 있음 :
Unrecognised font family "Orbitron"
내가 뭘 잘못하고 있니?
어떻게 fontFamily: 'xxx'
에 배치 할 정확한 값을 알 수 있습니까?
당신은 결국이 문제를 해결 했는가를? 글꼴은 iOS에서는 작동하지만 안드로이드에서는 작동하지 않습니다 – donovantc