-
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
[Fonts API] How to handle duplicate font variations #40288
Comments
Would definitely like some input here. cc @creativecoder @jeyip @mattwiebe @Addison-Stavlo @hellofromtonya @mtias @aristath |
I've been thinking about this a bit today. Here are some thoughts! First, I agree that this is important and a high priority to solve. However, I think that I would not necessarily classify this as a blocker for including this in WordPress 6.0 provided only the fonts used are enqueued and there are no significant performance pitfalls.
I don't think the end-user should ever need to be aware of the Webfonts API, or what's happening behind the scenes. The API itself should make the best decisions it can based on the information provided when fonts are registered through the API. If a user selects a font through the site editor, it should load based on the logic defined in the API. I think that the fonts API should behave similarly to the scripts/styles APIs in a number of ways, and the user not having to be aware of what's going on is one. For registering scripts, once a script is registered all subsequent If this logic is used, then In the scenarios described above, fonts defined within a theme's |
I disagree – this is a High Priority need. After testing this feature, I’m stuck with multiple registered and enqueued webfonts that point to dead links. As an experienced dev, I have no clue how to remove these from the frontend. I’ve spent over 5 hours pouring over docs and issues here to discover this one ticket. Others must be facing this same frustration. Is there any workaround to purge this old data? |
Update: This issue is no longer valid for the Fonts API once the Font Library is merged. Why? As shared in Ongoing Roadmap update #41479 (comment), the Fonts API's role changes to :
Font families and variations will no longer be "registered" or "enqueued" into the Fonts API. Rather, the font management through the Font Library will handle the user workflow. The decision making will no longer be in the Fonts API. Instead, the Fonts API will get / pull the fonts to be processed from Theme JSON merged data layer. |
Part of #41479.
What problem does this address?
It's not clear to the end-user how the Fonts API will behave regarding the registration and enqueueing of duplicated font variations.
Only enqueued fonts are added as inline styles in the front-end.
API scenarios
Trying to register a font face that was already registered
Which one should take precedence? The one that already exists, or the one that they're trying to re-register?
Trying to register a font-family that was already enqueued
What should happen?
Scenarios including
theme.json
After #39988 gets merged, new scenarios will come up now that we're considering
theme.json
as the source of truth for themes that are using this file.Trying to register and enqueue, through
theme.json
, a font face that was registered programmaticallyIn PHP:
In
theme.json
:Should we de-register/override the programmatically registered font face? Remember that we're trying to make
theme.json
the source of truth.Current behavior in #39988: both are added to the registered list.
However, the programmatically registered webfont is the one that gets enqueued. That's because it's found first when looking for registered font faces to enqueue and their attributes are equal (the provider is not taken into account in the comparison).
Trying to register and enqueue, through
theme.json
, a font face that was enqueued programmaticallyIn PHP:
In
theme.json
:Should we dequeue the programmatically enqueued and instead register + enqueue the
theme.json
face?Current behavior in #39988: both are enqueued.
Additional information
This problem is not a blocker for #39988 since that PR addresses a different matter. The above-mentioned behavior is already happening in
trunk
and #39988 is not the appropriate place to fix it.The text was updated successfully, but these errors were encountered: