-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Font Library: fix duplicate variants with different file types #54490
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/experimental/fonts/font-library/class-wp-font-family.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/install.php |
Flaky tests detected in b953b2f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6226554866
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working as expected for me. Fonts are limited to a single format. When adding a new it seems to always replace the existing, whatever format it is.
When uploading multiple at the same time the format chosen seems to be... alphabetical?
Either way, I can confirm that it fixes the issue at hand.
The tests I made manually are working great. |
phpunit/tests/fonts/font-library/wpRestFontLibraryController/installFonts.php
Outdated
Show resolved
Hide resolved
…ore than one font face.
@matiasbenedetto I moved these tests to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - I tested with with Cardo font.
- Regular
- Italic
- Bold
Used ttf, woff, woff2 file types for each.
This created 3 variants within Cardo, tried uploading 9 files total.
What?
This PR adds checks to ensure that multiple file types of the same font variant are not added, so that only one variation per font style and weight is stored.
Why?
Fixes #54253
How?
For fonts where the font family does not yet exist, checks the list of new font faces and compares their font weight and style, and if there is already an existing font face, skips adding the incoming one.
For font faces where the font family exists, adds a new function
get_intersecting_font_faces
which returns an array of font faces to be deleted and replaced by the incoming font face.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast