particle-os-modules/modules/fonts/sources/google-fonts.sh
Lucas Ribeiro 53507920aa
feat: fonts module (#52)
* feat: nerd-fonts modules

* feat: nerd-fonts modules

* feat: fonts module

* fix: fonts module readme

* chore: fonts module readme

* chore: fonts module

* chore: fonts module

* Update nerd-fonts.sh

* Update google-fonts.sh

* chore: scripts

* docs: unify font module grammar with other modules

fixes some misc grammar mistakes and makes documentation more inline with that of other modules

* refactor: move download.sh to root directory
this removes the need of the font source scripts
to have an environment variable with path to the ./scripts directory
making them more portable

* fix: get correct download.sh path
(relative to currently running script)

* chore: rm loop making .sh in scripts/ executable
this is not needed, as download.sh was moved and is called with bash

---------

Co-authored-by: xyny <60004820+xynydev@users.noreply.github.com>
2023-10-01 13:14:54 +00:00

27 lines
No EOL
714 B
Bash

#!/usr/bin/env bash
set -oue pipefail
mapfile -t FONTS <<< "$@"
URL="https://fonts.google.com/download?family="
DIR_PRINCIPAL=/usr/share/fonts/google-fonts
COMPACT_FORMAT="zip"
# To download google-fonts it is necessary to enter the name of the font replacing the spaces with '%20'. See the 3rd parameter of the download script.
if [ ${#FONTS[@]} -gt 0 ]; then
echo "Installation of google-fonts started"
rm -rf "$DIR_PRINCIPAL"
for font in "${FONTS[@]}"; do
font="$(echo "$font" | sed -e 's|^[[:blank:]]||g' | tr -d '\n')"
bash "$(dirname "$0")"/../download.sh "$font" "$COMPACT_FORMAT" "$URL${font// /%20}" "$DIR_PRINCIPAL/$font"
done
fc-cache -f $DIR_PRINCIPAL
fi