Skip to content

Proposal for a Webfonts collection schema #4

@aristath

Description

@aristath

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions