Make WordPress Core

Opened 5 years ago

Closed 14 months ago

Last modified 14 months ago

#53744 closed defect (bug) (reported-upstream)

Cannot set editor font-family via theme.json

Reported by: twentyzerotwo's profile TwentyZeroTwo Owned by:
Milestone: 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 (4)

#1 @ocean90
5 years 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
5 years ago

@ocean90 makes sense.

I think myself and a lot of other devs who use WordPress in an agency setting (themes for single 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/.

Last edited 5 years ago by TwentyZeroTwo (previous) (diff)

#3 @karmatosed
14 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Hi, thank you for the discussion here but I wanted to note that any issues be they bugs or enhancements are now done over on the github repo for the core editor. You also can now set font-family via theme.json, so perhaps this issue is both no longer valid. If that isn't the case please report here: https://github.com/WordPress/gutenberg/issues/new/choose

#4 @karmatosed
14 months ago

  • Resolution changed from worksforme to reported-upstream
Note: See TracTickets for help on using tickets.