oblador / react-native-vector-icons

Customizable Icons for React Native with support for image source and full styling.
https://oblador.github.io/react-native-vector-icons/
MIT License
17.44k stars 2.12k forks source link

loadFont doesn't exist for multi-style fonts #1095

Open bcgilliom opened 5 years ago

bcgilliom commented 5 years ago

Environment

iOS and Android v6.6.0 rn 0.59.10

Description

import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
FontAwesome5.loadFont(); // <-- does not exist for multi-style fonts

Looks like a func that loops over each sub-style would need to be exposed, unfortunately no time for a PR ATM :-(

ethanyuwang commented 4 years ago

Is there a workaround for this?

Currently this block of code:

import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
FontAwesome5.loadFont();

gives me this error:

Unrecognized font family 'FontAwesome5Free-Solid

personjerry commented 4 years ago

I had this issue and read through the code. Looks like FontAwesome5 is comprised of several different fonts so you we need to load all of them. This solves our issue:

FontAwesome5.getStyledIconSet('brand').loadFont();
FontAwesome5.getStyledIconSet('light').loadFont();
FontAwesome5.getStyledIconSet('regular').loadFont();
FontAwesome5.getStyledIconSet('solid').loadFont();