2022-09-13 12:05:26 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-05-13 07:48:24 +02:00
|
|
|
# Nerd Fonts Version: 3.0.1
|
2023-04-28 16:55:13 +02:00
|
|
|
# Script Version: 1.2.1
|
2022-09-13 12:05:26 +02:00
|
|
|
# Create font previews.
|
|
|
|
# All fonts need to be installed (or no preview is generated)
|
|
|
|
# Files should end up in the gh-pages branch
|
2019-08-15 22:57:52 +02:00
|
|
|
|
2022-09-13 12:05:26 +02:00
|
|
|
set -e
|
|
|
|
ver=$(inkscape --version)
|
|
|
|
echo "Check generator version: $ver"
|
2019-08-15 22:57:52 +02:00
|
|
|
|
2022-09-13 12:05:26 +02:00
|
|
|
output_dir="../../assets/img/previews/"
|
2022-12-19 18:07:20 +02:00
|
|
|
template_svg="lib/template-font-preview.svg"
|
2022-12-19 18:10:38 +02:00
|
|
|
template2_svg="lib/template-font-preview2.svg"
|
2019-08-15 22:57:52 +02:00
|
|
|
|
2022-09-13 12:05:26 +02:00
|
|
|
main() {
|
2019-09-12 23:22:39 +02:00
|
|
|
mkdir -p "$output_dir"
|
|
|
|
|
|
|
|
for i in $(jq '.fonts | keys | .[]' lib/fonts.json); do
|
|
|
|
patchedName=$(jq -r ".fonts[$i].patchedName" lib/fonts.json);
|
|
|
|
imagePreviewFont=$(jq -r ".fonts[$i].imagePreviewFont" lib/fonts.json);
|
2023-04-28 16:55:13 +02:00
|
|
|
if [ "$imagePreviewFont" != "$patchedName Nerd Font" ]; then
|
|
|
|
echo "[mismatch] (Fam vs name) $imagePreviewFont <=> $patchedName"
|
|
|
|
fi
|
2022-09-13 12:05:26 +02:00
|
|
|
if [ -z "$imagePreviewFont" ]; then
|
|
|
|
echo "[Skipping] $patchedName"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2022-12-19 18:10:38 +02:00
|
|
|
if $( fc-list -q "${imagePreviewFont}:charset=41" ); then
|
|
|
|
generate_preview "$imagePreviewFont" "$patchedName Nerd Font"
|
|
|
|
elif $( fc-list -q "${imagePreviewFont}" ); then
|
|
|
|
generate_preview_symbols "$imagePreviewFont" "$patchedName Nerd Font"
|
|
|
|
else
|
|
|
|
echo "[Missing] $imagePreviewFont"
|
|
|
|
fi
|
2019-09-12 23:22:39 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
generate_preview() {
|
|
|
|
font=$1
|
|
|
|
fontText=$2
|
2022-09-13 12:05:26 +02:00
|
|
|
echo "[Generating] $font"
|
2022-12-19 18:10:38 +02:00
|
|
|
sed -e "s/000000/ffffff/" -e "s/sans-serif/${font}/" -e "s/Font Name/${fontText}/" <"$template_svg" >"${output_dir}${font}.svg"
|
2022-12-19 21:55:23 +02:00
|
|
|
inkscape "${output_dir}${font}.svg" -g "--verb=EditSelectAll;ObjectToPath;FileVacuum;FitCanvasToDrawing;FileSave;FileQuit" 2>/dev/null
|
2022-12-19 18:10:38 +02:00
|
|
|
# svgo "${output_dir}${font}.svg"
|
|
|
|
}
|
|
|
|
|
|
|
|
generate_preview_symbols() {
|
|
|
|
font=$1
|
|
|
|
fontText=$2
|
|
|
|
echo "[Gen. Symb.] $font"
|
|
|
|
sed -e "s/000000/ffffff/" -e "40,80s/sans-serif/${font}/" -e "s/Font Name/${fontText}/" <"$template2_svg" >"${output_dir}${font}.svg"
|
2022-12-19 21:55:23 +02:00
|
|
|
inkscape "${output_dir}${font}.svg" -g "--verb=EditSelectAll;ObjectToPath;FileVacuum;FitCanvasToDrawing;FileSave;FileQuit" 2>/dev/null
|
2022-12-19 18:10:38 +02:00
|
|
|
# svgo "${output_dir}${font}.svg"
|
2019-09-12 23:22:39 +02:00
|
|
|
}
|
|
|
|
|
2023-01-30 08:55:58 +02:00
|
|
|
image_font_files=( \
|
2023-04-28 16:55:13 +02:00
|
|
|
'3270/Regular/3270NerdFont-Regular.ttf' \
|
|
|
|
'Agave/AgaveNerdFont-Regular.ttf' \
|
|
|
|
'AnonymousPro/Regular/AnonymiceProNerdFont-Regular.ttf' \
|
|
|
|
'Arimo/Regular/ArimoNerdFont-Regular.ttf' \
|
|
|
|
'AurulentSansMono/AurulentSansMNerdFont-Regular.otf' \
|
|
|
|
'BigBlueTerminal/BigBlueTermPlusNerdFont-Regular.ttf' \
|
|
|
|
'BitstreamVeraSansMono/Regular/BitstromWeraNerdFont-Regular.ttf' \
|
|
|
|
'CascadiaCode/Regular/CaskaydiaCoveNerdFont-Regular.ttf' \
|
|
|
|
'CodeNewRoman/Regular/CodeNewRomanNerdFont-Regular.otf' \
|
2023-04-30 10:13:52 +02:00
|
|
|
'ComicShannsMono/ComicShannsMonoNerdFont-Regular.otf' \
|
2023-04-28 16:55:13 +02:00
|
|
|
'Cousine/Regular/CousineNerdFont-Regular.ttf' \
|
|
|
|
'DaddyTimeMono/DaddyTimeMonoNerdFont-Regular.ttf' \
|
|
|
|
'DejaVuSansMono/Regular/DejaVuSansMNerdFont-Regular.ttf' \
|
|
|
|
'DroidSansMono/DroidSansMNerdFont-Regular.otf' \
|
|
|
|
'FantasqueSansMono/Regular/FantasqueSansMNerdFont-Regular.ttf' \
|
|
|
|
'FiraCode/Regular/FiraCodeNerdFont-Regular.ttf' \
|
|
|
|
'FiraMono/Regular/FiraMonoNerdFont-Regular.otf' \
|
|
|
|
'Gohu/14/GohuFont14NerdFont-Regular.ttf' \
|
|
|
|
'Go-Mono/Regular/GoMonoNerdFont-Regular.ttf' \
|
|
|
|
'Hack/Regular/HackNerdFont-Regular.ttf' \
|
|
|
|
'Hasklig/Regular/HasklugNerdFont-Regular.otf' \
|
|
|
|
'HeavyData/HeavyDataNerdFont-Regular.ttf' \
|
|
|
|
'Hermit/Regular/HurmitNerdFont-Regular.otf' \
|
|
|
|
'iA-Writer/Mono/Regular/iMWritingMonoNerdFont-Regular.ttf' \
|
|
|
|
'IBMPlexMono/Mono/BlexMonoNerdFont-Regular.ttf' \
|
|
|
|
'Inconsolata/InconsolataNerdFont-Regular.ttf' \
|
|
|
|
'InconsolataGo/Regular/InconsolataGoNerdFont-Regular.ttf' \
|
|
|
|
'InconsolataLGC/Regular/InconsolataLGCNerdFont-Regular.ttf' \
|
|
|
|
'Iosevka/Regular/IosevkaNerdFont-Regular.ttf' \
|
|
|
|
'IosevkaTerm/Regular/IosevkaTermNerdFont-Regular.ttf' \
|
|
|
|
'JetBrainsMono/Ligatures/Regular/JetBrainsMonoNerdFont-Regular.ttf' \
|
|
|
|
'Lekton/Regular/LektonNerdFont-Regular.ttf' \
|
|
|
|
'LiberationMono/LiterationMonoNerdFont-Regular.ttf' \
|
|
|
|
'Lilex/Regular/LilexNerdFont-Regular.ttf' \
|
|
|
|
'Meslo/M/Regular/MesloLGMNerdFont-Regular.ttf' \
|
|
|
|
'Monofur/Regular/MonofurNerdFont-Regular.ttf' \
|
|
|
|
'Monoid/Regular/MonoidNerdFont-Regular.ttf' \
|
|
|
|
'Mononoki/Regular/MononokiNerdFont-Regular.ttf' \
|
|
|
|
'MPlus/M_Plus_1_code/M+1CodeNerdFont-Regular.ttf' \
|
|
|
|
'NerdFontsSymbolsOnly/Symbols2048EmNerdFontMono-Regular.ttf' \
|
|
|
|
'Noto/Sans-Mono/NotoSansMNerdFont-Regular.ttf' \
|
|
|
|
'OpenDyslexic/Regular/OpenDyslexicNerdFont-Regular.otf' \
|
|
|
|
'Overpass/Mono/Regular/OverpassMNerdFont-Regular.otf' \
|
|
|
|
'ProFont/profontiix/ProFontIIxNerdFont-Regular.ttf' \
|
|
|
|
'ProggyClean/Regular/ProggyCleanNerdFont-Regular.ttf' \
|
|
|
|
'RobotoMono/Regular/RobotoMonoNerdFont-Regular.ttf' \
|
|
|
|
'ShareTechMono/ShureTechMonoNerdFont-Regular.ttf' \
|
|
|
|
'SourceCodePro/Regular/SauceCodeProNerdFont-Regular.ttf' \
|
|
|
|
'SpaceMono/Regular/SpaceMonoNerdFont-Regular.ttf' \
|
|
|
|
'Terminus/Regular/TerminessNerdFont-Regular.ttf' \
|
|
|
|
'Tinos/Regular/TinosNerdFont-Regular.ttf' \
|
|
|
|
'Ubuntu/Regular/UbuntuNerdFont-Regular.ttf' \
|
|
|
|
'UbuntuMono/Regular/UbuntuMonoNerdFont-Regular.ttf' \
|
|
|
|
'VictorMono/Regular/VictorMonoNerdFont-Regular.ttf' \
|
2023-01-30 08:55:58 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# Enable this to get a list of instruction to install all the needed fonts
|
|
|
|
#
|
|
|
|
# for f in "${image_font_files[@]}"; do
|
|
|
|
# echo "cp '../../patched-fonts/$f' ~/.local/share/fonts"
|
|
|
|
# done
|
|
|
|
# exit
|
|
|
|
|
|
|
|
# Enable this to get a list of Family names
|
|
|
|
#
|
|
|
|
# for f in "${image_font_files[@]}"; do
|
|
|
|
# fc-query "../../patched-fonts/$f" '-f %{family}\n'
|
|
|
|
# done
|
|
|
|
|
2019-09-12 23:22:39 +02:00
|
|
|
main "$@"; exit
|