-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Font Library: Prefer downloading WOFF instead of TTF font files #57706
Conversation
Thank you for looking into this, @aristath! I've tested this manually but it would always get me TTF files. I've looked through the source code, and the It looks like a list of all Google Fonts, with a I've tested this with Noto Sans. In the file from w.org, Noto Sans has the ID I think to make WOFF2 work, folks at Automattic need to update the Google Fonts file to include WOFF2 files and prefer delivering these over TTF. Pinging @matiasbenedetto, @mikachan, @annezazu and @richtabor for visibility. I'd also like to hear some input from the @WordPress/performance team on this. For reference, here's the issue I've found that exists already: #55049 |
Ah that makes sense... Thank you so much for digging deeper into this @luminuu! |
It would be best for the file on the CDN to contain links for all the available formats, TTF, WOFF, WOFF2. Then the consumer can pick whatever they prefer. There could be a filter for example.
We should match compat data with the browserslist config to see what is possible. Ideally we'd use WOFF2 directly. I don't see why it shouldn't be possible at first glance. |
I think I found the code that generates that data... |
Created issue on WordPress/google-fonts-to-wordpress-collection#1 👍 |
Since this has been fixed upstream now and I assume it will be added to Gutenberg 17.6, is there anything left to do on this repository here to make the changes in the upstream repository work? @mikachan @matiasbenedetto |
We still need to update the URL of the default font collection in Gutenberg, but that will be handled in a separate PR to this. I believe we can close this PR in favour of WordPress/google-fonts-to-wordpress-collection#3 being merged. Thanks for checking! |
This PR updates the
Exactly, we need to consume the new data: In this in-progress PR, I updated the URL of the new font collection data, among other changes. |
Closing this PR since its code is irrelevant. Discussions can continue on the other issues and PRs 👍 |
What?
Issue reported on WP's Slack by @luminuu:
Why?
.ttf
is an antiquated format, much larger in size than.woff
or.woff2
and also of lower quality, supporting far fewer features available in modern fonts.How?
Added a
user-agent
to ourwp_remote_get
call. Previously, there was no user-agent set so the default WP one was used. The user-agent selected here will download.woff
files, so that we can still support some older browsers.Looking at the browser supports for woff2 on caniuse.com I think we can switch to
woff2
instead ofwoff
, but I'm not 100% certain so I added a comment explaining why this particular user-agent was selected, and which one to use if we want to use woff2.