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

[Fonts API] Do not expose registered fonts in block settings (only expose enqueued fonts) #40362

Closed
zaguiini opened this issue Apr 14, 2022 · 4 comments
Assignees
Labels
[Type] Enhancement A suggestion for improvement.

Comments

@zaguiini
Copy link
Member

zaguiini commented Apr 14, 2022

What problem does this address?

Right now, the Fonts API is exposing registered fonts in the typography picker. That is fine for Site Editor's (Global Styles > Typography UI), but block settings should not see them.

There are 3 places where font families are relevant:

  • global styles font presets (this doesn’t have a UI in core yet);
  • global elements & block types;
  • block instances.

The first two (which represent the global styles UI) should be able to read and select from all registered fonts. Block instances (i.e. selecting a paragraph block in a post), on the other hand, should only get access to fonts enabled through the previous two UIs (presets, elements, and block type enabled font families).

@zaguiini zaguiini added [Priority] High Used to indicate top priority items that need quick attention [Feature] Webfonts labels Apr 14, 2022
@zaguiini zaguiini changed the title Webfonts: do not expose programmatically registered webfonts in block settings Webfonts: do not expose all programmatically registered webfonts in block settings Apr 14, 2022
@hellofromtonya hellofromtonya removed the [Priority] High Used to indicate top priority items that need quick attention label Jun 23, 2022
@hellofromtonya hellofromtonya changed the title Webfonts: do not expose all programmatically registered webfonts in block settings [Fonts API] do not expose all programmatically registered webfonts in block settings Apr 6, 2023
@hellofromtonya hellofromtonya changed the title [Fonts API] do not expose all programmatically registered webfonts in block settings [Fonts API] Do not expose registered fonts in block settings (only expose enqueued fonts) Apr 6, 2023
@hellofromtonya hellofromtonya self-assigned this Apr 6, 2023
@hellofromtonya
Copy link
Contributor

hellofromtonya commented May 25, 2023

Right now, the Fonts API is exposing registered fonts in the typography picker. That is fine for Site Editor's (Global Styles > Typography UI), but block settings should not see them.

There are 3 places where font families are relevant:

  • global styles font presets (this doesn’t have a UI in core yet);
  • global elements & block types;
  • block instances.
    The first two (which represent the global styles UI) should be able to read and select from all registered fonts. Block instances (i.e. selecting a paragraph block in a post), on the other hand, should only get access to fonts enabled through the previous two UIs (presets, elements, and block type enabled font families).

Double checking before work begins.

@mtias In the Site Editor, should a user be able to select a registered font-family in any of the Font pickers?

I had thought users could only select at the whole site "custom styles" level:
Screen Shot 2023-05-25 at 3 57 05 PM

But at the template level in the Site Editor, there's also a Styles icon for each block. For example, users are currently able to select any "registered" font-family at the block level for a specific template. Should they be about to do this?

single-post-title-font-family

@mtias
Copy link
Member

mtias commented May 26, 2023

@zaguiini is generally correct. Users should be able to select from registered fonts in the context of theme.json, and should be selecting from theme.json reduced fonts in the context of block instances.

The Global elements and block types is slightly more blurry in terms of mechanics. For example, it should be clear what fonts are already in use, but you should still be able to add new ones, which should modify the theme.json set of fonts. This might be a case of discovery more than allowing all registered fonts to show. I'm fine iterating on that middle layer provided everything else works as expected.

@hellofromtonya
Copy link
Contributor

Okay thank you @mtias. That answers my questions in terms of what a user can select in the Site Editor itself.

What about in say a post, i.e. not in the Site Editor? Let me explain my question and thinking.

Enqueued fonts = all theme defined fonts (defined in a theme's theme.json file) plus all user-selected fonts (including plugin registered fonts that a user selected) plus any fonts a plugin directly enqueues (regardless if a user selected them or not in the Site Editor)

When editing/creating a post, should each block's Font picker be a list of all those enqueued fonts? Or should the list be the theme defined fonts + any user selected font for the respective block (meaning each block potentially has a different list)?

If all the enqueued fonts populate all Font pickers in all blocks, then a user has the ability to override the global font selected for a block in the Site Editor.

@mtias what do you envision for font selection in a post editor for each block?

@hellofromtonya
Copy link
Contributor

hellofromtonya commented Jun 20, 2023

Update:

This issue is no longer valid for the Fonts API once the Font Library is merged.

Why?

The decision of what fonts to show in the font pickers will reside in theme.json. The Fonts API will no longer add / inject fonts into theme.json, but rather will become read-only of the theme.json merged data.

Issue #51151 supersedes this issue for what to display in the font pickers. Thus, I'm closing this issue and its associated PR.

@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants