-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclnfont
More file actions
executable file
·71 lines (52 loc) · 1.61 KB
/
clnfont
File metadata and controls
executable file
·71 lines (52 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -euo pipefail
# Utility that downloads my font of choice (Consolas Ligaturized), then patchs
# it with NerdFonts.
# Dependencies:
# mktemp
# git
# curl
# unzip
# python3
# fontforge (python3-fontforge)
# TODO: Quiet mode.
# TODO: I could run all this on docker.
# -------------------------------- Functions --------------------------------- #
Warn()
{
printf "Warning: %s\n" "$1" 1>&2
}
Err()
{
printf "Error: %s\n" "$2" 1>&2
# shellcheck disable=2086
(($1 > 0)) && exit $1
}
# ----------------------------- Input Processing ----------------------------- #
if (($# == 0)); then
echo "Usage: clnfont OUT_DIR"
exit 1
fi
OutDir="$(realpath -m $1)"
mkdir -p "$OutDir"
# ----------------------------------- Main ----------------------------------- #
FONT="consolas-ligaturized"
FONT_REPO="https://github.com/somq/$FONT"
FONT_REPO_LAST_COMMIT="d11d670146a58b5a1ffd9f6a44cef432e1678e1e"
FONT_PATCHER_BIN="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FontPatcher.zip"
TempFolder=$(mktemp -d)
cd "$TempFolder"
echo "* Cloning $FONT"
git clone --quiet "$FONT_REPO"
[[ $(git --git-dir="./$FONT/.git" rev-parse HEAD) != $FONT_REPO_LAST_COMMIT ]] \
&& Warn "$FONT repo had a new commit"
echo "* Downloading Font Patcher"
curl --silent -o "font-forge.zip" -L $FONT_PATCHER_BIN
unzip -qq "font-forge.zip" -d "font-forge"
FontsFolder="$FONT/Consolas-FiraCode_v3"
while read -r; do
printf "* Patching: %s\n" "$REPLY"
./font-forge/font-patcher --complete "$FontsFolder/$REPLY" -out "$OutDir"
done <<<$(ls "$FontsFolder")
cd # cd out of "TempFolder".
rm "$TempFolder" -rf