Fonts not properly being updated in the Site Editor
Pulling in feedback from the FSE Outreach Program's Build a Block Theme exploration:
I chose a Google Font at the exact step in the instructions and it worked fine. When I wanted to change the font later on, I can add new fonts to WP through the “Manage Theme Fonts” page, however the newly fonts there don’t show properly (they are added, but the font always falls back to the default system serif font). Also, the list of available fonts does not update in the site editor, I do still have the old font in there, even if I deleted it from the font management page. The font files are added to the assets folder so they are “physically” there, however they’re not loading in WP or the site editor. I’ve checked the Custom Styles entry in the wp_posts table and the old font is there, but none of the new fonts are.
It seems like we're running into a bug here when adding fonts after edits have been done!
Thanks @annezazu!
To help narrow this down, it would be good to know which Google font this happened with. @luminuu, could you let us know which font you added when you saw the bug? Thanks!
The font I originally chose that worked was Sofia Sans Condensed. I tried to switch to Albert Sans, Quattrocento Sans and JetBrains Mono afterwards, all of them failed. When I added these manually to the database, the fonts showed up in the site editor and on the Manage Fonts page. So I guess the error is somewhere in adding the JSON of the fonts to the custom styles.
I use 2 Google fonts, Dongle and Inter. I add them by enqueuing the Google Fonts stylesheet URLs that they build, which appears to be the way. The stylesheets are enqueued, and when I inspect the styles I see the correct font in the value; however, the browser always keeps falling back to the next available font. This only happens in the FS editor; displays fine on visitor-facing front-end.
The fonts are registered in theme.json, and show up in the FSE dropdown. However, selecting them changes nothing in the FSE. Choosing a vanilla font works fine.
A font related bug that is no longer relevant. Closing.