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] Allow enqueueing of font face with a chosen weight within range #40367

Closed
zaguiini opened this issue Apr 14, 2022 · 1 comment
Closed
Projects

Comments

@zaguiini
Copy link
Contributor

zaguiini commented Apr 14, 2022

What problem does this address?

Since weights can be a range, it would make sense for any weight within the range of the registered font face to be enqueued.

For example:

wp_register_webfont(
	array(
		'font-family'  => 'Source Serif Pro',
		'font-style'   => 'normal',
		'font-stretch' => 'normal',
		'font-weight'  => '200 900',
		'src'          => get_theme_file_uri( '/assets/fonts/SourceSerif4Variable-Roman.ttf.woff2' ),
	)
);

Font weight range from 200 to 900 gets registered. But right now, if you try passing a font weight within this range, you get an error:

The "Source Serif Pro:400:normal" font face is not registered.

What is your proposed solution?

Passing a font weight within the range (200 to 900) should enqueue that registered face.

In theme.json:

"fontFamilies": [
	{
		"fontFamily": "Source Serif Pro",
		"name": "Source Serif Pro",
		"slug": "source-serif-pro",
		"fontFaces": [
			{
				"fontFamily": "Source Serif Pro",
				"fontWeight": "400",
				"fontStyle": "normal"
			}
		]
	}
]
@zaguiini zaguiini changed the title Webfonts: register range of font weights as individual font faces Apr 14, 2022
@hellofromtonya hellofromtonya added this to To do in Fonts API via automation Jun 1, 2022
@hellofromtonya hellofromtonya changed the title Webfonts: allow enqueueing of font face with a chosen weight within range Jun 20, 2023
@hellofromtonya
Copy link
Contributor

Update:

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

Why?

As shared in Ongoing Roadmap update #41479 (comment), the Fonts API will no publicly expose the means to "register" or "enqueue" fonts. The Font Library and font management will handle the user workflow.

The Fonts API will get / pull the font variations from Theme JSON merged data that need their @font-face generated and printed.

Thank you everyone for your contributions!

Fonts API automation moved this from Backlog to Done Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants