area-51/font-logos/scripts/create_nf_lib.sh

24 lines
831 B
Bash
Raw Normal View History

2025-01-13 14:29:20 +01:00
#!/usr/bin/env bash
# Convert the icons.tsv file's data to Nerd Font lib's format
# to update their lib file with the new glyphs.
# Usage: ./create_nf_lib.sh
# Copy missing glyphs from the output to the
# <PATH>/nerd-fonts/bin/scripts/lib/i_logos.sh file.
# Get script directory to set file path relative to it
file_path="$(
cd -- "$(dirname "${0}")" >/dev/null 2>&1 || exit
pwd -P
)/../icons.tsv"
# Read the tsv file excluding the header
sed '1d' "${file_path}" | while IFS=$'\t' read -r offset _ classname; do
# Calculate the codepoint, font-logos starts at 0xF300
codepoint=$((0xF300 + offset))
# Get the glyph from the codepoint
glyph=$(printf "\\u%x" "${codepoint}" 2>/dev/null)
# Print line using the Nerd Fonts lib's format
printf "i='%b' i_linux_%s=\$i\n" "${glyph}" "$(echo "${classname}" | tr '-' '_')"
done