Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow themes to opt-in to font-smoothing via theme.json #35934

Closed
kjellr opened this issue Oct 25, 2021 · 10 comments
Closed

Allow themes to opt-in to font-smoothing via theme.json #35934

kjellr opened this issue Oct 25, 2021 · 10 comments
Assignees
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@kjellr
Copy link
Contributor

kjellr commented Oct 25, 2021

One reset-adjacent feature that many themes opt-into is font smoothing. Sure, they could do this with a couple lines of CSS, but I wonder if this is common enough that we should just allow it to be a single line in theme.json instead.

-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;

The past three default themes (Twenty Nineteen, Twenty Twenty, and Twenty Twenty-One) all opted into this via CSS, and I'd like to do it for Twenty Twenty-Two as well.

@kjellr kjellr added [Type] Enhancement A suggestion for improvement. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Oct 25, 2021
@kjellr kjellr changed the title Allow themes to opt-into font-smoothing via theme.json Allow themes to opt-in to font-smoothing via theme.json Oct 25, 2021
@sagarnasit
Copy link

Hi @kjellr

I use theme.json for almost all the themes I am currently working on. This looks like an excellent feature to add.

Let me know if I can take on adding this feature in the Gutenberg.

@kjellr
Copy link
Contributor Author

kjellr commented Oct 27, 2021

Hey @sagarnasit — go for it! I think a PR would be worthwhile.

@sagarnasit
Copy link

sagarnasit commented Oct 27, 2021

Great! @kjellr

This feature would go in styles -> typography -> fontSmoothing in the theme.json file

{
	"version": 1,
	"style": {
		"typography": {
			"fontSmoothing": true,
			...
		}
	}
	...
}

I have a couple of questions in mind.

  1. Adding the above style should work fine. Does it require adding settings as well for font-smoothing?

  2. Does this feature require support for elements and block level styles too?

@kjellr
Copy link
Contributor Author

kjellr commented Oct 27, 2021

Adding the above style should work fine. Does it require adding settings as well for font-smoothing?

I do not think we need any UI/settings for this.

Does this feature require support for elements and block level styles too?

I think just a global toggle would make sense for now.

@scruffian
Copy link
Contributor

Looks like a good addition to me. I might even make it opt out...

@chthonic-ds
Copy link
Contributor

Can this be kept as opt in, please? Those two lines of CSS are not supported for many users. For those it does affect, there's also the potential for a11y issues when applied to smaller text and/or text with a light font weight.

@sagarnasit
Copy link

@chthonic-ds Yes, this feature would be opt-out by default.

@bgardner
Copy link

Just throwing my two cents in:

  1. I absolutely love the suggestion to add support for font-smoothing in theme.json. It’s something I use on practically every site I design.

  2. I agree that it should not be turned on by default, for the reasons @chthonic-ds has said (among a few others, I am presuming.)

Given the simplicity of this PR/issue, I hope it finds its way into Gutenberg 11.9, and consequently 5.9. Huge win, IMO if it does.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Oct 30, 2021
@kjellr
Copy link
Contributor Author

kjellr commented Nov 3, 2021

Closing as per the thoughts in #36092 (comment).

@kjellr kjellr closed this as completed Nov 3, 2021
@SamuelMiller
Copy link

As a said note, there are critics of anti-aliasing font smoothing (-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;) who say that it actually degrades the clarity of fonts on computer screens, particularly the typical dark text on a light background. It switches rendering from subpixel-rendering to pixel level rendering:
https://usabilitypost.com/2012/11/05/stop-fixing-font-smoothing/
google/fonts#1170

The Twenty Twenty Two's CSS has antialiasing enabled. Perhaps this is a mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants