fix(wp): match local font file names to the sanitized upload name - #26
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24
The bug
Local fonts whose family name has a space (for example Source Sans 3) never load on the front end. WordPress stores the upload under a sanitized name, where spaces become dashes, but the
@font-facesrcwas built from the raw family and kept the spaces. It pointed at a file that 404s, and the browser dropped the font silently. Reported by a customer on 2.0.1.The fix
The upload file name and the CSS
srcnow come from one helper,localFontFileName, which sanitizes the name the waysanitize_file_name()does, so the URL always matches the file on disk. Font deletion uses it too. The helper lives in core with unit coverage. The www app is unaffected: it references the real file URLs, not a constructed path. Existing broken fonts need one re-save to regenerate their CSS.Verification
Notes
The importer also downloads the same variable font once per weight (byte identical). Left as a follow-up.