Skip to content

Commit

Permalink
Uses each fontFaces font-family for enqueuing.
Browse files Browse the repository at this point in the history
The font-family in each `fontFaces` may be different than its parent.
For example, the parent may have a fallback defined such as
"fontFamily": "\"Source Serif Pro\", serif",`.
  • Loading branch information
hellofromtonya committed Apr 19, 2022
1 parent dc14844 commit bd4259e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/experimental/enqueue-webfonts-listed-in-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,17 @@ function _wp_enqueue_webfonts_listed_in_theme_json() {
continue;
}

wp_webfonts()->enqueue_webfont( $font_family, $font_face );
/*
* Skip if this font-face's font-family is not defined. Why?
* Its font-family may be different from its parent (i.e. `$font_family`).
* For example, the parent may define a fallback such as "serif",
* whereas this font-face may define only the font-family.
*/
if ( ! isset( $font_face['fontFamily'] ) ) {
continue;
}

wp_webfonts()->enqueue_webfont( $font_face['fontFamily'], $font_face );
}
}
}
Expand Down

0 comments on commit bd4259e

Please sign in to comment.