-
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 families: data from theme.json
is not properly registered
#50576
Comments
This is because the I don't know what's the intention of that code or the way forward yet, but thought I'd share what I'm learning as early as possible, to gather thoughts from others. |
I do not foresee WordPress Core bundling local fonts, i.e. providing the local font files within WordPress Core. Rather, this is the job of the theme to define the typography and then extenders via plugins for further customization. @oandregal Can you provide more context as to why or when local font files would be bundled within WordPress Core? |
It's fine that we decide not to. My point is that there are issues in how it works now: data defined at the We should enforce what's expected. I'd suggest make all origins work the same, as we could change our mind, or people could use a filter to add them to the |
I'm confused by the testing steps of removing "System font". This font is not registered with the Fonts API. Why? It does not have a
Therefore, the Fonts API has no But I am curious of the results you had and why these are happening. I'll do some testing to see where this font is stored. |
I learned a few more things about the font library goals. This is how we aim it to work #40363 (comment) The takeaway for this issue is that the font library and the theme.json models are at odds. The font library currently passes data to the client using the theme.json data for lack of a better alternative, but it should develop its own data flow. A longer explanation is this. The "origins" is a key concept of theme.json data, and how any preset works. Take colors, for example:
While we only surface this "origins" to the UI for the color preset type, the underlying data flow/storage is the same for every other preset type. Compare how font families work now;
If we expected the theme.json model and the font library to work together, all origins should work, classic themes would have an API to add their fonts to the |
I'm closing this as the next steps would be to develop the font library data flow and stop using theme.json data. This needs to be tracked in other places and this will no longer be an issue. |
The mechanism for registering font families client-side depends on every font family being registered at the
theme
level. It should be able to register font families from any origin:default
,theme
orcustom
(user), like any other preset does.Test with data coming from the
default
origintheme.json
of TT3.theme.json
bundled with Gutenberg atlib/theme.json
.The expected result was that:
core/edit-site
has all font families defined by the different originsroot.settings.__experimentalFeatures.typography.fontFamilies.default
holds the "DM Sans" and "IBM plex mono".root.settings.__experimentalFeatures.typography.fontFamilies.theme
holds the rest: "Inter", "System font", "Source Serif pro".What happened instead was that:
root.settings.__experimentalFeatures.typography.fontFamilies.default
holds the "DM Sans" and "IBM plex mono". This is correct.root.settings.__experimentalFeatures.typography.fontFamilies.theme
holded all the fonts, the ones defined bydefault
and the ones defined by thetheme
. This is incorrect. It should not have the ones defined bydefault
default
don't show the proper labels ("DM Sans" and "Inter Plex mono") but the slug "dm-sans" and "ibm-plex-mono").Gravacao.de.ecra.a.partir.de.12-05-2023.12.16.38.webm
Test with data coming from the
custom
origintheme.json
of TT3.theme.json
for user data (it defines the system font):The expected result was that:
core/edit-site
has all font families defined by the different originsroot.settings.__experimentalFeatures.typography.fontFamilies.theme
holds all the fonts but "System font".root.settings.__experimentalFeatures.typography.fontFamilies.custom
holds the "System Font".What happened instead was that:
Gravacao.de.ecra.a.partir.de.12-05-2023.12.31.05.webm
Environment info
I've tested this with Gutenberg
trunk
and latest WordPresstrunk
.The text was updated successfully, but these errors were encountered: