1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-12-13 17:18:37 +02:00
nerd-fonts/bin/scripts/test-fonts.sh

103 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
# Given a decimal number start and end print all unicode codepoint.
# If $3 is specified, it's used as the current column number.
function print-decimal-unicode-range() {
local start="$1"
local end="$2"
local continuedCount="$3"
local count="${continuedCount:-0}"
# Use alternating colors to see which symbols extend out of the bounding
# box.
local bgColor='\x1b[48;2;54;11;0m'
local alternateBgColor='\x1b[48;2;0;54;11m'
local currentColor="${bgColor}"
local allChars="${currentColor}"
local wrapAt=25
for decimalCode in $(seq "${start}" "${end}"); do
local hexCode=$(printf '%x ' "${decimalCode}")
allChars+="\u${hexCode} "
count=$(( (count + 1) % $wrapAt))
if [[ count -eq 0 ]]; then
if [[ "${currentColor}" = "${alternateBgColor}" ]]; then
currentColor="${bgColor}"
else
currentColor="${alternateBgColor}"
fi
allChars+="\n${currentColor}"
fi
done
printf "${allChars}${reset_color}"
}
# TODO COLOR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
function print-unicode-ranges() {
local count=0
local arr=($@)
for ((i=0; i<=$#; i+=2)); do
#for i in "${!arr[@]}"
#echo "i $i"
#local start="$@[i]"
#local start="${@[$i]}"
local start="${arr[$i]}"
#echo "start $start"
#echo "i+1 $((i+1))"
#local end="$@[i+1]"
local end="${arr[(($i+1))]}"
#echo "end $end"
local startDecimal=$((16#$start))
local endDecimal=$((16#$end))
#echo "startDec $startDecimal"
#echo "endDec $endDecimal"
print-decimal-unicode-range "${startDecimal}" "${endDecimal}" "${count}"
count=$(($count + $endDecimal - $startDecimal))
done
}
function test-fonts() {
echo "Nerd - Pomicons"
print-unicode-ranges e000 e00a
echo; echo
echo "Nerd - Powerline"
print-unicode-ranges e0a0 e0a2 e0b0 e0b3
echo; echo
echo "Nerd - Powerline Extra"
print-unicode-ranges e0a3 e0a3 e0b4 e0c8 e0cc e0d2 e0d4 e0d4
echo; echo
echo "Nerd - Symbols original"
print-unicode-ranges e5fa e62b
echo; echo
echo "Nerd - Devicons"
print-unicode-ranges e700 e7c5
echo; echo
echo "Nerd - Font awesome"
print-unicode-ranges f000 f2e0
echo; echo
echo "Nerd - Font awesome extension"
print-unicode-ranges e200 e2a9
echo; echo
echo "Nerd - Octicons"
print-unicode-ranges f400 f4a8 2665 2665 26A1 26A1 f27c f27c
echo; echo
echo "Nerd - Font Linux"
print-unicode-ranges f300 f313
echo; echo
echo "Nerd - Font Power Symbols"
print-unicode-ranges 23fb 23fe 2b58 2b58
echo; echo
echo "Nerd - All"
print-unicode-ranges e000 e00a e0a0 e0a2 e0b0 e0b3 e0a3 e0a3 e0b4 e0c8 e0cc e0d2 e0d4 e0d4 e5fa e62b e700 e7c5 f000 f2e0 e200 e2a9 f400 f4a8 2665 2665 26A1 26A1 f27c f27c f300 f313 23fb 23fe 2b58 2b58
}
test-fonts