Local Google web font hosting made easy, controllable and automated

The bash script best-served-local is created for web masters/hosters who don’t want to force their visitors to leave traces at google which each visit of a website.

The scripts makes downloading and self-hosting a google web font as easy as running the following command in a terminal:

bash <(wget -q -o - "https://lacocina.nl/best-served-local") "Roboto Bold"

This will lookup the appropriate font definitions and character set for roboto, download the download the appropriate font files (like roboto_bold_v15_latin_700.woff) to a local temporary directory and will display the following valid css3 in the terminal:

@font-face {
      font-family: 'roboto bold';
       local('roboto bold'), local('roboto-bold'), 
       url('roboto_bold_v15_latin_700.woff2') format('woff2'),
       url('roboto_bold_v15_latin_700.woff') format('woff');
      font-style:  normal;
      font-weight: 700;
  /* ... */

Screencast of the basic usage example:

Fully automated usage example

Specifying a few extra options fully automates your desired usage scenario:

bash < (wget -q -O - "https://lacocina.nl/best-served-local") --incss-fontpath /static/fonts --outputfile /var/www/example.org/static/css/fontdefs.css --fontdirectory /var/www/example.org/static/fonts/ --overwrite --formats superprogressive --subsets latin-ext "Open Sans:300,400,700" "Roboto:100,100italic,regular,italic,900"

Apart from bash version 4, this script only depends on curl (it’s not tested on OSX yet).

Getting and running the script

The script can be cloned or forked from its gitlab repository, downloaded, or started straight from the web like showed above (although some would advise against that).

To display all commandline arguments, run the script with the `–help` (or `-h`) argument.

See the README.md file for detailed usage information.

Happy Google-free hosting!

Leave a Reply

Your email address will not be published. Required fields are marked *