fontsource icon indicating copy to clipboard operation
fontsource copied to clipboard

Add support for native apps

Open bartvanandel opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. We're currently developing an app in React-Native, using Expo, and we need to use custom fonts (specifically, Barlow). While searching for a package that provides this font, I bumped into this excellent fontsource thing. Unfortunately, the fonts are only provided as .woff and .woff2, which is not supported on Android (see e.g. Expo documentation).

Describe the solution you'd like It would be very nice if you could also expose .otf (and/or ttf) fonts, which seem to be the best supported font format across all platforms.

Describe alternatives you've considered Alternatives in our case would be to bundle the fonts manually (which works fine, but requires keeping an eye on updated fonts manually), or use another package, which as far as I can tell don't offer as nice as a feature set (incl. easily switching to other, similar fonts) as yours.

Additional context none at this point

bartvanandel avatar Sep 12 '22 10:09 bartvanandel

Would #555 be a solution for you?

While TTF/OTF files aren't in our NPM packages (due to NPM package size restrictions), we do actually have downloads including TTF/OTF files available right now with the small download button found on the top bar of the current website.

ayuhito avatar Sep 12 '22 10:09 ayuhito

Perhaps email notifications for updates could be a feature to extend #555 and be more useful to you.

ayuhito avatar Sep 12 '22 10:09 ayuhito

#555 would be a nice resource to have available for font downloads in general, but it would still require manual work to stay up-to-date. If npm package size is the restricting factor, maybe this package could offer an npm script to download the font in a specific format (e.g. with options for otf, ttf, woff, woff2, etc)? Then we could add a postinstall script to our own package.json file to download the fonts after the package has been installed.

bartvanandel avatar Sep 12 '22 11:09 bartvanandel

For the time being though, I'm just going to have to download the fonts by myself. Gotta move forward. But having this option in the future would be nice!

bartvanandel avatar Sep 12 '22 11:09 bartvanandel

I've added our solution to a public gist, maybe you can use some of it: https://gist.github.com/bartvanandel/19921f48ce134c393bb38bb2c8887247

bartvanandel avatar Oct 03 '22 11:10 bartvanandel

Thanks! This gives me a lot more insight into how I would want to structure #562 to be beneficial to many people. I want to make most of the functionality of this project to be fully portable for teams to utilise.

ayuhito avatar Oct 03 '22 12:10 ayuhito

You're welcome! I do realize that our script is definitely cutting some corners, for instance, it would for sure benefit from some kind of hash match or version storage, so we can keep the number of downloads to a minimum instead of on every npm install, but for now this was good enough for us.

bartvanandel avatar Oct 03 '22 12:10 bartvanandel

Now that V5 is released, I think we could store all the TTF files into the font-files quite easily. We have all the necessary metadata to do so.

We just need to ensure when publishing to NPM, those TTF files are just ignored, as well as find all the TTF sources for all non-google custom fonts we host.

ayuhito avatar May 23 '23 04:05 ayuhito