test-fonts: Allow for 5 digit codes

[why]
The code is hardcoded for 4 (hex-)digit codepoints. If we want to
examine 3 or 5 digit codes it breaks the formatting.

[how]
Switch from \u to \U to allow printing codepoints with more than 4
digits. This works on all machines I tested (Linux/Mac).

Manually pad the codepoint to get a consistent length independent of
actual number of digits. We can not use "%5x" because we want to
underline only the actual digits.
This also makes the output of empty slots nicer because the underline is
skipped if there is no code.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2023-06-01 07:37:35 +02:00
parent dcbcef0fe6
commit 6f1cdb82d9

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Nerd Fonts Version: 3.0.1
# Script Version: 1.1.0
# Script Version: 1.1.1
# Run this script in your local bash:
# curl https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/bin/scripts/test-fonts.sh | bash
@ -58,15 +58,20 @@ function print-decimal-unicode-range() {
local hexCode
hexCode=$(printf '%x' "${decimalCode}")
local code="${hexCode}"
local char="\\u${hexCode}"
local char="\\U${hexCode}"
# fill in placeholder cells properly formatted:
if [ "${char}" = "\\u0" ]; then
if [ "${char}" = "\\U0" ]; then
char=" "
code=" "
code=""
fi
allCodes+="${currentColorCode} ${underline}${code}${reset_color}${currentColorCode} ${reset_color}$bar"
filler=""
for ((c = ${#code}; c < 5; c++)); do
filler=" ${filler}"
done
allCodes+="${currentColorCode}${filler}${underline}${code}${reset_color}${currentColorCode} ${reset_color}$bar"
allChars+="${currentColorChar} ${char} ${reset_color}$bar"
counter=$((counter + 1))
count=$(( (count + 1) % wrapAt))