-
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
Server-Side Font Face CSS Generation and Printing: Ongoing Roadmap (formerly the Fonts API) #41479
Comments
The vision for the font management through a formal Webfonts API is now available in the description of this roadmap (ie in the Vision section). The first priority is to solidify the architecture as all other tasks will be affected by these architectural changes:
Once these 2 tasks are done, then the remaining tasks can be prioritized along with impacts to update each of them to fit within the architectural changes. I removed the priority labels from each of these other tasks. |
This sounds great! A clear and well defined vision makes the tasks ahead much easier to understand. Trying to get into a bit more details, perhaps "brainstorm" a little more. One of the hard performance related questions would be: What happens when somebody decides to register the whole collection from https://fontsource.org/ (more than 1600 fonts)? It's pretty pointless (will need a dedicated UI and still the users will have a pretty hard time selecting fonts from such a huge list) but that doesn't mean it's not going to happen. That led to couple of questions:
For the first question, in most cases it seems registering can be done together with the enqueueing only for the fonts that are in use. That will speed things up and perhaps reduce complexity a little. Thinking a bit further implementation-wise: should registering a font be needed for enqueueing it? Seems not. A "prior art" is how scripts can be enqueued without a need to be registered. The second question is harder. Are we talking about building UI similar to the Google's webfonts picker? Seems anything less may not be enough, perhaps. Not sure what a UI for picking one out of a hundred fonts may be, but thinking it would be best to have an idea about it before deciding on the back-end code, so the requirements of that (and future) UI are met. |
Great to see this overview issue @hellofromtonya - this is super helpful as I've been struggling to keep up with the Fonts API proposals & progress. I noticed several features I see in other font APIs that aren't mentioned here and wanted to know if these are on your roadmap at all or would be something to propose for a future iteration:
|
One thing that's been bugging me is that I feel like "Webfonts" is wrong when I read it. I did some searching around, and my findings seem to point towards "Web fonts" as the preferred way to refer to this. I know this is a nit, but I think it's important to get it right and be consistent. here are some authoritative pages I found pointing to Web Fonts:
Other pages for Webfonts
|
@adamsilverstein Yeah, support for preloading is needed, but not sure what "downloading" has to do here? Thought is was decided that this API is for local fonts only. This has numerous advantages as discussed before. Downloading what, and from where? :) I'd also think that if a plugin wants to use external fonts from a CDN, like Google fonts, it would still consider downloading the open source fonts as available at places like https://github.com/fontsource/fontsource and not trying to capture the CDN's output (which may also have some compatibility or licensing issues as it is closed source). |
@mtias and I discussed this roadmap for both block and classic themes. From that discussion, I've updated the description of this ongoing roadmap including the "font library" vision, technical details, and a new FAQ section. The changes include publicly exposing |
Bundled in the API is a local fonts provider. It does not include remote font foundry handling. It does provide the means for plugin authors to create custom providers, such as to handle (a) an alternative local fonts approach or (b) remotely hosted fonts. IMO I don't think Core should force only local fonts. |
Thanks for clarifying @hellofromtonya and @azaozz
🎉 Great! |
I opened a separate issue for renaming consideration per @desrosj suggestion. Let's move the naming discussion to here #42868 |
Tracking the block level typography consistency effort #43242 |
⭐ Status Update:Status: Blocked by architectural work. DONE: ✅ The major architectural redesign (See #41481) is now merged. The new architecture is a code rewrite which has breaking changes. Some high level details:
NEXT: ⚪ There are 2 more architectural tasks that need to be completed to unblock the remaining bugs, performance, and feature work can continue.
👉 Where can you help?
|
⭐ Status Update ⭐ Status:
Big Picture👉 It's a NEW API 👉 BC Layer Who's impacted?
⭐ 👉 Next steps
These 2 issues are must-haves:
All open PRs are impacted. This means each open issue and any of its PRs must be evaluated one-by-one and if still relevant, rebased and rebuilt to apply changes to the new API. TODO:
|
@hellofromtonya Please let me know how I can help with this effort in relation to WP 6.2. Is there already a corresponding Trac ticket for it? |
Thanks for the update @hellofromtonya! While reading through your comment, I was a bit skeptical on what the change would mean for classic themes since the original proposal would have indeed been agnostic. But as long as a classic theme can introduce support via Let's make sure to keep the classic theme considerations on our radar, we need to make sure that the way the Font Library is eventually implemented satisfies both block and classic themes use-cases. |
Thank @felixarntz. Yesterday, I confirmed that since WordPress 6.0.0 (with the
Cool! I created this Proposal yesterday to stay with that convention for classic themes, use a
As far as I know, the Font Library will only work with Site Editor, which is only available to block themes. Classic themes use Customizer. I think the better place to raise awareness of classic themes with the Font Library is in this issue #45271, i.e. where managing fonts and font library are being discussed and worked on. |
Sorry for the delay in responding to you @webd-uk.
If the user has already selected a plugin defined font, then that font should be saved in the database when saving those selections in the Site Editor. Those fonts then should be within the theme.json merged data, i.e. Then when it's time to "print" As for what gets "activated" in the Font Library, I think it's also using that same data. What isn't there yet is the means for a plugin to "register" its defined fonts with the Font Library. I'd suggest asking the question and contributing in the main issue #45271 or in the Font Library's WIP PR #50927. |
Thank you, @hellofromtonya! I will definitely be doing that but need to read up on everything first. Thanks again, Wordpress has needed this built-in feature for soooooooo long! |
Update 22 Jun 2023New LearningsNew Learnings since my 19th Jun update: What currently works with the Fonts Library?WordPress Core ✅ The stopgap code in WordPress Core since 6.0.0 works with the Fonts Library However, the Fonts API in Gutenberg does not work with the Fonts Library and must be changed before the Fonts Library is merged. ❌ Should the Fonts API's architecture change?Yes! ✅ It needs a near complete redesign. Issue #51769 is for the redesign, transforming the Fonts API into only a Font Face styles generator and printer. WIP PR #51770 is what I envision as the redesign. What about classic sites?Yes, supported ✅ Classic themes and plugins can have their Classic themes have 2 options:
Plugins supporting classic sites can use Option 1. What about font-face property validation?Yes, still required ✅ To support classic sites and potentially other needed customizations, the new Font Face design exposes a As any source could invoke that What about "providers"?Fonts Library only supports serving To keep parity with the Fonts Library, the Fonts API support of custom providers will be removed. The new design will only support local font files. This change will ensure fonts work the same on all types of sites. If enough of need is discovered, then a future enhancement could be to add custom provider support. What about sites currently using the Fonts API?The API is experimental. However, the API has taken the approach of supporting backward compatibility through the BC Layer to avoid sites breaking. The new Font Face generation is a big big change. Care is needed to consider how to safeguard sites currently using the Fonts API while guiding developers towards where and what needs to change. |
The description of this roadmap is now updated for "Font Face", i.e. to define its new role in font management and its scope of work. |
UpdateFont Face is ready to be introduced into WordPress Core. It is a direct replacement for TODO:
|
Here's the Core Trac ticket for merging Font Face into Core https://core.trac.wordpress.org/ticket/59165. |
Introducing Font Face, a server-side `@font-face` styles generator and printer. tl;dr: * Introduces Font Face. * Deprecates `_wp_theme_json_webfonts_handler()`. **Introduce Font Face** From an array of fonts (i.e. each font-family and its font variations to be processed), it: 1. Validates each `font-face` declaration, i.e. the CSS property and value pairing. If validation fails, processing stops with no font-face styles printed. 3. Generates the `@font-face` CSS for each font-family. 4. Prints the CSS within a `<style id="wp-fonts-local">` element. The entry point into Font Face is through a new global function called `wp_print_font_faces()`, which is automatically called: * when the `'wp_head'` hook runs (for the front-end). * when the `'admin_print_styles'` hook runs (for the back-end). * when `_wp_get_iframed_editor_assets()` runs to inject the `@font-face` styles into the iframed editor. Once called, it gets the fonts from Theme_JSON merged data layer, which includes theme defined fonts and user activated fonts (once the Font Library #59166 is introduced into Core). For classic sites, themes and plugins can directly call `wp_print_font_faces()` and pass their fonts array to it for processing. **Deprecates `_wp_theme_json_webfonts_handler()`.** As Font Face is a direct replacement, the stopgap code in `_wp_theme_json_webfonts_handler()` (introduced in 6.0.0 via [53282]) is deprecated and unused in Core. **Props note:** There's a long multiple year history baked into Font Face, which dates back to the early versions of a web font API (see #46370 and [WordPress/gutenberg#41479 roadmap]. The props list includes those who contributed from those early versions up to this commit. **References:** * #46370 original (Web)Fonts API proposal for registering and enqueuing web fonts. * [WordPress/gutenberg#41479 Gutenberg tracking issue] which includes the evolution from Webfonts API to Fonts API to Font Face. * [53282] / #55567 Added the stopgap code `_wp_theme_json_webfonts_handler()` in 6.0. * [https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face @font-face on mdn web docs] * #59166 Font Library: Font manager for WordPress Follow-up to [53282]. Props aristath, jonoaldersonwp, hellofromTonya, andraganescu, annezazu, antonvlasenko, arena, askdesign, azaozz, bph, bradley2083, colorful-tones, costdev, davidbaumwald, desrosj, dingo_d, djcowan, domainsupport, dryanpress, elmastudio, flixos90, francina, garrett-eclipse, gigitux, grantmkin, grapplerulrich, gziolo, ironprogrammer, jb510, jeffpaul, jeremyyip, jffng, joostdevalk, jorgefilipecosta, juanmaguitar, mamaduka, matveb, mburridge, mitogh, ndiego, ntsekouras, oandregal, ocean90, oglekler, paaljoachim, pagelab, peterwilsoncc, poena, priethor, scruffian, SergeyBiryukov, shiloey, simison, skorasaurus, soean, westonruter, wildworks, zaguiini. Fixes #59165. git-svn-id: https://develop.svn.wordpress.org/trunk@56500 602fd350-edb4-49c9-b593-d223f7449a82
Introducing Font Face, a server-side `@font-face` styles generator and printer. tl;dr: * Introduces Font Face. * Deprecates `_wp_theme_json_webfonts_handler()`. **Introduce Font Face** From an array of fonts (i.e. each font-family and its font variations to be processed), it: 1. Validates each `font-face` declaration, i.e. the CSS property and value pairing. If validation fails, processing stops with no font-face styles printed. 3. Generates the `@font-face` CSS for each font-family. 4. Prints the CSS within a `<style id="wp-fonts-local">` element. The entry point into Font Face is through a new global function called `wp_print_font_faces()`, which is automatically called: * when the `'wp_head'` hook runs (for the front-end). * when the `'admin_print_styles'` hook runs (for the back-end). * when `_wp_get_iframed_editor_assets()` runs to inject the `@font-face` styles into the iframed editor. Once called, it gets the fonts from Theme_JSON merged data layer, which includes theme defined fonts and user activated fonts (once the Font Library #59166 is introduced into Core). For classic sites, themes and plugins can directly call `wp_print_font_faces()` and pass their fonts array to it for processing. **Deprecates `_wp_theme_json_webfonts_handler()`.** As Font Face is a direct replacement, the stopgap code in `_wp_theme_json_webfonts_handler()` (introduced in 6.0.0 via [53282]) is deprecated and unused in Core. **Props note:** There's a long multiple year history baked into Font Face, which dates back to the early versions of a web font API (see #46370 and [WordPress/gutenberg#41479 roadmap]. The props list includes those who contributed from those early versions up to this commit. **References:** * #46370 original (Web)Fonts API proposal for registering and enqueuing web fonts. * [WordPress/gutenberg#41479 Gutenberg tracking issue] which includes the evolution from Webfonts API to Fonts API to Font Face. * [53282] / #55567 Added the stopgap code `_wp_theme_json_webfonts_handler()` in 6.0. * [https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face @font-face on mdn web docs] * #59166 Font Library: Font manager for WordPress Follow-up to [53282]. Props aristath, jonoaldersonwp, hellofromTonya, andraganescu, annezazu, antonvlasenko, arena, askdesign, azaozz, bph, bradley2083, colorful-tones, costdev, davidbaumwald, desrosj, dingo_d, djcowan, domainsupport, dryanpress, elmastudio, flixos90, francina, garrett-eclipse, gigitux, grantmkin, grapplerulrich, gziolo, ironprogrammer, jb510, jeffpaul, jeremyyip, jffng, joostdevalk, jorgefilipecosta, juanmaguitar, mamaduka, matveb, mburridge, mitogh, ndiego, ntsekouras, oandregal, ocean90, oglekler, paaljoachim, pagelab, peterwilsoncc, poena, priethor, scruffian, SergeyBiryukov, shiloey, simison, skorasaurus, soean, westonruter, wildworks, zaguiini. Fixes #59165. Built from https://develop.svn.wordpress.org/trunk@56500 git-svn-id: http://core.svn.wordpress.org/trunk@56012 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Introducing Font Face, a server-side `@font-face` styles generator and printer. tl;dr: * Introduces Font Face. * Deprecates `_wp_theme_json_webfonts_handler()`. **Introduce Font Face** From an array of fonts (i.e. each font-family and its font variations to be processed), it: 1. Validates each `font-face` declaration, i.e. the CSS property and value pairing. If validation fails, processing stops with no font-face styles printed. 3. Generates the `@font-face` CSS for each font-family. 4. Prints the CSS within a `<style id="wp-fonts-local">` element. The entry point into Font Face is through a new global function called `wp_print_font_faces()`, which is automatically called: * when the `'wp_head'` hook runs (for the front-end). * when the `'admin_print_styles'` hook runs (for the back-end). * when `_wp_get_iframed_editor_assets()` runs to inject the `@font-face` styles into the iframed editor. Once called, it gets the fonts from Theme_JSON merged data layer, which includes theme defined fonts and user activated fonts (once the Font Library #59166 is introduced into Core). For classic sites, themes and plugins can directly call `wp_print_font_faces()` and pass their fonts array to it for processing. **Deprecates `_wp_theme_json_webfonts_handler()`.** As Font Face is a direct replacement, the stopgap code in `_wp_theme_json_webfonts_handler()` (introduced in 6.0.0 via [53282]) is deprecated and unused in Core. **Props note:** There's a long multiple year history baked into Font Face, which dates back to the early versions of a web font API (see #46370 and [WordPress/gutenberg#41479 roadmap]. The props list includes those who contributed from those early versions up to this commit. **References:** * #46370 original (Web)Fonts API proposal for registering and enqueuing web fonts. * [WordPress/gutenberg#41479 Gutenberg tracking issue] which includes the evolution from Webfonts API to Fonts API to Font Face. * [53282] / #55567 Added the stopgap code `_wp_theme_json_webfonts_handler()` in 6.0. * [https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face @font-face on mdn web docs] * #59166 Font Library: Font manager for WordPress Follow-up to [53282]. Props aristath, jonoaldersonwp, hellofromTonya, andraganescu, annezazu, antonvlasenko, arena, askdesign, azaozz, bph, bradley2083, colorful-tones, costdev, davidbaumwald, desrosj, dingo_d, djcowan, domainsupport, dryanpress, elmastudio, flixos90, francina, garrett-eclipse, gigitux, grantmkin, grapplerulrich, gziolo, ironprogrammer, jb510, jeffpaul, jeremyyip, jffng, joostdevalk, jorgefilipecosta, juanmaguitar, mamaduka, matveb, mburridge, mitogh, ndiego, ntsekouras, oandregal, ocean90, oglekler, paaljoachim, pagelab, peterwilsoncc, poena, priethor, scruffian, SergeyBiryukov, shiloey, simison, skorasaurus, soean, westonruter, wildworks, zaguiini. Fixes #59165. Built from https://develop.svn.wordpress.org/trunk@56500 git-svn-id: https://core.svn.wordpress.org/trunk@56012 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Closing this out as https://core.trac.wordpress.org/ticket/59165 shipped. Let me know if that's incorrect and I can reopen. Thanks for all the hard work here! |
This is an epic ticket to share the ongoing roadmap including:
Updates:
Changed to Font Face: to server-side generate and print fonts'
@font-face
stylesWith the introduction of the new Fonts Library, the role of the Fonts API has significantly changed as noted in #41479 (comment).
Fonts will be presented to users via the Fonts Library, rather than through the Fonts API.
Font Face "gets" the fonts to print from Theme JSON merged data layer. Fonts are no longer registered or enqueued directly with it.
A full API is no longer needed. Thus, Font Face replaces the Fonts API.
Vision
As part of fonts management and Fonts Library,
This API's job is to provide the backend capabilities to support the "font library" to include font management and dynamic building of the
@font-face
styles.The "font library" feature will continue to be built, refined, stabilized, and tuned over multiple WordPress releases.
Font Library
See #50927.
The idea is to have the concept of a font library on a site to
The fonts in the library can come from:
The fonts to be used in the site are saved and available via Theme JSON merged data layer, i.e.
WP_Theme_JSON_Resolver_Gutenberg::get_merged_data()->get_settings()
.FAQ
What about classic sites?
Yes, supported ✅
Classic themes and plugins can have their
@font-face
styles generated and printed. How?Classic themes have 2 options:
'wp_head'
and'admin_print_styles'
and within that callback function, invoke a new print method and pass their fonts to it.theme.json
file that only defines the fonts. See issue [Fonts API] Proposal: classic themes define fonts in a theme.json file #51714 for more information.Plugins supporting classic sites can use Option 1.
Ongoing work
Architecture
⭐ Required for Core introduction:
Performance
⭐ Required for Core introduction:
None
Feature needs
⭐ Required for Core introduction:
None
Future enhancements
Bugs
None
Documentation
fontFace
and it’s values intheme.json
schema #41844 ⚪Backports
Future.
Tracking key
✅ Done
⚪ WIP: work in progress
🟡 Experiment WIP
🍏 in testing or code review
🔴 Danger > immediate action needed
🚫 Blocked
⭐ Needed for WP Core introduction
The text was updated successfully, but these errors were encountered: