Skip to content

WP Webfonts: avoid duplicated font families if the font family name was defined using fallback values. - #46378

Merged
matiasbenedetto merged 4 commits into
trunkfrom
fix/wp-webfonts_get-font-slug
Dec 9, 2022
Merged

matiasbenedetto merged 4 commits into
trunkfrom
fix/wp-webfonts_get-font-slug

Conversation

@matiasbenedetto

@matiasbenedetto matiasbenedetto commented Dec 7, 2022 •

Copy link
Copy Markdown
Contributor

What?

WP Webfonts: avoid duplicated font families if the font family name was defined using fallback values

Why?

Because of #46376

How?

The function gutenberg_add_registered_webfonts_to_theme_json is adding the fonts twice when the font family name has fallback values. This is because how are we compairing the slug of the fonts.

In this PR, we change the get_font_slug function to return the family slug if it is already defined. If it's not defined, the function returns the font family name. If the font family has fallback values, it creates the slug using the first font family name.

Testing Instructions

Follow test instructions from: #46376
And see that the font is no longer repeated

Fixes: #46376

@matiasbenedetto matiasbenedetto mentioned this pull request Dec 7, 2022
5 of 10 tasks

@jffng jffng left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this with Vivre and the fix works as described:

Before After
Screenshot 2022-12-08 at 4 58 40 PM Screenshot 2022-12-08 at 4 59 40 PM

@matiasbenedetto
matiasbenedetto merged commit 3cb3881 into trunk Dec 9, 2022
@matiasbenedetto
matiasbenedetto deleted the fix/wp-webfonts_get-font-slug branch December 9, 2022 02:03
@github-actions github-actions Bot added this to the Gutenberg 14.8 milestone Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicated font families in global settings

2 participants