Skip to content

Instantly share code, notes, and snippets.

@zinglax
Created July 2, 2019 16:14
Show Gist options
  • Save zinglax/7aad851af73055a9659e34863427aae8 to your computer and use it in GitHub Desktop.
Save zinglax/7aad851af73055a9659e34863427aae8 to your computer and use it in GitHub Desktop.
Install Google Fonts to Ubuntu
#!/bin/bash
# Installs google fonts to system
#
# oooooooooooo oooo oooooooooooo .
# `888' `8 `888 `888' `8 .o8
# 888 oooo d8b .ooooo. .oooo.o 888 .oo. 888 .ooooo. ooo. .oo. .o888oo .oooo.o
# 888oooo8 `888""8P d88' `88b d88( "8 888P"Y88b 888oooo8 d88' `88b `888P"Y88b 888 d88( "8
# 888 " 888 888ooo888 `"Y88b. 888 888 888 " 888 888 888 888 888 `"Y88b.
# 888 888 888 .o o. )88b 888 888 888 888 888 888 888 888 . o. )88b
# o888o d888b `Y8bod8P' 8""888P' o888o o888o o888o `Y8bod8P' o888o o888o "888" 8""888P'
#ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
#Z VARS ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
#ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
# Fonts Extension
F_EXT="TTF"
# Local Fonts Directory
LF_DIR=${HOME}/.local/share/fonts
# Google Fonts URL
GF_URL="https://codeload.github.com/google/fonts/zip/master"
# Google Fonts Local ( Extracted ) Directory
GFL_DIR=${HOME}/.local/share/google-fonts
# Google Fonts ( Local File ) Zip
GF_ZIP="${GFL_DIR}/google-fonts-master.zip"
echo "Local Fonts Directory:\t\t${LF_DIR}"
echo "Google Fonts URL:\t\t${GF_URL}"
echo "Google Fonts Local Directory:\t${GFL_DIR}"
echo "Google Fonts Zip:\t\t${GF_ZIP}"
#ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
#Z STEPS ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
#ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
# Get Google Fonts Zip from URL
echo "Get Google Fonts Zip from URL"
curl -o ${GF_ZIP} ${GF_URL}
# Ensure Local Fonts Directoy Exists
echo "Ensure Local Fonts Directoy Exists"
if [ ! -d "$LF_DIR" ]; then
echo "Creating local fonts dir"
mkdir -p ${LF_DIR}
fi
# Ensure Google Fonts Local Directoy Exists
echo "Ensure Google Fonts Local Directoy Exists"
if [ ! -d "$GFL_DIR" ]; then
echo "Creating local google fonts dir"
mkdir -p ${GFL_DIR}
fi
# Empty Google Fonts Local Directoy
echo "Empty Google Fonts Local Directoy"
rm -rf ${GFL_DIR}/*
# Unzip Google Fonts Zip to Google Fonts Local Directoy
echo "Unzip Google Fonts Zip to Google Fonts Local Directoy "
unzip ${GF_ZIP} -d ${GFL_DIR}
# Find ttf's and copy to Local Fonts Directory
echo "Find ttf's and copy to Local Fonts Directory"
find ${GFL_DIR} -name "*.ttf" -type f -exec /bin/cp {} ${LF_DIR} \;
# Cleanup Google Fonts Local Directoy
echo "Cleanup Google Fonts Local Directoy"
rm -rf ${GFL_DIR}
# Update Font Cache
echo "Update Font Cache"
fc-cache -fv
@zinglax
Copy link
Author

zinglax commented Jul 2, 2019

Let me know what you guys think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment