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.
WP_Font_Face: https://github.com/WordPress/wordpress-develop/blob/c05f7a66b0b9f89b5b140dac234602dcf325a17d/src/wp-includes/fonts/class-wp-font-face.php#L46WP_Font_Collection: https://github.com/WordPress/wordpress-develop/blob/c05f7a66b0b9f89b5b140dac234602dcf325a17d/src/wp-includes/fonts/class-wp-font-collection.php#L275- Font faces REST endpoint: https://github.com/WordPress/wordpress-develop/blob/c05f7a66b0b9f89b5b140dac234602dcf325a17d/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php#L624
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
- Activate a block theme and replace its
theme.jsonwith 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"
]
}
]
}
]
}
}
}
- View the source of the front end and find the
@font-facerule in thewp-fonts-localstyle 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
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
WP_Theme_JSON::FONT_FAMILY_SCHEMAdoesn't includefontVariant, so the property is removed when theme.json data is sanitized andfont-variantis never printed in the@font-facerule. The theme.json JSON schema,WP_Font_Face,WP_Font_Collection, and the font faces REST endpoint already accept it.This PR adds
fontVariantto the schema. No other change is needed, becauseWP_Font_Face_Resolverconverts the property tofont-variantandWP_Font_Facealready 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