Themes: Remove local() from @font-face styles in _wp_theme_json_webfonts_handler().

Removes adding `local()` as a `@font-face` `src` within `_wp_theme_json_webfonts_handler()`.

Why?

To fix font incompatibilities when a user has the font-family locally installed on their viewing computer or device. It's unknown if all of the font-face variations specified by theme.json and/or global styles are:

* installed on the user's computer/device.
* and in one file or multiple files.

The previous implementation used the `src` specified when registering the font with the API. That src will likely vary from user computer/device to user computer/device.

To avoid these unknowns which could cause incompatibilities or styling issues, this changeset removes adding `local()` to the generated font-face CSS styles.

References:
* [https://github.com/WordPress/gutenberg/pull/47254 Gutenberg PR 47254]

Follow-up to [53282].

Props luehrsen, aristath, ehtmlu, hellofromTonya, wetah.
Fixes #57430.
Built from https://develop.svn.wordpress.org/trunk@55314


git-svn-id: http://core.svn.wordpress.org/trunk@54847 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2023-02-13 14:33:18 +00:00
parent e70f9b1a11
commit be815b3093
2 changed files with 5 additions and 2 deletions

View File

@ -3520,13 +3520,14 @@ function _wp_theme_json_webfonts_handler() {
* Compiles the 'src' into valid CSS. * Compiles the 'src' into valid CSS.
* *
* @since 6.0.0 * @since 6.0.0
* @since 6.2.0 Removed local() CSS.
* *
* @param string $font_family Font family. * @param string $font_family Font family.
* @param array $value Value to process. * @param array $value Value to process.
* @return string The CSS. * @return string The CSS.
*/ */
$fn_compile_src = static function( $font_family, array $value ) { $fn_compile_src = static function( $font_family, array $value ) {
$src = "local($font_family)"; $src = '';
foreach ( $value as $item ) { foreach ( $value as $item ) {
@ -3542,6 +3543,8 @@ function _wp_theme_json_webfonts_handler() {
: ", url('{$item['url']}') format('{$item['format']}')"; : ", url('{$item['url']}') format('{$item['format']}')";
} }
$src = ltrim( $src, ', ' );
return $src; return $src;
}; };

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.2-beta1-55313'; $wp_version = '6.2-beta1-55314';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.