WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.32k stars 4.12k forks source link

Allow customize fontWeight (and fontStyle) #39685

Open Chrico opened 2 years ago

Chrico commented 2 years ago

What problem does this address?

Currently it is only possible to configure via theme.json following:

{
    "version": 2,
    "settings": {
        "typography": {
            "fontWeight": false
        }
    }
}

But it is not possible to define the allowed fontWeights.

If this is not set, all (from 100 - 900) are available as defined here: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/font-appearance-control/index.js#L19 and combined here: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/font-appearance-control/index.js#L105 .

This makes it hard to use custom fonts, since not every font wants/needs to support every fontWeight.

What is your proposed solution?

Why is it not possible to configure something like:

{
  "version": 2,
  "settings": {
    "typography": {
      "fontWeight": ["300", "400"]
    }
  }
}

via theme.json to have control (whitelist allowed once) over it?

carolinan commented 2 years ago

I believe the plan was for this to be built into the webfonts api, it just hasn't been completed yet.

Chrico commented 2 years ago

Is there any issue related to that @carolinan we can dig into?

github-actions[bot] commented 1 year ago

Hi, This issue has gone 180 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

Thelmachido commented 1 year ago

This issue hasn't had much activity in a while, if it stays stale for more than two weeks it will end up being closed. @carolinan is there still a plan to move this forward?

merijnponzo commented 1 year ago

The fontweight property within theme.json typography should definitely be an enum where you can specify fontweights, or a boolean true or false.

Since i only have 3 weights for a custom font, the typography doesn't work as it should in the editor since this whole list:

Thin: 100
Extra Light: 200
Light: 300
Regular: 400
Medium: 500
Semi Bold: 600
Bold: 700
Extra Bold: 800
Black: 900

is present.

I hope an enum will be supported soon

Chrico commented 1 year ago

@carolinan any updates on that issue? :)

dnl13 commented 1 year ago

a bit disappointing for a "plugin" called Gutenberg that does not flexibly handle the basic fonts.

Would love to know if there is an update on this, This has already taken me a day of research to figure out that this is all hardcoded.

Thanks for opening this topic

eirichmond commented 1 month ago

~Is this still an open issue? My recent testing suggests that this has been resolved :)~

Scrub that, I can see that this is still persistant in the "Site Editor"