[wp-trac] [WordPress Trac] #46020: API to register and enqueue web fonts
WordPress Trac
noreply at wordpress.org
Thu Jan 17 15:05:56 UTC 2019
#46020: API to register and enqueue web fonts
--------------------------+-----------------------------
Reporter: swissspidy | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
This is something that was suggested by @jonoalderson at WCUS and
discussed with @igrigorik and others.
There could be potential in providing a dedicated API for themes and
plugins to register and enqueue web fonts.
At the moment, developers need to build their own solutions for loading
fonts from Google Fonts, Typekit, or self-hosted fonts. This makes it hard
for others to hook into this process in order to modify or disable the
loading of these fonts. Performance and privacy concerns are some of the
reasons.
Some use cases that come to mind:
1. Google Fonts and Typekit currently don't set
[https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display
`font-display`]. One could hook into the font registration to download the
font CSS from the provider, enhance it with `font-display` and host it
locally. ([https://github.com/swissspidy/local-webfont something like
this])
2. Optimize font registration to request multiple font families from
Google Fonts or similar in one request (if supported)
2. For performance reasons, one could hook into the font registration to
completely disable web fonts and rely on system fonts instead
3. For privacy reasons, one could load a font from a different host / CDN
This could be as simple as `wp_enqueue_font` at the core, which in the
background could end up as a `wp_enqueue_style()` call.
When enqueueing a font, one obviously needs to specify a name/family, the
provider to load it from (or a URL) font weights, and perhaps other
options (`font-display`, etc.).
Any suggestions/feedback welcome :-)
-----
Related: #43898
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46020>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list