Skip to content

Changing the slug for font-family in theme.json works except for the body #44242

@Humanify-nl

Description

@Humanify-nl

Description

I changed the slug value in theme.json settings.typography:

      "fontFamilies": [
        {
          "fontFamily": "\"Source Serif Pro\", serif",
          "name": "Source Serif Pro",
          "slug": "main",
          "fontFace": [
            {
              "fontFamily": "Source Serif Pro",
              "fontWeight": "200 900",
              "fontStyle": "normal",
              "fontStretch": "normal",
              "fontDisplay": "swap",
              "src": [
                "file:./assets/fonts/SourceSerif4Variable-Roman.ttf.woff2"
              ]
            }
          ]
        }
      ],

The new variable --wp-preset--font-family--main is succesfully output for blocks.

Except for the body.

See here:
image

I did a search, nowhere in my theme code is this variable --wp-preset--font-family--source-serif-pro declared, also not in theme.json. It seems to be auto-generated from the font-family name.

However, it works fine for headings and other blocks.

image

So i'd say this looks like a bug!

Step-by-step reproduction instructions

  1. See above example (basically TT2), change the slug in theme.json to 'main'.
  2. Make sure that theme.json has: styles.typography { "font-family" : "var(--wp-preset--font-family--main)"}.
  3. Open the front-end, inspect the body and look for its font-family declaration on body.

Screenshots, screen recording, code snippet

No response

Environment info

  • WP 6.0.2
  • No Gutenberg

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Theme Style VariationsRelated to style variations provided by block themes[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions