Search code examples
react-nativesvgreact-native-iosreact-native-svg

Showing SVG image with 'react-native-svg' library, however encounter 'Unrecognized font family' error in iOS (Android works fine.)


My react-native version is "0.62.2".

In order to show remote SVG images, I use react-native-svg library in my React Native project.

I use it like:

import {SvgUri} from 'react-native-svg';

const MyScreen = ({route, navigation}) => {
  ...
  ...
  return (<View>
        <SvgUri width="100%" height="100%" uri={imageSource} />
        </View>)
}

export default MyScreen;

In Android emulator, it works fine!

In iOS, it works in a sense, but the way how it works is: when navigate to MyScreen, I always encounter the following error at runtime in the 1st place:

enter image description here

Then, I have to press on keyboard ctrl+S to save code again (though nothing needs to save) which triggers the simulator to refresh, then MyScreen is shown successfully with the SVG image.

Why I get the "Unrecognized font family 'Univers-Condensed'" error at runtime in iOS? How to get rid of it?

(In my code, I have no code using that font, so my guess is the library introduced that font.)


Solution

  • Can you try this add Universe-Condensed.ttf in info.plist

    <key>UIAppFonts</key>
        <array>
            <string>Universe-Condensed.ttf</string>
        </array>