Archived topic
Use Local Font and Remove Google Fonts
13 replies · Started by sumanta on August 7, 2018
To increase the performance of my site, I want to store a couple of Google fonts in my server and remove any requests to Google server. I did these:
1. Hosted Open Sans locally using the guide below and now I can see Open Sans in my system font list of Customizer.
https://docs.generatepress.com/article/adding-local-fonts/
2. Tried to remove Google font completely but failed.
Added this using Code Snippets plugin (ref: https://generatepress.com/forums/topic/how-to-disable-google-fonts-or-update-enqueing-process/):
add_action( 'wp_enqueue_scripts','tu_remove_google_fonts', 10 );
function tu_remove_google_fonts() {
wp_dequeue_style( 'generate-fonts' );
}
But I can still see Google fonts in Customizer. Please help.
By the way, are these the right way to avoid any request to Google font server?
(My site is an intranet site, so cannot share the web link)
Thank you.
Hi there,
There's no need to remove Google Fonts from the Customizer itself. If you choose the Open Sans you added locally, GeneratePress won't load anything from Google.
The fonts will still display as options in the Customizer, but the front end of your site won't make any calls to Google.
Let me know if that makes sense or not :)
Thank you Tom. I will try that.
You're welcome :)
Hi Tom,
sorry to pick up this old topic, but I have a question.
Even if it is not necessary to remove all the font choices in the customizer, would this still somehow be possible? If a site already uses for example two different local fonts, in some scenarios it would be good if only these two local font choices were presented in the typography settings inside the customizer.
Hi there,
this article provides the PHP snippet to remove the google font list from the customizer:
Hi David,
thanks for reminding me of these snippets. I tried these a while ago and the second snippet for removing the font list somehow didn't work. I now tried the snippet and this time it worked.
Is there a way of also removing the list of system fonts, resulting in only having the locally uploaded fonts in the list?
I don't think there is a filter for that.
Hi David,
I just wanted to let you know that the snippet for removing the Google Fonts from the typography menues (https://docs.generatepress.com/article/remove-google-fonts/) throws the following PHP warning, if DEBUG mode is activated:
Warning: array_key_exists() expects parameter 2 to be array, bool given in .../plugins/gp-premium/typography/functions/migration.php on line 170
Since it's just a warning no problem at all, I just wanted to let you know.
I guess you can't do much about it, because the array gets removed by the filter mentioned above.
Thanks for the heads up! Just adjusted the function :)
Perfect! Thank you very much!
No problem!
Hi Generate Press Team,
I used the instructions here to remove Google Fonts:
https://wordpress.org/support/topic/remove-preconnect-to-https-fonts-gstatic-com/
But, that did not completely remove Google Fonts.
I previously used native Google Fonts (Ubuntu and Lora) and I tried to clean up my website but maybe there are still some vestiges of Google. Actually, I can still see Google Fonts (Ubuntu) making a request as seen in this GT Metrix Report (https://gtmetrix.com/reports/www.lifestyledemocracy.com/zL5Qp1Dh/).
I would appreciate your support in completely removing Google Fonts from my website/GP theme.
Looking forward to your tips.
Stefan
Hi Stefan,
This is an old topic, as we rebuilt the typography system, now you don't need to add any PHP snippet to remove Google fonts if you are using the dynamic typography.
https://docs.generatepress.com/article/switching-to-dynamic-typography/
If there's no Google fonts are added at customizer > typography > font manager, then GP won't call for any Google fonts.
Make sure cache is cleared, if your site still requests Google fonts, try disable all plugins and test again as there might be some plugin is using Google fonts.