-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Fix font loading for uploaded fonts with names of more than one word. #58853
Conversation
…ems loading fonts with several words in the font name.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -369 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @juanfra 👋 , thanks for working on this.
I did some testing, and it's working for the font family mentioned in the original issue description. Still, it's not working as expected using other font families with multi-word names:
2024-02-08.16-53-44.mp4
… fonts. Avoid using quotes when it's only one font, so Google Chrome can load it properly.
Thanks @matiasbenedetto ✨ I've been checking that, and apparently, Google Chrome was picky about loading the font if the font family had quotes in it. I've pushed some changes that should also fix that. It wasn't noticeable before because the font library is showing the svg. I also added that the font is added to the browser when installing, as the preview in the sidebar wasn't working when installing from Google fonts. 🎥 This is how it's looking now Screen.Recording.2024-02-09.at.17.27.05.mov(I also fixed some typos in a couple of variables) |
This is a good enhancement that partially fixes the problem. These are the results of my tests: ✔️ Single word without 'special' characters (i.e.: Aclonica, Bangers) Could we polish this a bit more to make the font families with multiple words with special characters work? |
@juanfra thanks again for working on this. I have been debugging the problem mentioned here #58853 (comment) and I found several edge cases (Wordpress theme.json slugs formatting, firefox specific needs, and differences between CSS font-family value and name of font faces loaded by JS) so I submitted a PR alternative to this one which I think is (hopefully) covering most of the cases: #59019 Could you please review and test it? |
Thanks, @matiasbenedetto - I came back to this one last night after work and ran into the same things as you. I had most things sorted out but was working on the firefox/chromium discrepancy, and I was going to come back at it again tonight. I'm going to be reviewing your PR, you have all the edge cases sorted out, so we could close this in favor of yours. |
What?
Update the use of quotes in font family names, so that they're properly loaded in the browser.
Fixes #58765
Why?
When uploading a font with a name of more than one word,
formatFontFamily
was formatting things to in a way that was preventing the font from being loaded correctly in the browser (for a later use). As a result, the font would only be available after refresh.How?
Updating the way the font family is being formatted so that it can be loaded correctly in the browser. And adding the font to the whole document so that it's also accessible in the sidebar.
Testing Instructions
Uploading new fonts
Installing Google fonts
Testing Instructions for Keyboard
Screenshots or screencast
Screen.Recording.2024-02-08.at.17.02.23.mov