Make WordPress Core


Ignore:
Timestamp:
02/20/2024 07:09:43 AM (10 months ago)
Author:
youknowriad
Message:

Editor: Format and sanitize font family names according the CSS spec.

This fixes two bugs in the font library.

  • Fonts using special characters were not being rendered properly in the frontend.
  • Allows the ability to use generic() in font family names.

Props mmaattiiaass, nithins53, kafleg, vivekawsm, swissspidy, audrasjb.
Fixes #60537.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/fonts/font-library/wpFontUtils/sanitizeFontFamily.php

    r57539 r57657  
    3636        return array(
    3737            'data_families_with_spaces_and_numbers' => array(
    38                 'font_family' => 'Rock 3D , Open Sans,serif',
    39                 'expected'    => '"Rock 3D", "Open Sans", serif',
     38                'font_family' => 'Arial, Rock 3D , Open Sans,serif',
     39                'expected'    => 'Arial, "Rock 3D", "Open Sans", serif',
    4040            ),
    4141            'data_single_font_family'               => array(
    4242                'font_family' => 'Rock 3D',
    4343                'expected'    => '"Rock 3D"',
    44             ),
    45             'data_no_spaces'                        => array(
    46                 'font_family' => 'Rock3D',
    47                 'expected'    => 'Rock3D',
    4844            ),
    4945            'data_many_spaces_and_existing_quotes'  => array(
     
    5955                'expected'    => '"Rock 3D"',
    6056            ),
     57            'data_font_family_with_generic_names'   => array(
     58                'font_family' => 'generic(kai), generic(font[name]), generic(fangsong), Rock 3D',
     59                'expected'    => 'generic(kai), "generic(font[name])", generic(fangsong), "Rock 3D"',
     60            ),
    6161        );
    6262    }
Note: See TracChangeset for help on using the changeset viewer.