-
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 #50927
Font Library #50927
Conversation
Heads Up: The new Font Face was merged into Rebasing this PR on top of What is Font Face? See #45271 (comment) |
We are splitting the font library in several PRs to merge it progressively: |
|
Hey @matiasbenedetto Really nice work! Just a quick comment after seeing the first video. An example. It would be helpful to select - deselect as well as delete a font when one knows it will not be used. |
Hi @paaljoachim, yes! I think it does not appear on the screencast, but currently, there is a "uninstall" button available for the font families with no font faces activated. When clicked, It will remove the font definition and the font assets. |
Great! Thank you @matiasbenedetto Matias! |
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.
A question: Is there a specific reason for the Font Library to use a third-party proprietary CDN for fonts sources? Asking because use of Google Fonts was one of the reason the initial "Webfonts API" was not committed to WordPress two years ago. Then there was a GDPR related court case about usage of Google Fonts where, as far as I remember, that usage was deemed inappropriate/breaking the GDPR. There seem to be other sources for the same fonts.
Seems use of the Google Fonts CDN in WP should be discouraged, and core should not force any website to it. What is the chance to remove use of the huge (1.3MB) list of available Google fonts and replace it with a list to the same fonts hosted elsewhere? As far as I see there are several places that host the same open source fonts, even as NPM packages (would that be a preferable format?).
@azaozz I have the same doubts regarding Google Fonts and GDPR compliance. |
@matiasbenedetto I think that, for font families with active font faces, the button should be displayed anyway, but grayed out and with a hint saying that it is is not possible to delete that font because it is currently active somewhere(?). |
Hi @tomxygen, Yes! Good suggestion. I'm closing this PR because it was just a prototype. |
What?
This PR implements font management capabilities into the Gutenberg editor.
Screencast: Activate, de-activate and install fonts:
2023-05-24.14-43-40.mp4
Screencast: Persisting fonts installed across themes:
2023-05-24.15-15-23.mp4
Screencast: Uploading local font assets:
2023-05-29.16-54-46.mp4
Why?
Refer to #45271
How?
By the implementation of a Font Library.
What is the font library?
The Font Library consists of a font manager for WordPress. The Font Library is available globally, independently of the theme activated, similar to the Media Library. This list of installed fonts and their assets are site-wide available and the users can select the fonts activated (available in the editor) for each theme.
Using the Font Library the users can:
In this PR we implement the font installation from Google fonts and local fonts, but I think this implementation will make it easy to create third-party plugins that offer a list of fonts from which users can pick and install the ones they want to use.
How it works:
/wp-content/fonts
)./wp-content/fonts
. The assets from Google are called just at the time of previewing fonts in the font library. After the fonts is installed no other request to Google or other third-party servers will be made because the font assets are hosted locally in the/wp-content/fonts
folder.wp-content/fonts
folder and the font definitions are added to the list of installed fonts./wp-content/fonts
folder. Only the non-active fonts from the user-installed fonts can be uninstalled. Theme fonts will be able to be deactivated but not uninstalled.Known issues:
How the data is persisted?
User-installed fonts: the list of installed fonts is saved in a custom post type,
wp_fonts_library
, in the database, similar to how Global Styles. That is an addition to this PR. It is motivated by the necessity of having a list of fonts that is independent of the theme activated and currently, we don't have that ability.Theme installed fonts: the list of theme fonts comes from the theme origin of the Global Styles/Settings.
Active fonts list: From the previous 2 sources the user can add font definitions to a third list persisted in the Global Styles custom origin. This is the list of active fonts for each theme. If this list is not defined in Global Styles, all the theme fonts are active.
How to test
Use the feature as features in the screencast.
All the feedback about the design, behavior, and data-persistence of the feature is welcome!
About the code implementation
I consider that is not ready and it doesn't worth making a code review yet because the implementation is sketched to test if this work is on a good path. Currently, we are implementing just the happy path, there is not much error checking, no security checks, not performance optimization and no tests.
Previous explorations around this:
#46332
#50102