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

Font Face: redesign the Fonts API to become only a font-face styles generator and printer #51769

Closed
hellofromtonya opened this issue Jun 21, 2023 · 1 comment · Fixed by #51770
Assignees
Labels
[Feature] Typography Font and typography-related issues and PRs

Comments

@hellofromtonya
Copy link
Contributor

Part of #41479.

Introduction

The Fonts API needs to evolve to support is single role in typography management:

  • Generate and print the @font-face styles for all theme defined and user activated fonts.

As shared on 19 June 2023 in the Ongoing Roadmap #41479 (comment), the role of the Fonts API has changed to support the font management and Fonts Library. What was an "API" for managing fonts, now becomes a Font Face generator and printer for @font-face styles.

Changes

With new font management system, the Fonts API (or whatever its new name becomes) becomes "read-only" of the Theme JSON fonts definitions and then prints the @font-face styles for only those fonts.

Change: Register, deregister, and enqueue functionality are no longer needed.

Registering and enqueuing no longer applies. Instead, theme.json fonts are passed in for processing.

Plugins will no longer interact with the Fonts API / Font Face. Instead, they will integrate directly into the Fonts Library (once that capability exists).

Change: Add missing fonts into Theme JSON is no longer needed.

The Fonts API / Font Face will become read-only. It will no longer injects fonts into theme.json.

Changes:

  • WP_Fonts_Resolver::add_missing_fonts_to_theme_json() is no longer needed and can be removed.
  • The code that invokes it in WP_Theme_JSON_Resolver_Gutenberg::get_theme_data() can also be removed.

// BEGIN OF EXPERIMENTAL CODE. Not to backport to core.
static::$theme = WP_Fonts_Resolver::add_missing_fonts_to_theme_json( static::$theme );
// END OF EXPERIMENTAL CODE.

Change: Automatic enqueueing of user selected fonts from Site Editor is no longer needed.

Before the Font Library, the Fonts API automatically identified and enqueued fonts selected by users in the Site Editor (currently doing in WP_Fonts_Resolver::enqueue_user_fonts()). This is no longer needed.

Change: Support for custom providers is no longer needed.

In this first iteration, only local font files will be supported.

Providers were originally conceptualized to support local fonts (built-in) and Google fonts (custom). With the Fonts Library, Google Fonts will now be built-in and will installed locally in wp-content/fonts/ folder.

What about other remote font services?

Is there enough of a use-case to add custom provider functionality to support other remote font services? If yes, then the Fonts Library will need to add support for custom remote font services. Then the Fonts API / Font Face can also add support for custom providers.

Rename to Font Face

This new design is no longer a true "API". Rather, it's a font face generator and printer. With this redesign, it's time to rename it.

This proposal suggests Font Face, to represent that it's job is @font-face.

@hellofromtonya
Copy link
Contributor Author

Sites are currently using the Fonts API. To avoid sites breaking, the new redesign version of it is dependent upon the Fonts Library being merged and available. Thus, the new design will need to be conditionally loaded into memory only if the Fonts Library exists; else load the original Fonts API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Typography Font and typography-related issues and PRs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant