expo / google-fonts

Use any of the 1000+ fonts (and their variants) from fonts.google.com in your Expo app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working on web, font source is missing uri prop

Njaah-0 opened this issue · comments

Hi,
I tried to use this package in pretty fresh project, but run into an issue where nothing happened. My code looks like this:
Screenshot 2020-07-11 at 11 03 22

fontsLoaded stays false and error is always null (but that's another issue). I then did some digging and found out that font source passed to loadAsync looks like this:
Screenshot 2020-07-11 at 11 04 48
But then the FontLoader.web.js in expo-font package expects that object passed to it has property called uri, otherwise invalid source error is thrown.

I modified FontLoader.web.js code like this and it started working, but maybe this package should add this uri prop when user is on web?
Screenshot 2020-07-11 at 11 07 45

Still relevant in 2022.

Thanks so much for sharing

@Njaah-0 Is it necessary to modify the code behind useFonts (FontLoader.web.js) to use it on the web? Could you share your solution or explain what you did a bit further? thx