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.

Can't use custom fonts with SVG (or react-native-art)

See original GitHub issue

Environment

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

  1. Load some custom font:
await Font.loadAsync({
  IndieFlower: require('./assets/fonts/IndieFlower.ttf')
});
  1. 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

  1. Start the project:
git clone https://github.com/fhelwanger/ReactNativeArtExpoFontTest.git
yarn install
yarn start
  1. Open the project on Expo Client.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
iamelicommented, Aug 24, 2018

This appears to still be a problem.

1reaction
brentvatnecommented, Feb 20, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

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