Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Font loading via CSS Font Loading API #146

Open
qtiki opened this issue Dec 9, 2019 · 4 comments
Open

Feature request: Font loading via CSS Font Loading API #146

qtiki opened this issue Dec 9, 2019 · 4 comments

Comments

@qtiki
Copy link

qtiki commented Dec 9, 2019

It would be nice if the resource-loader supported dynamic font loading "out of the box". Currently loading dynamic fonts requires the use of an external package like https://github.com/typekit/webfontloader.

Loading fonts could be implemented with the new CSS Font Loading API: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API

I know the technology is still experimental but the compatibility chart is already pretty good and hopefully will get better with time (Edge at least should be pretty 1:1 with Chrome now that they're switching to Webkit).

@englercj
Copy link
Owner

englercj commented Dec 11, 2019

I'm open to giving this a shot again now that browser tech has moved forward a bit.

In the past I've avoided it because of just how complex font loading is. So complex that it would more than double the size of the library just to handle font edge cases.

I wonder if it makes sense to have a separate plugin that adds font support to resource loader, rather than building it in the lib here given how much code seems to be required.

All that being said it has been a while since I looked into this problem space and the state of browsers so I'll at least do some investigation and see where we are. Or if your up to it, PRs are always welcome!

edit: one other complexity is that we support back to ie9 currently, so adding font support would need to support back to that browser as well. Even if we use a modern api we still have to write the fallbacks.

@creativefctr
Copy link

I think all you need is a Strategy around FontFaceObserver:
https://github.com/bramstein/fontfaceobserver
It supports old browsers and also is very lightweight

@englercj
Copy link
Owner

englercj commented Feb 7, 2020

PRs welcome.

@irongaze
Copy link

+1 to this concept - the Venn diagram of resource-loader users who also need to load fonts is likely a circle. :-) Happy to help test if someone with a better understanding of the internals is willing to take a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants