1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-12-13 17:18:37 +02:00
nerd-fonts/bin/scripts/generate-font-image-previews.sh
Fini Jastrow 7aa717a05e generate-font-image-previews: Cleanup
[why]
There are two svg tempates, one with and one without Inkscape metadata.

[how]
The metadataless files is fine and opens ok in Inkscape.
There are no real differences between the two templates.
Drop the Inkscape one.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-12-19 17:07:20 +01:00

43 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Nerd Fonts Version: 2.3.0-RC
# Script Version: 1.0.1
# Create font previews.
# All fonts need to be installed (or no preview is generated)
# Files should end up in the gh-pages branch
set -e
ver=$(inkscape --version)
echo "Check generator version: $ver"
output_dir="../../assets/img/previews/"
template_svg="lib/template-font-preview.svg"
main() {
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);
if [ -z "$imagePreviewFont" ]; then
echo "[Skipping] $patchedName"
continue
fi
fc-list -q "$imagePreviewFont" \
&& generate_preview "$imagePreviewFont" "$patchedName Nerd Font" \
|| echo "[Missing] $imagePreviewFont"
done
}
generate_preview() {
font=$1
fontText=$2
echo "[Generating] $font"
sed -e "s/000000/ffffff/" -e "s/sans-serif/${font}/" -e "s/Font Name/${fontText}/" <"$template_svg" >"${output_dir}${fontText}.svg"
inkscape "${output_dir}${fontText}.svg" "--actions=select-all;object-to-path;export-filename:${output_dir}${fontText}.svg;export-do;quit-inkscape" 2>/dev/null
# svgo "${output_dir}${fontText}.svg"
}
main "$@"; exit