Host Google Fonts locally with OMGF
Google fonts are being used on almost all modern themes, they are a great resource for great typefaces for any kind of WordPress based website. However the fact that these fonts are hosted on Google servers can conflict with GDPR compliance requirements, this is why site administrators need to be able to host them locally should they decide to do so. As usual there’s a plugin for that!
This plugin will auto-detect any Google font selected on our theme’s typography options in the Customizer and with a few clicks will download the fonts, generate and enqueue a local stylesheet to make them work locally. To achieve this, install, activate the plugin and navigate to Settings → Optimize Google Fonts
In the plugin’s settings screen click the Auto Detect button and wait for a few seconds. Once the auto-detection is done the plugin will list the font families found, these display both the theme’s default font families and also any font family selected by you in the theme’s typography options in the Customizer. If you want to exclude a particular font weight from being loaded just click the X button on the right most side of each list item in the Available font styles section. Next click Download Fonts and Generate Stylesheet.
Once the stylesheet generation is done you can dequeue the theme’s built in Google fonts stylesheet by adding the code below at the end of your theme’s (or even better child theme’s) functions.php file.
Please note that you will have to replace the ci-theme bit in ci-theme-user-google-fonts in the highlighted line above, with the theme’s name, for example for Hugo you will use hugo-user-google-fonts.