WordPress.org

Make WordPress Core

Opened 8 weeks ago

Last modified 8 weeks ago

#53744 new defect (bug)

Cannot set editor font-family via theme.json

Reported by: TwentyZeroTwo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords: close
Focuses: Cc:

Description

As indicated on https://make.wordpress.org/core/2021/06/25/introducing-theme-json-in-wordpress-5-8/, "The default font-family styles for the editor are not enqueued." when theme.json is present in a theme.

As far as I can see, there is no method to set the font-family of the editor without enqueuing a custom style sheet, which defeats the point of what I believe the new theme.json is pushing to achieve.

Similarly, theme.json can specify the below property:

settings.typography.fontFamilies

but it doesn't appear to do anything or be used anywhere in the editor.

Is this future functionality, or is the handling of editor/block font-families an oversight in 5.8?

Change History (2)

#1 @ocean90
8 weeks ago

  • Keywords close added

Hi @TwentyZeroTwo, WordPress 5.8 itself only supports a subset of possible theme.json features. But with the Gutenberg plugin you'll get a few more features, including support for font-family. On the handbook page for settings and styles you can view what is supported by WordPress and what requires Gutenberg.

Here's a quick example of a theme.json (based on tt1-blocks) which would set a default font-family and one specific to paragraphs - for the editor and the frontend. But as mentioned above, this requires Gutenberg to be active.

{
  "version": 1,
  "settings": {
    "typography": {
      "fontFamilies": [
        {
          "fontFamily": "-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif",
          "slug": "system-font",
          "name": "System Font"
        },
        {
          "fontFamily": "Cambria, Georgia, serif",
          "slug": "cambria-georgia"
        }
      ]
    }
  },
  "styles": {
    "typography": {
      "fontFamily": "var(--wp--preset--font-family--system-font)"
    },
    "blocks": {
      "core/paragraph": {
        "typography": {
          "fontFamily": "var(--wp--preset--font-family--cambria-georgia)"
        }
      }
    }
  }
}

So right now I'd say that what you want to have is planned for a future release.

#2 @TwentyZeroTwo
8 weeks ago

@ocean90 makes sense.

I think myself and a lot of other devs who use WordPress in an agency setting (themes specific use-cases/clients and not for market place) will likely hold off adopting theme.json use. Saying that, I will install the gutenberg plugin and try more of these features out as overall theme.json is a brilliant new feature.

Out of interest, why was the decision made to disable the default editor font in WordPress when theme.json is active? If core doesn't support setting fontFamily yet without the plugin, then it seems a little odd to dequeue the editor font-family with no way to define the new family.

I would also argue this is a docs enhancement as users reading https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/ are not informed that the default family is dequeued, as that information is only available on https://make.wordpress.org/core/2021/06/25/introducing-theme-json-in-wordpress-5-8/.

Version 0, edited 8 weeks ago by TwentyZeroTwo (next)
Note: See TracTickets for help on using tickets.