WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.06k stars 4.04k forks source link

Upload Fonts: Invalid parameter(s): font_family_settings #62701

Open at-benni opened 3 weeks ago

at-benni commented 3 weeks ago

Description

As I try to upload fonts in woff2 format, I get the error message. Invalid parameter(s): font_family_settings

I found out the reason why this is happening is because the font name is missing in the metadata of the font. https://fontdrop.info/

As per w3.org specification the name in the metadata is optional, so this is a valid bug of Gutenberg: WOFF2:

The WOFF2 file MAY contain a block of extended metadata. The interpretation of this block is exactly the same as [WOFF 1]. https://www.w3.org/TR/WOFF2/#Metadata WOFF1:

Zero or more name elements may be used to provide a human-friendly name for the collection of extended metadata items in an extension element. A user agent that displays metadata SHOULD choose the name with most the appropriate language from among those available for each named extension element. This child element is OPTIONAL in extension elements; anonymous extension elements are also permissible. https://www.w3.org/TR/2012/REC-WOFF-20121213/#Metadata

Step-by-step reproduction instructions

  1. Upload a font without the font family meta data

Screenshots, screen recording, code snippet

Screenshots and bug reports at: https://core.trac.wordpress.org/ticket/61426

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

creativecoder commented 3 weeks ago

We need some kind of unique identifier for the font family before it can be created. So the best way forward seems like finding one or more fallbacks from the font metadata to use for the font family slug when the name isn't present, and then submitting that as the slug in the API request to create the font family.

creativecoder commented 3 weeks ago

Additionally we need better error handling! The UI should display the error that comes back from the API request, not persist the loading indicator.

at-benni commented 3 weeks ago

Maybe the first upload of the font should fail if there is no unique identifier and return a new submission form, this time with a "name" field.

The loading indicator is stuck when a font with no name is uploaded. The originally reported error is returned when the font name metadata contains invalid characters.