From 7d255e5c3dfe5b475460d08ec2697e9aac02d91e Mon Sep 17 00:00:00 2001 From: Ryan L McIntyre Date: Sat, 8 Apr 2017 17:34:59 -0400 Subject: [PATCH] Updates script to display in ascii table (WIP) --- bin/scripts/test-fonts.sh | 143 +++++++++++++++++++++++++++++++------- 1 file changed, 119 insertions(+), 24 deletions(-) diff --git a/bin/scripts/test-fonts.sh b/bin/scripts/test-fonts.sh index 19df0d279..87a441f5c 100755 --- a/bin/scripts/test-fonts.sh +++ b/bin/scripts/test-fonts.sh @@ -6,66 +6,161 @@ function print-decimal-unicode-range() { local start="$1" local end="$2" local continuedCount="$3" + #echo "1 is $1" + #echo "2 is $2" + #echo "3 is $3" + local counter=0 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 bgColor='\e[48;5;124m%03d' - local alternateBgColor='\e[48;5;202m%03d' + local bgColor='\x1b[48;2;54;11;0m' + local alternateBgColor='\x1b[48;2;0;54;11m' + #local bgColor='\e[48;5;124m%03d' + #local alternateBgColor='\e[48;5;202m%03d' local currentColor="${bgColor}" local reset_color='\e[0m' 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 + local allCodes="${currentColor}" + local wrapAt=5 + local topLine='╔══════╦══════╦══════╦══════╦══════╗' + local bottomLine='╚══════╩══════╩══════╩══════╩══════╝' + local line='╠══════╬══════╬══════╬══════╬══════╣' + local bar='║' + local originalSequence=($(seq "${start}" "${end}")) + local originalSequenceLength=${#originalSequence[@]} + local leftoverSpaces=$((wrapAt - (originalSequenceLength % wrapAt))) + + #printf "\nleftover is %s\n" "$leftoverSpaces" + + # add fillers to array to maintain table: + if [[ "$leftoverSpaces" < "$wrapAt" ]]; then + for i in $(seq 1 $leftoverSpaces); do + #printf "adding a leftover\n" + originalSequence+=(0) + done + fi + + local sequenceLength=${#originalSequence[@]} + + #printf "orig seq len %s" "$originalSequenceLength" + #printf "\n" + #printf "leftover is %s" "$leftoverSpaces" + #printf "\n" + #printf "seq len %s" "$sequenceLength" + #printf "\n" + #exit + #printf "hey" + printf "$topLine\n" + #printf "║" + for decimalCode in "${originalSequence[@]}"; do + local hexCode=$(printf '%x' "${decimalCode}") + local code="${hexCode}" + local char="\u${hexCode}" + + #echo "hexcode was $hexCode" + #echo -e "char was ${char}" + # fill in placeholder cells properly formatted: + if [ "${char}" = "\u0" ]; then + #echo "IN IF char was '$char'" + char=" " + code=" " + #else + #echo "IN ELSE char was '$char'" + fi + + allCodes+=" ${code} $bar" + allChars+=" ${char} $bar" + #echo -e "\ncount was $count" + counter=$((counter + 1)) + count=$(( (count + 1) % wrapAt)) + #echo -e "\ncount was $count" + #echo -e "\nwrap was $wrapAt" + #echo -e "\nwrap-1 was $((wrapAt - 1))" + #leftoverSpaces=$((wrapAt - count)) + if [[ $count -eq 0 ]]; then + #printf "║" + #echo -e "\ncount is at zero\n" + #echo -e "\nleftoversSpaces is $leftoverSpaces\n" if [[ "${currentColor}" = "${alternateBgColor}" ]]; then currentColor="${bgColor}" else currentColor="${alternateBgColor}" fi - allChars+="\n${currentColor}" + + allCodes+="${currentColor}" + allChars+="${currentColor}" + + printf "%s%b%b" "$bar" "$allCodes" "$reset_color" + printf "\n" + printf "%s%b%b" "$bar" "$allChars" "$reset_color" + printf "\n" + + #printf "counter is %s" "$counter" + + if [ "$counter" != "$sequenceLength" ]; then + printf "%s\n" $line + fi + + allCodes="" + allChars="" fi + done - printf "${allChars}${reset_color}" + printf "$bottomLine\n" + # print left-overs: + #leftoverSpaces=$((wrapAt - count)) + # printf "${allCodes}${reset_color}" + # printf "\n║${allChars}${reset_color}" + # printf "\n" + #printf "$bottomLine\n" + #printf "count was %s" $count + #printf "\nleftovers was %s" $leftoverSpaces + #printf "${allChars}${reset_color}" } function print-unicode-ranges() { - local count=0 + #local count=0 local arr=($@) - for ((i=0; i<=$#; i+=2)); do + local len=$# + #echo "len was $len" + for ((j=0; j