Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fonts with spaces are not correctly applied #60040

Closed
srueegger opened this issue Mar 20, 2024 · 7 comments · Fixed by #60093
Closed

Fonts with spaces are not correctly applied #60040

srueegger opened this issue Mar 20, 2024 · 7 comments · Fixed by #60093
Assignees
Labels
[Feature] Typography Font and typography-related issues and PRs [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@srueegger
Copy link

Description

If I upload a font (woff2) that has one or more spaces in the name, this font is not declared correctly in the CSS in the frontend and is therefore not displayed.

Here is the concrete problem:

When I upload the font "Heineken Serif 18" in the new font library (The fonts I use are attached) the following CSS is created in the frontend:

body { --wp--preset--font-family--heineken-serif-18: Heineken Serif 18; }

Therefore, the font is not displayed: But it should be the following:

body { --wp--preset--font-family--heineken-serif-18: "Heineken Serif 18"; }

The strange thing is that I installed a second font directly from Google Fonts as a test (see attached screenshot). The font is called "PT Sans", and this is correctly declared with quotation marks.

Step-by-step reproduction instructions

  1. Go to Theme Customizer
  2. Open The Font Library
  3. Upload the Fonts
  4. Set the Font as Default

Screenshots, screen recording, code snippet

Bildschirmfoto vom 2024-03-20 14-57-13

Environment info

WordPress 6.5-RC3-57856,
Ubuntu 22.04 Desktop System in Firefox and Google Chrome

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

@srueegger srueegger added the [Type] Bug An existing feature does not function as intended label Mar 20, 2024
@srueegger
Copy link
Author

I forgot to add the ZIP Files with the Fonts.

heinekene-woff2.zip

@jordesign jordesign added the [Feature] Typography Font and typography-related issues and PRs label Mar 20, 2024
@annezazu
Copy link
Contributor

Thank you for opening and testing @srueegger. Really appreciate it. @matiasbenedetto can you look into this? Adding to 6.5 to be safe.

@carolinan
Copy link
Contributor

I was able to reproduce the issue with the fonts in the zip file.

I tried uploading:
A font that has one space, but no numbers. The quotes were added.
A font that has two spaces, but no numbers. The quotes were added.
Another font that has one space and numbers. The quotes were not added.

So it seems related to the numbers, not the spaces?, Perhaps it is an issue in maybe_add_quotes() in WP_Font_Utils?

@matiasbenedetto matiasbenedetto self-assigned this Mar 21, 2024
@matiasbenedetto
Copy link
Contributor

matiasbenedetto commented Mar 21, 2024

Thanks for reporting the issue!

This isn't a problem related to the font library source code but a bug in the WP_Font_Face_Resolver class.
I found that this method seems to be causing the problem:
https://github.com/WordPress/wordpress-develop/blob/8d0aed455b1790c5d51386f7675d9e8d68e48edf/src/wp-includes/fonts/class-wp-font-face-resolver.php#L78-L95

I'll submit a PR with a fix soon.

@matiasbenedetto
Copy link
Contributor

matiasbenedetto commented Mar 21, 2024

I took a closer look at this issue, and I found that this issue is in fact part of the font library codebase or at least can be fix there reducing it's scope which I think it's safer considering the next release 6.5 release. Could you please review this potential fix: #60093 ?

@getdave getdave changed the title WordPress RC3 Gutenberg Font-Library Fonts with spaces are not correctly applied Mar 25, 2024
@getdave
Copy link
Contributor

getdave commented Mar 25, 2024

@srueegger Thanks for raising this Issue. I trust you won't mind that I've taken the liberty of renaming this Issue to better reflect the problem at hand.

It looks like there is a potential fix. Are you able to assist in testing?

@getdave
Copy link
Contributor

getdave commented Mar 28, 2024

Test coverage added and merged in #60221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Typography Font and typography-related issues and PRs [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants