Featured Web Fonts API doesn’t come on WordPress 5.9, possibly landing in Gutenberg first – WP Tavern

After what appeared to be a shoo-in for WordPress 5.9, a Web Fonts API proposal was put on hold. The feature would standardize the way theme and plugin developers load fonts and lay the foundation for future features for users.

Jono Alderson opened a ticket for the feature film in February 2019. In recent months, the proposition has gained momentum. The pull request had over 200 built-in messages, 93 commits, and code approval from two master commiters. The API seemed ready. However, he has stopped in recent days.

Andrew Ozz, one of the main WordPress developers, has essentially stopped the possibility of the new API landing in version 5.9. He said he didn’t think the proposal was ready for WordPress.

“Purely as code, it looks good,” he wrote in the post. “It’s really well documented (thank you [Tonya Mark]!). However, I still don’t see how this would improve WordPress in the short and long term. We were chatting with [Andrei Draganescu] and he suggested that ideally it should have been a feature plugin, and I agree. Then it would have been possible to really test it in production, verify (or reject) the assumptions that were made when creating it, and make it a truly worthy addition to WordPress. Unfortunately, it is too late for that now for 5.9.

One of the issues with testing API functionality plugins is that they often don’t get adopted, as others noted in the post. Developers would not rely on them in production in most cases. And, the average end user wouldn’t install something specific to developers.

“Suggesting that this be done as a feature plugin is an elegant way to delay something for a few years,” said Ari Stathopoulos, one of the API developers. However, he pointed out that the REST API was an exception that worked well enough to be ported into WordPress.

The basic WordPress proposition will likely be pushed into the Gutenberg plugin for further exploration. It would be kind of a tradeoff between launching as a separate feature plugin and moving into WordPress 5.9.

The Web Fonts API is not directly related to the block system. Traditional themes and blocks, as well as plugins, could use this feature today. However, several of Gutenberg’s proposals rely on the existence of the API, such as allowing theme authors to define web fonts through their theme.json files.

Ozz listed several questions around the proposal, and several developers answered each. However, its main argument was on the practicality of why everything in the API was necessary, claiming that the previous answers had been “in principle” and appeared to be based on assumptions.

At the most basic level, the Web Fonts API would allow developers to save and load locally hosted fonts or those from Google Fonts. Developers can also add custom providers outside of the two defaults. The first iteration of the proposed API was more about establishing a foundation to build on in future versions of WordPress.

The appeal of functionality isn’t just loading fonts. Technically, theme authors could do this with a single line of code if they wanted to. Four lines of code if they wanted to follow current core WordPress standards, at least on the front-end.

Stathopoulos put together a list of improvements such an API would bring to WordPress and its plugins.

  • Themes could define fonts via their theme.json files.
  • Font previews in the editor’s font family picker.
  • Display of valid font weights and styles for a font family.
  • Improved frontal performance.
  • Server side localization for better performance and privacy.

This was a small sample of the arguments for including the API in the core of WordPress.

“There are a lot of improvements in Gutenberg that are in limbo, awaiting a web fonts API,” Stathopolous wrote in the post. “Not having a Web Fonts API is a blocker at this point. It’s not a good item to have on our wishlist, it’s a requirement moving forward.

Currently, there are no standards specifically for web fonts in WordPress. Theme authors are grafted onto existing functions to queue a third-party or custom stylesheet with @font-face rules. This has generally been an accepted practice in the theme authoring community over the years.

However, many reluctantly accepted it. Several have created custom scripts to alleviate the problems. Many others just copy the method used by the latest default WordPress theme.

One of the goals is to make sure that developers don’t have to worry about doing all the extra work related to loading web fonts. There really shouldn’t be a need for a theme to figure out how to load them both in the editor and the front-end, handle preloading, or account for localization. As themes age and third-party APIs like Google Fonts change, there would be no need to update themes if WordPress takes care of it under the hood.

The problem of how best to load web fonts multiplies when you add plugins. Usually, themes do all of the heavy lifting when it comes to design. However, some plugins are launching into this side of the WordPress world to add additional styling options. There is no way to resolve conflicts when loading multiple copies of the same font. There is also no foolproof way to deactivate a theme’s fonts and replace them through the plugin.

One of these plugin authors emailed me with some news that I had already known. The Web Fonts API no longer seemed to land in WordPress 5.9. The developer was preparing to launch a new website and service in addition to the new functionality. They even had a mascot. For now, we may have to wait.

The feature freeze deadline was two days ago. Therefore, the Web Fonts API is unlikely to be added back to WordPress milestone 5.9. Maybe the developers will see it when version 6.0 arrives. Maybe pushing it to the Gutenberg plugin breathes a little more life into it, allowing contributors to move forward with new features that depend on it.

About Nell Love

Check Also

How to Change the Font Size on Your Kindle

Here we will show you how to change the font size on your Kindle in …

Leave a Reply

Your email address will not be published.