Commit fd97019529 for wordpress.org
commit fd9701952935a51bcf85c41c3e6d9864f9426a41
Author: SergeyBiryukov <sergeybiryukov@git.wordpress.org>
Date: Thu Sep 17 08:45:49 2026 +0000
Fonts: Quote axis tags when compiling a `font-variation-settings` array.
`WP_Font_Face::generate_font_face_css()` accepts `font-variation-settings` as an array and converts it with `::compile_variations()`. That method concatenated each axis as `"$key $value"` with no separator and no quotes around the axis tag, so the output was not valid CSS.
Before:
{{{
font-variation-settings:wght 400GRAD 0;
}}}
After:
{{{
font-variation-settings:"wght" 400, "GRAD" 0;
}}}
The `font-variation-settings` descriptor takes a comma-separated list of `<string> <number>` pairs, where the axis tag is a quoted four-character string. Without the quotes and commas the browser drops the declaration.
The string form, which `theme.json` documents, is passed through unchanged and is not affected.
Reference: [https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/font-variation-settings MDN: font-variation-settings CSS property].
Developed in https://github.com/WordPress/wordpress-develop/pull/13514.
Follow-up to r56500.
Props kimjiwoon, ugyensupport.
Fixes #66103.
Built from https://develop.svn.wordpress.org/trunk@63653
git-svn-id: http://core.svn.wordpress.org/trunk@62827 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/fonts/class-wp-font-face.php b/wp-includes/fonts/class-wp-font-face.php
index 193a5d0951..c8d081b955 100644
--- a/wp-includes/fonts/class-wp-font-face.php
+++ b/wp-includes/fonts/class-wp-font-face.php
@@ -363,17 +363,18 @@ class WP_Font_Face {
* Compiles the font variation settings.
*
* @since 6.4.0
+ * @since 7.2.0 Quotes each axis tag and separates the axes with commas.
*
- * @param array $font_variation_settings Array of font variation settings.
+ * @param array $font_variation_settings Array of font variation settings, keyed by axis tag.
* @return string The CSS.
*/
private function compile_variations( array $font_variation_settings ) {
- $variations = '';
+ $variations = array();
- foreach ( $font_variation_settings as $key => $value ) {
- $variations .= "$key $value";
+ foreach ( $font_variation_settings as $tag => $value ) {
+ $variations[] = sprintf( '"%s" %s', $tag, $value );
}
- return $variations;
+ return implode( ', ', $variations );
}
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index cf80b07c9e..1de6a4e3c0 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-63652';
+$wp_version = '7.2-alpha-63653';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.