Make WordPress Core

Opened 36 hours ago

Last modified 36 hours ago

#66629 new defect (bug)

Global Styles: fontVariant is removed from theme.json font face settings

Reported by: wildworks Owned by:
Priority: normal Milestone: 7.3
Component: Editor Version: 6.5
Severity: normal Keywords: gutenberg-merge has-patch has-unit-tests
Cc: Focuses:

Description

Gutenberg PR: ​https://github.com/WordPress/gutenberg/pull/86478

The theme.json JSON schema, WP_Font_Face, WP_Font_Collection, and the font faces REST endpoint all accept fontVariant for a font face.

However, WP_Theme_JSON::FONT_FAMILY_SCHEMA does not include it, so the property is removed when theme.json data is sanitized.

Steps to reproduce

  1. Activate a block theme and replace its theme.json with the following:
{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 3,
	"settings": {
		"typography": {
			"fontFamilies": [
				{
					"name": "Roboto",
					"slug": "roboto",
					"fontFamily": "Roboto, sans-serif",
					"fontFace": [
						{
							"fontFamily": "Roboto",
							"fontStyle": "normal",
							"fontWeight": "400",
							"fontVariant": "small-caps",
							"src": [
								"https://fonts.gstatic.com/s/roboto/v51/KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbWmWggvWl0Qn.woff2"
							]
						}
					]
				}
			]
		}
	}
}
  1. View the source of the front end and find the @font-face rule in the wp-fonts-local style tag.

Expected

font-variant is printed in the @font-face rule (formatted for readability):

@font-face {
	font-family: Roboto;
	font-style: normal;
	font-weight: 400;
	font-display: fallback;
	src: url('https://fonts.gstatic.com/s/roboto/v51/KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbWmWggvWl0Qn.woff2') format('woff2');
	font-variant: small-caps;
}

Actual

font-variant is missing from the @font-face rule (formatted for readability):

@font-face {
	font-family: Roboto;
	font-style: normal;
	font-weight: 400;
	font-display: fallback;
	src: url('https://fonts.gstatic.com/s/roboto/v51/KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbWmWggvWl0Qn.woff2') format('woff2');
}

Change History (1)

This ticket was mentioned in ​PR #15839 on ​WordPress/wordpress-develop by ​@wildworks.


36 hours ago
#1

  • Keywords has-patch has-unit-tests added

WP_Theme_JSON::FONT_FAMILY_SCHEMA doesn't include fontVariant, so the property is removed when theme.json data is sanitized and font-variant is never printed in the @font-face rule. The theme.json JSON schema, WP_Font_Face, WP_Font_Collection, and the font faces REST endpoint already accept it.

This PR adds fontVariant to the schema. No other change is needed, because WP_Font_Face_Resolver converts the property to font-variant and WP_Font_Face already allows it.

Backport of ​https://github.com/WordPress/gutenberg/pull/86478.

To test, follow the steps to reproduce in the ticket.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Porting the code change and test from the Gutenberg PR, running the tests, and drafting this PR description.

---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See ​GitHub Pull Requests for Code Review in the Core Handbook for more details.

🤖 Generated with ​Claude Code

Note: See TracTickets for help on using tickets.