Make WordPress Core


Ignore:
Timestamp:
02/13/2023 02:31:06 PM (12 months ago)
Author:
hellofromTonya
Message:

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:

Follow-up to [53282].

Props luehrsen, aristath, ehtmlu, hellofromTonya, wetah.
Fixes #57430.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r55279 r55314  
    35213521     *
    35223522     * @since 6.0.0
     3523     * @since 6.2.0 Removed local() CSS.
    35233524     *
    35243525     * @param string $font_family Font family.
     
    35273528     */
    35283529    $fn_compile_src = static function( $font_family, array $value ) {
    3529         $src = "local($font_family)";
     3530        $src = '';
    35303531
    35313532        foreach ( $value as $item ) {
     
    35423543                : ", url('{$item['url']}') format('{$item['format']}')";
    35433544        }
     3545
     3546        $src = ltrim( $src, ', ' );
    35443547
    35453548        return $src;
Note: See TracChangeset for help on using the changeset viewer.