Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A bash script to install all Google Fonts, system wide, on debian based systems (ex. Ubuntu)
#!/bin/sh
# Written by: Keefer Rourke <https://krourke.org>
# Based on AUR package <https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ttf-google-fonts-git>
# dependancies: fonts-cantarell, ttf-ubuntu-font-family, git
sudo apt-get install fonts-cantarell, ttf-ubuntu-font-family, git
srcdir="/tmp/google-fonts"
pkgdir="/usr/share/fonts/truetype/google-fonts"
giturl="git://github.com/google/fonts.git"
mkdir $srcdir
cd $srcdir
echo "Cloning Git repository..."
git clone $giturl
echo "Installing fonts..."
sudo mkdir -p $pkgdir
sudo find $srcdir -type f -name "*.ttf" -exec install -Dm644 {} $pkgdir \;
echo "Cleaning up..."
sudo find $pkgdir -type f -name "Cantarell-*.ttf" -delete \;
sudo find $pkgdir -type f -name "Ubuntu-*.ttf" -delete \;
# provides roboto
sudo apt-get --purge remove fonts-roboto
echo "Updating font-cache..."
sudo fc-cache -f > /dev/null
echo "Done!"
@codeAshu

This comment has been minimized.

Copy link

codeAshu commented Oct 23, 2017

Great :) Works really well!

@drinkmaker

This comment has been minimized.

Copy link

drinkmaker commented Jun 24, 2018

Perfect!

@kn100

This comment has been minimized.

Copy link

kn100 commented Aug 21, 2018

Simple and effective, thanks!

@michaelmcandrew

This comment has been minimized.

Copy link

michaelmcandrew commented Sep 25, 2018

Here's a simpler solution. In your home directory:

mkdir .fonts
git clone git://github.com/google/fonts.git .fonts/google-fonts
fc-cache -f

There are other directories where you can store fonts, e.g. ~/.local/share/fonts or /usr/local/share/fonts if you want them to be available to all users. See https://wiki.debian.org/Fonts#Manually for more info.

PS if there are any fonts that you don't want to import (for example system fonts that you already have like google-fonts/ofl/cantarell or google-fonts/ufl/ubuntu) just delete the directories for the fonts you don't want to import before running fc-cache.

@nicola-lunghi

This comment has been minimized.

Copy link

nicola-lunghi commented Oct 15, 2018

Some suggestion

git clone --depth=1 $giturl

also is ttf not tff :-)

sudo find $pkgdir -type f -name "Cantarell-*.ttf" -delete \;
sudo find $pkgdir -type f -name "Ubuntu-*.ttf" -delete \;

see also here
https://github.com/qrpike/Web-Font-Load/blob/master/install.sh

@DeepSeaTian

This comment has been minimized.

Copy link

DeepSeaTian commented May 31, 2019

works like a charm!

@oleersoy

This comment has been minimized.

Copy link

oleersoy commented Aug 9, 2019

Awesome - Thank you so much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.