Unrecognized font family on iOS simulator with React Native

后端 未结 14 1420
北海茫月
北海茫月 2020-12-14 05:55

I\'ve added Linux Biolinum fonts (http://www.dafont.com/linux-biolinum.font, LinBiolinum_R.ttf, LinBiolinum_RB.ttf) to my React Native project. Android version is OK. But on

相关标签:
14条回答
  • 2020-12-14 06:21

    I had the same issue and fixed it by just opening the project in Xcode and under Resources folder in Project Navigator, there were duplicate fonts and just removing them from Resources folder and Info.plist both, the issue got resolved. Just run the app in Xcode after deletion then you may verify in your other tools as well without reinstalling npm. Just run 'react-native run-ios', cheers :)

    0 讨论(0)
  • 2020-12-14 06:23

    I renamed the font files and re-ran react-native link and ended up in this state.

    I resolved it by ensuring the old fonts were removed from the Resources folder and Info.plist and then ran the build again.

    0 讨论(0)
  • 2020-12-14 06:25

    In App.js file just import the missing font family and load the font as below

    import Feather from 'react-native-vector-icons/Feather'

    Feather.loadFont();

    You can find these fonts in your project folder

    Path - Project->node-modules-react-native-vector-icons->Fonts

    Check this tested and works fine

    Hope this helps!!

    0 讨论(0)
  • 2020-12-14 06:25

    If you are running react-native ios simulator, you should include fonts in the xcode project directory.

    react-native link react-native-vector-icons doing so , will add the fonts to Resources folder in xcode project and also add fonts to pinfo list.

    0 讨论(0)
  • 2020-12-14 06:26

    In my case, it worked fine in Android but not in iOS. The font file name was PlayfairDisplay-VariableFont_wght.ttf. But when I opened that file I saw the name as:

    .

    So, I changed the file name to PlayfairDisplay-Regular.ttf and it worked pretty well!

    0 讨论(0)
  • 2020-12-14 06:27

    Implement the following code in your appdelegate file

    for (NSString* family in [UIFont familyNames])
    {
        NSLog(@"%@", family);
    
        for (NSString* name in [UIFont fontNamesForFamilyName: family])
        {
            NSLog(@"Family name:  %@", name);
        }
    }
    

    You should use FONT FAMILY NAME instead of your font file name like the following

    fontFamily: "FuturaBT-Book"
    
    0 讨论(0)
提交回复
热议问题