Can't use custom fonts with SVG (or react-native-art)
See original GitHub issueEnvironment
Environment: OS: Windows 10 Node: 8.6.0 Yarn: 1.2.1 npm: 5.5.1 Watchman: Not Found Xcode: N/A Android Studio: Not Found
Packages: (wanted => installed) expo: ^25.0.0 => 25.0.0 react: 16.2.0 => 16.2.0 react-native: 0.52.0 => 0.52.0
Diagnostics report: https://exp-xde-diagnostics.s3.amazonaws.com/fhelwanger-4deb5b43-5b8f-4a73-a5ba-dc5910b65855.tar.gz
Steps to Reproduce
- Load some custom font:
await Font.loadAsync({
IndieFlower: require('./assets/fonts/IndieFlower.ttf')
});
- Try to render some
ReactNative.ART.Text
using this font:
<ART.Surface height={50} width={100}>
<ART.Text
font={{
fontFamily: 'IndieFlower',
fontSize: 14
}}
fill="#000"
>
{'<ART.Text/>'}
</ART.Text>
</ART.Surface>
Expected Behavior
The custom font is displayed.
Actual Behavior
- On iOS, the app crashes with the
Unrecognized font family
error. - On Android, no error is thrown but the default font is shown instead.
- If I use the default
ReactNative.Text
, the font is displayed correctly.
Reproducible Demo
https://github.com/fhelwanger/ReactNativeArtExpoFontTest
- Start the project:
git clone https://github.com/fhelwanger/ReactNativeArtExpoFontTest.git
yarn install
yarn start
- Open the project on Expo Client.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Custom font not working in React Native - Stack Overflow
In my case it 'broke' custom font, so I had to add and use font ttf with variants (like Roboto-Thin, Roboto-Bold etc) in...
Read more >Using Custom Fonts With SVG in an Image Tag | CSS-Tricks
When we produce a PNG image, we use an <img> tag or a CSS background, and that's about it. It is dead simple...
Read more >How do I use a custom font in an SVG image on my site?
I created a custom Facebook icon using Inkscape and saved it as an svg. It uses the same font as the title of...
Read more >How to Use Fonts in SVG - Vecta.io
Learn how to use fonts on SVG, depending on how you intend to embed ... and each of them requires a different approach...
Read more >paisley pattern svg
I want to rotate it continuously I'm not able to apply animation on that pattern ... Plain Pattern lets you upload your own...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This appears to still be a problem.
see this guide: https://docs.expo.io/versions/latest/guides/using-custom-fonts.html scratch that - I see in the example you linked to that you did this as expected. perhaps Svg isn’t working with custom fonts at the moment, cc @nikki93 who might know more