Directory

Font Library: Same font faces with different file extensions are added as a separated variant. · Issue #54253 · WordPress/gutenberg · GitHub
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

Font Library: Same font faces with different file extensions are added as a separated variant. #54253

Closed
matiasbenedetto opened this issue Sep 7, 2023 · 0 comments · Fixed by #54490
Assignees
Labels
[Feature] Typography Font and typography-related issues and PRs [Type] Bug An existing feature does not function as intended

Comments

@matiasbenedetto
Copy link
Contributor

What ?

Font with the same name but different type as existing custom font (e.g. guillon_normal_400.ttf and guillon_normal_400.woff2) is added as a separate variant.

Originally reported by @ironprogrammer in #53884 (comment)

Expected:

  • There should not be 2 variants if you are uploading the same family weight and style.
  • The old file should be removed or overwritten.

Current behavior

Currently, we compare the incoming variant with the existing one in the backend. We use a string-based approach around the entire font face data, so if something of the font face data is different (the file name in this case), it will be treated as a new variant.

$font_faces_1 = isset( $font1['fontFace'] ) ? $font1['fontFace'] : array();
$font_faces_2 = isset( $font2['fontFace'] ) ? $font2['fontFace'] : array();
$merged_font_faces = array_merge( $font_faces_1, $font_faces_2 );
$serialized_faces = array_map( 'serialize', $merged_font_faces );
$unique_serialized_faces = array_unique( $serialized_faces );
$unique_faces = array_map( 'unserialize', $unique_serialized_faces );
$merged_font = array_merge( $font1, $font2 );

What needs to be changed

  • Consider the variants by their font style and weight to know if they are repeated.
  • If we update the file asset, the old should be removed or overwritten.
@matiasbenedetto matiasbenedetto added [Type] Bug An existing feature does not function as intended [Feature] Typography Font and typography-related issues and PRs labels Sep 7, 2023
@matiasbenedetto matiasbenedetto changed the title Font Library: Font with same name but different type as existing custom font is added as a separate variant. Font Library: Font with same filename but different type as existing custom font is added as a separate variant. Sep 7, 2023
@matiasbenedetto matiasbenedetto changed the title Font Library: Font with same filename but different type as existing custom font is added as a separate variant. Font Library: Same font faces with different file extensions are added as a separated variant. Sep 7, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Sep 8, 2023
@jffng jffng linked a pull request Sep 8, 2023 that will close this issue
@jffng jffng removed a link to a pull request Sep 15, 2023
@mikachan mikachan removed the [Status] In Progress Tracking issues with work in progress label Sep 29, 2023
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 [Type] Bug An existing feature does not function as intended
Projects
Status: Done
3 participants