Google Fonts Loader - WebsiteBaker / WBCE script

Using Google Fonts is a privacy problem for some countries (soon possibly in all Europe) because the visitor IP address will be visible for Google on US servers.

Now there is a small script that you can add to your template that will download all necessary files to your server (template) and make them available in your CSS as usual.

Just upload the PHP script (in the downloaded .zip file) into your template folder and add the font url's just like Google fonts suggest.

<?php 
$font[] = 'https://fonts.googleapis.com/css?family=Roboto+Condensed:400,300,700&display=swap';
$font[] = 'https://fonts.googleapis.com/css?family=Noto+Sans:400,700&display=swap';
$font[] = 'https://fonts.googleapis.com/css2?family=Mouse+Memoirs&display=swap';
$font[] = 'https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@200;300;400;600&display=swap';
$font[] = 'https://fonts.googleapis.com/css2?family=Raleway:wght@100;200;400;600;800;900&display=swap';
$font_format = 'woff'; // optional values 'woff' / 'woff2' / 'woff2-unicode'
include 'google_fonts.php';
?>

The included script will read/download the files from google's server and store everything locally.

The output will be pointing to local fonts only.

No more privacy problems!

v0.3 improvements:

- beter debugging info in errorlog (set LOCALFONT_INCLUDE_DEBUG to true in google_fonts.php);
- using the correct google API link when variable fonts are used
- accepting different methods for declaring the fonts to use:  1. just using the name and optionally weight. 

$font[] = "Open Sans";
$font[] = "Open Sans:400,600,700";
$font[] = "Noto+Sans:wght@400;600;700;900";

  2. use the link with one or more fonts

$font[] = 'https://fonts.googleapis.com/css?family=Roboto+Condensed:400,300,700&display=swap';
$font[] = 'https://fonts.googleapis.com/css?family=Roboto+Condensed:400,300,700&family=Mouse+Memoirs&display=swap';

  3. use the complete tag as presented by google fonts

$font[] = '<link href="https://fonts.googleapis.com/css2?family=DynaPuff:wght@400;700&family=Ubuntu:wght@300;350;400;700&display=swap" rel="stylesheet">';


 

Download

localfont_include_v0.5.zip

v0.5
Fixed a problem caused by a change in google fonts for the woff format
License: GNU / GPL
Timestamp: 15-03-2024
Version: 0.5
Filesize: 4.70 KB
Downloads: 31

localfont_include_v0.3.zip
Version: 0.3, Timestamp: 15-08-2022, Downloads: 610
v0.3
- beter debugging info in errorlog (set LOCALFONT_INCLUDE_DEBUG to true in google_fonts.php);
- using the correct API link when variable fonts are used
- accepting different methods for declaring the fonts to use

localfont_include_v0.2.zip
Version: 0.2, Timestamp: 12-08-2022, Downloads: 299
v0.2
- added possibility to select what font type is used (ttf/woff/woff2)
- cleanup of previous downloads when refreshing (logged-in in admin, CTRL F5 on any frontend page)
- the script will create folders by default like: /css/local/ and /fonts/local/
* do not use these folders for other css/fonts. on refreshing these folders will be emptied completely.
- return a warning message when your server does not support curl (needed to download css/fonts).

localfont_include.zip
Version: 0.1, Timestamp: 10-08-2022, Downloads: 256
v0.1
- initial release