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

[Webfonts] Rename to Fonts API #46749

Merged
merged 14 commits into from
Jan 18, 2023
Merged

[Webfonts] Rename to Fonts API #46749

merged 14 commits into from
Jan 18, 2023

Conversation

hellofromtonya
Copy link
Contributor

@hellofromtonya hellofromtonya commented Dec 22, 2022

Closes #42868.

What?

Renames the API from Webfonts to Fonts API.

Why?

The renaming is to align the feature to well-known authoritative standards for consistency and maintainability. Why? These standards do not use "webfont" to describe @font-face CSS styles. Rather, they use terms such as "font", "custom font", "downloadable font", and "web font".

How?

  1. All publicly facing functionality is deprecated as part of the temporary BC layer. Notices will be thrown to alert developers where to upgrade their code to the new API.
  2. "web" is removed from all inline comments, docblocks, and code names (except for the original which are now deprecated).

Testing Instructions

Testing Instructions for Keyboard

Testing Instructions

  1. Active TT3
  2. Activate the Gutenberg plugin
  3. Reset the global styles to the default by:
    • Go to the Site Editor > Global Styles "Styles Beta" UI
    • Click on the 3 vertical dots
    • Select "Reset to defaults"
    • Click on the "Save" button
  4. Examine the dynamically generated @font-face stylings in the admin area by:
    • Open Dev Tools in your favorite browser
    • Search for wp-fonts-local (which is in the <head>)
    • Expand the <style> element to inspect the CSS
    • The CSS should be:
