From 6f1cdb82d9c3582e3a26f12e1382422189579aeb Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 1 Jun 2023 07:37:35 +0200 Subject: [PATCH] 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 --- bin/scripts/test-fonts.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/scripts/test-fonts.sh b/bin/scripts/test-fonts.sh index caa8087fa..68ea672e3 100755 --- a/bin/scripts/test-fonts.sh +++ b/bin/scripts/test-fonts.sh @@ -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))