BibleGet-I-O / bibleget-wordpress

Plugin for WordPress that let's you insert Bible quotes into your posts or pages from a variety of Bible versions in different languages. This is a mirror of the SVN repo where the plugin gets published to the WordPress plugins store. Kudos to @kas-catholic for helping import the repo from SVN.
https://www.bibleget.io
Apache License 2.0
0 stars 2 forks source link

Update for WordPress 6.5 fonts #23

Open JohnRDOrazio opened 6 months ago

JohnRDOrazio commented 6 months ago

WordPress 6.5 has finally enabled handling fonts and installing fonts from Google WebFonts. This means, we can now avoid all the messy font pickers we created in the BibleGet plugin to allow installation and usage of Google Fonts. In order to do this, we need to detect whether the new fonts functionality is present. Is there an easy way of detecting support for this? Or would we have to simply check against the minimum supported WordPress version?

JohnRDOrazio commented 2 months ago

This is basically all handled through global styles in Full Site Editing. I believe single blocks can register their own styles, that can then be handled through the Full Site Editor

JohnRDOrazio commented 2 months ago

Currently handling this in the oop-dev branch.

JohnRDOrazio commented 2 months ago

See for reference:

JohnRDOrazio commented 2 months ago

This would also mean detecting whether the current theme supports Full Site Editing. If it does, we won't implement the custom Font selector; if it doesn't, we will implement the custom Font selector.

JohnRDOrazio commented 2 months ago

Perhaps this can help: Discussion: Identifying themes with support for full site editing

JohnRDOrazio commented 2 months ago

So we have succeeded in retrieving an actual .woff2 file rather than .ttf files, which cuts the size of the font files practically in half.

Now we just need to take care of the font loading issue. Rather than load a css file that declares all of the possible font faces (resulting in over a thousand requests for local resources that are therefore blocked by the browser) we should implement the CSS Font Loading API, loading only those fonts that are actually in view in the dropdown list. This will mean knowing which fonts are currently in view in the dropdown, and loading a discreet number of font resources beyond that limit (before and after).

The next best thing would be to generate images from the fonts, and perhaps combine them into a single image file, and then display the portions of the image using coordinates.

The absolute best would be to implement the new WordPress Font Library (which I believe will only be available for themes with Full Site Editing capabilities?), and only fall back to the more tedious implementation when a classic theme is in use.

JohnRDOrazio commented 2 months ago

I believe it should be possible to detect whether a theme is a block theme (support FSE) using the WP_Theme class (you can get the WP_Theme object of the current theme by calling wp_get_theme() without any parameters):

https://developer.wordpress.org/reference/classes/wp_theme/is_block_theme/