<style id="wp-fonts-local">
@font-face{font-family:"Source Serif Pro";font-style:normal;font-weight:200 900;font-display:fallback;src:local("Source Serif Pro"), url('/wp-content/themes/twentytwentytwo/assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"Source Serif Pro";font-style:italic;font-weight:200 900;font-display:fallback;src:local("Source Serif Pro"), url('/wp-content/themes/twentytwentytwo/assets/fonts/source-serif-pro/SourceSerif4Variable-Italic.ttf.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"DM Sans";font-style:normal;font-weight:400;font-display:fallback;src:local("DM Sans"), url('/wp-content/themes/twentytwentytwo/assets/fonts/dm-sans/DMSans-Regular.ttf') format('truetype');}
@font-face{font-family:"DM Sans";font-style:italic;font-weight:400;font-display:fallback;src:local("DM Sans"), url('/wp-content/themes/twentytwentytwo/assets/fonts/dm-sans/DMSans-Italic.ttf') format('truetype');}
@font-face{font-family:"DM Sans";font-style:normal;font-weight:700;font-display:fallback;src:local("DM Sans"), url('/wp-content/themes/twentytwentytwo/assets/fonts/dm-sans/DMSans-Bold.ttf') format('truetype');}
@font-face{font-family:"DM Sans";font-style:italic;font-weight:700;font-display:fallback;src:local("DM Sans"), url('/wp-content/themes/twentytwentytwo/assets/fonts/dm-sans/DMSans-BoldItalic.ttf') format('truetype');}
@font-face{font-family:"IBM Plex Sans";font-style:normal;font-weight:400;font-display:fallback;src:local("IBM Plex Sans"), url('/wp-content/themes/twentytwentytwo/assets/fonts/ibm-plex/IBMPlexSans-Light.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"IBM Plex Sans";font-style:italic;font-weight:400;font-display:fallback;src:local("IBM Plex Sans"), url('/wp-content/themes/twentytwentytwo/assets/fonts/ibm-plex/IBMPlexSans-LightItalic.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"IBM Plex Sans";font-style:normal;font-weight:200;font-display:fallback;src:local("IBM Plex Sans"), url('/wp-content/themes/twentytwentytwo/assets/fonts/ibm-plex/IBMPlexSans-ExtraLight.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"IBM Plex Sans";font-style:italic;font-weight:200;font-display:fallback;src:local("IBM Plex Sans"), url('/wp-content/themes/twentytwentytwo/assets/fonts/ibm-plex/IBMPlexSans-ExtraLightItalic.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"IBM Plex Mono";font-style:normal;font-weight:400;font-display:fallback;src:local("IBM Plex Mono"), url('/wp-content/themes/twentytwentytwo/assets/fonts/ibm-plex/IBMPlexMono-Text.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"IBM Plex Mono";font-style:italic;font-weight:400;font-display:fallback;src:local("IBM Plex Mono"), url('/wp-content/themes/twentytwentytwo/assets/fonts/ibm-plex/IBMPlexMono-TextItalic.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"IBM Plex Mono";font-style:normal;font-weight:700;font-display:fallback;src:local("IBM Plex Mono"), url('/wp-content/themes/twentytwentytwo/assets/fonts/ibm-plex/IBMPlexMono-Bold.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"IBM Plex Mono";font-style:italic;font-weight:700;font-display:fallback;src:local("IBM Plex Mono"), url('/wp-content/themes/twentytwentytwo/assets/fonts/ibm-plex/IBMPlexSans-BoldItalic.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:Inter;font-style:normal;font-weight:200 900;font-display:fallback;src:local(Inter), url('/wp-content/themes/twentytwentytwo/assets/fonts/inter/Inter.ttf') format('truetype');font-stretch:normal;}
</style>
  1. Examine the front-end by:
    • Go to the front-end of the website
    • Open Dev Tools in your favorite browser
    • Search for wp-fonts-local
    • Expand the <style> element to inspect the CSS
    • The CSS should be the same as above.
  2. Change to the Blue style variation and modify the "text" typography by:
    • Go back to the Global Styles UI in the admin
    • Select "Browser styles"
    • Select the "blue" variation
    • Select "Browse styles" to go back
    • Select "Typography"
    • Select "Text"
    • Change the size to "4"
    • Change the "Appearance" to "Semi Bold Italic"
    • Inspect the CSS as you did in Step 3. It should be the same.
  3. Examine the front-end by:
    • Refresh (may have to refresh multiple times until the blue styling renders)
    • Search for wp-fonts-local
    • Expand the <style> element to inspect the CSS and verify the CSS.

Testing a plugin

This gist is a plugin that uses Jetpack's Google Font Provider package, which is using the original (deprecated) API functionality and web fonts array structure. So it should continue to work and throw deprecation notices.

Instructions of how to install and test are in the plugin's README.md file, which you can get here.

Note: This plugin has a Google Fonts Provider which means it will print <style id="wp-fonts-jetpack-google-fonts">..</style> into the <head>.

Copy link
Contributor

@ironprogrammer ironprogrammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, @hellofromtonya! I've left a few notes for review.

lib/experimental/class-wp-webfonts-provider-local.php Outdated Show resolved Hide resolved
lib/experimental/class-wp-webfonts-provider.php Outdated Show resolved Hide resolved
lib/experimental/class-wp-webfonts-provider.php Outdated Show resolved Hide resolved
lib/experimental/class-wp-webfonts.php Outdated Show resolved Hide resolved
@hellofromtonya
Copy link
Contributor Author

Well darn it all, lots has changed since I created this PR. Merge conflicts are being unruly. Going to rebase and reapply the commits. Then force push to get it back in sync. Then will apply the changes @ironprogrammer suggested (thank you Brian).

* Moves the files into a fonts-api directory to better identify all of the API's files.
* Moves the deprecated files (BC layer) into a /deprecations/ dir to better identify files that will not be backported to Core.
@hellofromtonya hellofromtonya force-pushed the try/rename-to-fonts-api branch 2 times, most recently from 805b8fa to 145548e Compare January 17, 2023 22:13
@WordPress WordPress deleted a comment from github-actions bot Jan 17, 2023
@hellofromtonya
Copy link
Contributor Author

  • Merge conflicts taken care of ✅
  • Feedback from @ironprogrammer addressed ✅
  • Tested it locally: works in the Site Editor and frontend ✅

@ironprogrammer @aristath It's ready for your review and testing. If possibly, would like to merge this PR this week to unblock the rest of the API's work. Thanks!

@github-actions
Copy link

Flaky tests detected in 79cc093432d018bb738888d9dcf6f13dbcd37cea.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3943813274
📝 Reported issues:

Copy link
Member

@aristath aristath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work here! Looks good to me and works as advertised 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Priority] High Used to indicate top priority items that need quick attention [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webfonts: Consider renaming "webfont" to "web font" or "font"
5 participants