Skip to content

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

@matiasbenedetto

Description

@matiasbenedetto

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.

Metadata

Metadata

Assignees

Labels

[Feature] TypographyFont and typography-related issues and PRs[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions