1. 程式人生 > >[Solved] fontFamily 'Arial' is not a system font and has not been loaded ... « 關於網路那些事...

[Solved] fontFamily 'Arial' is not a system font and has not been loaded ... « 關於網路那些事...

In the development of RN process, using react-native-swiper expansion,
When ios preview normal display, but Android has made an error: fontFamily 'Arial' is not a system font and has not been loaded through Expo.Font.loadAsync...

I am using and Expo
Obviously, the reason for the error is less Arial font

Go online to find a solution, to provide solutions as follows:

Method 1. Installation of missing fonts

First, download Arial fonts
Put "Arial.ttf" in project,and import:

For example:

import { Font } from 'expo';
export default class App extends React.Component {
  state = {
    fontLoaded: false
} async componentDidMount() { await Font.loadAsync({ 'Arial': require('./path/to/fonts/Arial.ttf') }); this.setState({ fontLoaded: true }); } render() { if (!this.state.fontLoaded) return null; return ( <Main /> ); } // ... }

Method 2. Remove fontFamily

Open the file

\node_modules\react-native-swiper\src\index.js

Remove buttonText's fontFamily: 'Arial'

...

  buttonText: {
    fontSize: 50,
    color: '#007aff'
    fontFamily: 'Arial' // <------- Remove fontFamily: 'Arial'

  }
...

This solution has been committed


如果你喜歡我們的文章內容,請在這裡按個讚