-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
What problem does this address?
When registering fonts from a plugin with wp_register_webfonts, we define a font-family that then becomes the "name" of the font in Style picker.
When registering fonts with themes with theme.json, fontFamilies supports passing the name attribute that then gets picked by the UI as font label in the dropdown.
Using fontFamily as label works fine for most cases just fine. When a plugin provinding external font-provider (Google Fonts in our case), there isn't flexibility in pickign a nice font family name because the font family has to match the one passed to Google Fonts API.
For example, language-specific fonts in Google fonts don't have pretty names:
- Alexandria
- IBM Plex Sans Arabic
- Noto Sans Hebrew
- Noto Sans HK
- Noto Sans JP
- Noto Sans KR
- Noto Sans SC
- Noto Sans TC
- Noto Sans Telugu
- Noto Serif Hebrew
- Noto Serif HK
- Noto Serif JP
- Noto Serif KR
- Noto Serif SC
- Noto Serif TC
Above list would be better served with human-readable labels. It would be great to be able to translate the parts inside brackets, too.
'Alexandria' => 'Alexandria (Arabic)',
'IBM Plex Sans Arabic' => 'IBM Plex Sans (Arabic)',
'Noto Sans Hebrew' => 'Noto Sans (Hebrew)',
'Noto Sans HK' => 'Noto Sans (Hong Kong)',
'Noto Sans JP' => 'Noto Sans (Japanese)',
'Noto Sans KR' => 'Noto Sans (Korean)',
'Noto Sans SC' => 'Noto Sans (Simplified Chinese)',
'Noto Sans TC' => 'Noto Sans (Traditional Chinese)',
'Noto Sans Telugu' => 'Noto Sans (Telugu)',
'Noto Serif Hebrew' => 'Noto Serif (Hebrew)',
'Noto Serif HK' => 'Noto Serif (Hong Kong)',
'Noto Serif JP' => 'Noto Serif (Japanese)',
'Noto Serif KR' => 'Noto Serif (Korean)',
'Noto Serif SC' => 'Noto Serif (Simplified Chinese)',
'Noto Serif TC' => 'Noto Serif (Traditional Chinese)',What is your proposed solution?
wp_register_webfonts should support name attribute that then gets added to Theme JSON object.
AlternativelyI looked altering theme json object with wp_theme_json_data_theme filter (as in example) but this felt rather messy for something as simple.
