facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.13k stars 24.2k forks source link

Fonts are unrecognizable #27784

Closed huntermetts closed 4 years ago

huntermetts commented 4 years ago

I've added a react-native.config.js file, added module.exports = { assets:['./assets/fonts'] }

ran react-native link

restarted everything

And have attempted to use the font and it just says it's unrecognized

React Native version: react-native-cli: 2.0.1 react-native: 0.61.5

Steps To Reproduce

  1. Create react-native.config.js folder with "module.exports = { assets:['./assets/fonts'] }"
  2. Create assets folder with fonts folder and the a font inside of it
  3. run react-native link
  4. Use the font in a styles.js file
  5. run react-native run-ios

Describe what you expected to happen: "unrecognized font family 'ProximaNovaAlt-Bold'

Screen Shot 2020-01-15 at 2 12 07 PM Screen Shot 2020-01-15 at 2 12 21 PM Screen Shot 2020-01-15 at 2 22 00 PM Screen Shot 2020-01-15 at 2 23 30 PM Screen Shot 2020-01-15 at 2 38 34 PM
mtt87 commented 4 years ago

You also need to check if they are listed in your info.plist i.e.

    <key>UIAppFonts</key>
    <array>
        <string>FedraSansPro-Book.ttf</string>
        <string>FedraSansPro-Medium.ttf</string>
        <string>AntDesign.ttf</string>
        <string>Entypo.ttf</string>
        <string>EvilIcons.ttf</string>
        <string>Feather.ttf</string>
        <string>FontAwesome.ttf</string>
        <string>Foundation.ttf</string>
        <string>Ionicons.ttf</string>
        <string>MaterialIcons.ttf</string>
        <string>MaterialCommunityIcons.ttf</string>
        <string>SimpleLineIcons.ttf</string>
        <string>Octicons.ttf</string>
        <string>Zocial.ttf</string>
        <string>FontAwesome5_Brands.ttf</string>
        <string>FontAwesome5_Regular.ttf</string>
        <string>FontAwesome5_Solid.ttf</string>
        <string>Fontisto.ttf</string>
    </array>
hramos commented 4 years ago

@huntermetts did @mtt87's suggestion help?

dulmandakh commented 4 years ago

Also make sure to use font family name, not font file name.