Google Webfonts Installer

Bash script to download and install the entire Google Webfonts collection for offline use.

Since this script was conceived, five or six years ago, the Google Fonts Directory (as it’s now called) has grown out of all proportion. As such, while this script will still work, I don’t think I’d recommend this approach anymore. -- Simon, 2018-01

This script will download and install the entire Google Webfonts collection. Many people have asked me for it, so I’m posting it here.

The script will work on Debian GNU/Linux systems (and derivatives, such as Linux Mint and Ubuntu) only. It can be downloaded below, or copied and pasted from this page.

 1 #!/bin/bash
2 #
3 # written by Simon <[email protected]>
4 # inspired by a script written by Michalis Georgiou <[email protected]>
5 #   and modified by Andrew http://www.webupd8.org <[email protected]>,
6 #   described at
7 #   http://www.webupd8.org/2011/01/automatically-install-all-google-web.html
8 #
9 #  (but completely re-written)
10 #
11
12 HGROOT="https://googlefontdirectory.googlecode.com/hg/";
13 FONTDIR="/usr/share/fonts/truetype/google-fonts";
14
15 set -e;
16
17 exists() { which "$1" &> /dev/null ; }
18
19 if [[ $EUID -ne 0 ]]; then
20     echo "This script must be run as root (i.e. with sudo)!" 1>&2;
21     exit 1;
22 fi
23
24 if ! exists hg ; then
25     echo "Mercurial is required (hint: sudo apt-get install mercurial)!" 1>&2;
26     exit 1;
27 fi
28
29 mkdir -p "$FONTDIR";
30
31 TMPDIR=$(mktemp -d);
32 trap 'rm -rf "$TMPDIR"' EXIT INT QUIT TERM;
33
34 echo -n "Getting data from GoogleCode Repository... "
35 hg clone $HGROOT $TMPDIR > /dev/null;
36 if [ $? != 0 ]; then
37     echo "Couldn't get data from GoogleCode Repository!  Aborting!" 1>&2;
38     exit 1;
39 fi
40 echo "done!"
41
42 echo -n "Installing fonts... "
43 find $TMPDIR/ -name '*.ttf' -exec install -m644 {} "$FONTDIR" \;
44 echo "done!"
45
46 echo "Updating font cache... "
47 fc-cache -fvs "$FONTDIR";
48
49 echo "All done!"

Downloads