Skip to content

Commit

Permalink
Skip redundant registration for Fonts API-registered fonts (#48341)
Browse files Browse the repository at this point in the history
* Update font origin to match updated API

When fonts are converted to theme.json format, origin is set to `gutenberg_wp_fonts_api`.

* Update font origin set in deprecated WP_Web_Fonts class

---------

Co-authored-by: Tonya Mork <tonya.mork@automattic.com>
  • Loading branch information
ironprogrammer and hellofromtonya committed Feb 23, 2023
1 parent 6acbb4b commit 1a93475
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ public function to_theme_json( $font_family_handle ) {
}

$variation_obj = $this->registered[ $variation_handle ];
$variation_properties = array( 'origin' => 'gutenberg_wp_webfonts_api' );
$variation_properties = array( 'origin' => 'gutenberg_wp_fonts_api' );
foreach ( $variation_obj->extra['font-properties'] as $property_name => $property_value ) {
$property_in_camelcase = lcfirst( str_replace( '-', '', ucwords( $property_name, '-' ) ) );
$variation_properties[ $property_in_camelcase ] = $property_value;
Expand Down
4 changes: 2 additions & 2 deletions lib/experimental/fonts-api/register-fonts-from-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function gutenberg_register_fonts_from_theme_json() {
$font_family['fontFace'] = (array) $font_family['fontFace'];

foreach ( $font_family['fontFace'] as $font_face ) {
// Skip if the webfont was registered through the Webfonts API.
if ( isset( $font_face['origin'] ) && 'gutenberg_wp_webfonts_api' === $font_face['origin'] ) {
// Skip if the font was registered through the Fonts API.
if ( isset( $font_face['origin'] ) && 'gutenberg_wp_fonts_api' === $font_face['origin'] ) {
continue;
}

Expand Down

1 comment on commit 1a93475

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 1a93475.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4254543048
📝 Reported issues:

Please sign in to comment.