[wp-trac] [WordPress Trac] #59165: Font Face: Server-side @font-face styles generator and printer

WordPress Trac noreply at wordpress.org
Tue Aug 22 13:21:50 UTC 2023


#59165: Font Face: Server-side @font-face styles generator and printer
----------------------------+--------------------------------------------
 Reporter:  hellofromTonya  |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  6.4
Component:  General         |    Version:
 Severity:  normal          |   Keywords:  gutenberg-merge needs-dev-note
  Focuses:                  |
----------------------------+--------------------------------------------
 Introducing Font Face, a server-side `@font-face` styles generator and
 printer. This ticket tracks merging Font Face from Gutenberg into Core.

 == What is Font Face?

 Font Face's role is to generate and print the `@font-face` styles for all
 theme defined and user activated fonts (activation will be handled by Font
 Library - coming soon).

 There is no font registration or enqueuing.

 It is not involved in the process of determining which fonts the site
 should or is using. Rather, it processes what is passed to it or, if none,
 pulls / gets the fonts from Theme_JSON's merged data layer.

 It introduces a new global function called `wp_print_font_faces()`. This
 function 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 is introduced into Core).

 == What is `@font-face` styles?

 Per [https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face mdn web
 docs]:
 >The `@font-face` CSS at-rule specifies a custom font with which to
 display text; the font can be loaded from either a remote server or a
 locally-installed font on the user's own computer.

 == Does it work on classic sites too?

 Yes. For classic sites, themes and plugins can directly call
 `wp_print_font_faces()` and pass their fonts array to it for processing.

 == Does it replace `_wp_theme_json_webfonts_handler()`?

 Yes. Font Face is a direct replacement for the stopgap code in
 `_wp_theme_json_webfonts_handler()` that was introduced in 6.0 via
 [53282].

 == References:
 * #46370 original (Web)Fonts API proposal for registering and enqueuing
 web fonts.
 * [https://github.com/WordPress/gutenberg/issues/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]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59165>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list