question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom fonts won't load on tvOS apps - Unrecognized font family

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment: OS: macOS High Sierra 10.13.2 Node: 8.9.4 Yarn: Not Found npm: 5.6.0 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: Not Found

Packages: (wanted => installed) react: 16.2.0 => 16.2.0 react-native: 0.53.2 => 0.53.2

Steps to Reproduce

  1. Create new project using `react-native init AwesomeProject
  2. Create folder: resources/fonts
  3. Add rnpm settings to package.json to link fonts:
  "rnpm": {
    "assets": [
      "resources/fonts"
    ]
  },
  1. Download and add a custom font to resources/fonts (I used BioRhymeExpanded-Regular.ttf in this example - available at https://fonts.google.com/specimen/BioRhyme+Expanded
  2. run react-native link
  3. Modify App.js to utilize new font (Lines 48-53):
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
    fontFamily: 'BioRhymeExpanded-Regular'
  },
  1. Open XCode and run on iOS Simulator and on tvOS simulator

Expected Behavior

We should see the “Welcome to React Native” heading rendered using the new font in both iOS and tvOS apps.

Actual Behavior

We get Unrecognized font family 'BioRhymeExpanded-Regular' when running tvOS (on either AppleTV 4k or AppleTV 4k at 1080p). iOS apps display the correct/expected output.

Working iOS ios_working

Busted tvOS tvos_busted

Essentially, tvOS apps are not loading custom fonts. Additionally, noticed that font files did not have tvOS targets, but correcting this had no effect (even after clean, shutdown and restart of packager, and rebuild).

Reproducible Demo

https://gist.github.com/natestone/69b04c8725ef39893c3c5d1a7ca9f7f7

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
psegalencommented, Mar 12, 2018

I have a custom font on tvOS, I remember running in some issues but finally made it work. Check the following:

  • The fonts are listed in your Info.plist “Fonts provided by application” section;
  • Your tvOS target is correctly using this Info.plist file; (I think it was my problem)
  • The tvOS target config “Build Phases” tab has your *.ttf files added in the “Copy Bundle Resources” section.
1reaction
natestonecommented, Mar 15, 2018

Overall, the solution posted by @psegalen is correct (and thank you for pointing me in the right direction). It was the second issue listed that was causing the problem (tvOS target using the correct info.plist file).

For reference to those who also have this issue, it turns out that the react native system does not make the -tvOS and -tvOSTests folders from the ios/ directory appear in XCode. However, it does create these folders and assigns the tvOS targets to use the Info.plist files in these directories. This was quite confusing as I kept checking the standard folder Info.plist as applying to both targets. This does not change the “build setting” in XCode, however. It just results in the file being added to the “copy resources” section of the “build phases” section in XCode.

To fix, you need to create groups matching the names of your -tvOS Targets. These folders already exist on the file system, but not in the XCode workspace:

screenshot 2018-03-14 15 19 47

I created two “groups without folders” matching the ones from the file system that were not showing. Note: if you create folders it will fail due to name collisions.

screenshot 2018-03-14 15 20 26

Then I dragged the Info.plist files from the file system to the new groups in the XCode workspace and assigned them to the correct targets. screenshot 2018-03-14 15 20 39

Now the Info.plist files for the tvOS targets can be properly edited and maintained through the XCode interface. So, I’m up and running.

However, I’m not sure if it’s appropriate to close the issue as this is actually a workaround. It seems to me that this issue and the react-native link function should properly handle tvOS targets. I’ll try and fix it in the react-native code, but that may be out of my wheelhouse.

Let me know if others think this should be closed due to a workaround being found.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unrecognized font family on iOS simulator with React Native
If you have custom fonts that you downloaded from internet, place them, e.g in src/assets/fonts folder. Create a file that is called react-native.config.js ......
Read more >
Custom fonts aren't being recognized in my React Native project
I've been trying to add a custom .ttf font in my React Native project but Metro keeps telling me it's an "Unrecognized font...
Read more >
unrecognized font family poppins regular react-native ios
Open side panel. facebook/react-nativeCustom fonts won't load on tvOS apps - Unrecognized font family#18025. Created almost 5 years ago.
Read more >
How to fix Unrecognised font family error in React Native - Des
If the problem still persist, open [project].xcworkspace and click on your project name under Targets, click on Build Phases, scroll to Copy Bundle...
Read more >
[Solved]-React-native unrecognized font family error
After adding the custom fonts, you need to link it using react-native link . That will create an entry in Info.plist file (iOS) ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found