How web fonts will be defined in a theme:
In a theme.json file:
{
"webfonts": {
"font-handle-1": {
"font-family": "Open Sans",
"font-weight": "400",
"font-style": "normal",
"provider": "google"
},
"font-handle-2": {
"font-family": "Open Sans",
"font-weight": "600",
"font-style": "italic",
"font-variant": "small-caps",
"provider": "google"
},
"font-handle-3": {
"font-family": "My Local Font",
"font-weight": "400",
"font-style": "normal",
"src": [ "fonts/MyLocalFont.woff2" ],
"provider": "local"
}
}
}
webfonts is an object. The key is the webfont's handle, and the value contains all the webfont's props (all valid CSS props for @font-face, plus a provider to define the type of webfont (local/google/other).
The same exact structure will be used when defining a webfont-collection from PHP instead of a theme.json file.
We may want to use fontFamily instead of font-family in theme.json... Everything else in a theme.json file uses camelCase and not kebab-case, so it would make sense to follow that same pattern. In PHP however, we may want to stick to camel-case 'cause that's what the eventual CSS will be
How web fonts will be defined in a theme:
In a
theme.jsonfile:{ "webfonts": { "font-handle-1": { "font-family": "Open Sans", "font-weight": "400", "font-style": "normal", "provider": "google" }, "font-handle-2": { "font-family": "Open Sans", "font-weight": "600", "font-style": "italic", "font-variant": "small-caps", "provider": "google" }, "font-handle-3": { "font-family": "My Local Font", "font-weight": "400", "font-style": "normal", "src": [ "fonts/MyLocalFont.woff2" ], "provider": "local" } } }webfontsis an object. The key is the webfont'shandle, and the value contains all the webfont's props (all valid CSS props for@font-face, plus aproviderto define the type of webfont (local/google/other).The same exact structure will be used when defining a webfont-collection from PHP instead of a
theme.jsonfile.We may want to use
fontFamilyinstead offont-familyintheme.json... Everything else in atheme.jsonfile uses camelCase and not kebab-case, so it would make sense to follow that same pattern. In PHP however, we may want to stick to camel-case 'cause that's what the eventual CSS will be