Skip to content

Fonts not differentiated by unicode-range #48813

Closed

Description

@strarsis

Description

Fonts that are registered with the Fonts API (including by theme.json) are currently not differentiated by the unicode-range.

convert_variation_into_handle only uses the font-weight and font-style for generating a handle, not unicode-range.
https://github.com/WordPress/gutenberg/blob/trunk/lib/experimental/fonts-api/class-wp-fonts-utils.php#L53

Just adding unicode-range to the array of processed properties solves the issue. But unicode range normalization may be required to ensure that fonts with same unicode-range but differing notation of the unicode-range are treated as identical.

Step-by-step reproduction instructions

  1. Declare two font files for a font-face with same parameters, except for a unicode-range.
  2. Notice that the font face of only one font file is eventually enqueued, all the other font files will not be usable.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

  1. added
    [Type] Enhancement
    on Mar 7, 2023
  2. added
    [Feature] Typography
    and removed on Sep 25, 2023
  3. tyxla commented on Sep 28, 2026

    @tyxla
    Member

    Closing this, as I tested manually and confirmed it was fixed.

    For the test I registered two fontFace entries that had the same weight and style but different unicodeRange values. Both @font-face rules were printed on the frontend, each with the correct unicode-range:

    @font-face{font-family:"Unicode Test";font-style:normal;font-weight:400;font-display:fallback;src:url('https://example.com/latin.woff2') format('woff2');unicode-range:U+0000-00FF;}
    @font-face{font-family:"Unicode Test";font-style:normal;font-weight:400;font-display:fallback;src:url('https://example.com/cyrillic.woff2') format('woff2');unicode-range:U+0400-045F;}

    The Fonts API was replaced by Font Face in #51770. Font Face does not generate handles, so it keeps every fontFace entry, including ones that differ only by unicode-range. FWIW, the Fonts API was later deprecated in #52485 and fully removed in #82813.

    Feel free to reopen if you still see this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Typography[Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions