WC Fonts: Register imported google fonts for use in the editor #868
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use the (experimental?) Fonts API to load selected Google Fonts in block-based themes.
When fonts are loaded via the WordCamp Fonts admin screen, there's no easy way to use them in the editor. The Typography settings don't know about these fonts, and without being able to update the theme.json, a user can't add them.
With this PR, if a site is using a block theme and the user has added a google font to Appearance > Fonts, the font is registered & enqueued using the Fonts API (rather than output in
wp_head
). It's also loaded into the editor, and listed in the available Typography > Font Family options. When selected, Gutenberg automatically applies style or class, and the font is used.While this does touch the use of google fonts, this PR does not address anything in #739.
Tech details
wp_head_google_web_fonts
already works.* Jetpack does have a beta Google Fonts feature, but it's pulling from a small subset of fonts.
Screenshots
This example uses the following settings to load Comfortaa (variable), Tilt Warp (default), Open Sans (normal & italic, 300 weight), & Rubik Pixels (default).
How to test the changes in this Pull Request:
@import
URLsThere are checks in place to make sure this does not break if GB is accidentally disabled.