關於網路那些事...

網路行銷,SEO,網路趨勢,教學文章,網頁設計,生活時事

[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 create-react-native-app 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

Remove fontFamily: 'Arial'. #690


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



最新文章推薦