-
Notifications
You must be signed in to change notification settings - Fork 61
/
nerd-fonts-test.sh
executable file
·191 lines (152 loc) · 5.07 KB
/
nerd-fonts-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env bash
# Nerd Fonts Version: 3.0.2
# 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
# Is possible to change the number of columns passing a number as the first parameter (default=16):
# ./test-fonts.sh 8
# Given an array of decimal numbers print all unicode codepoint.
function print-decimal-unicode-range() {
local originalSequence=("$@")
local counter=0
# Use alternating colors to see which symbols extend out of the bounding
# box.
local bgColorBorder='\033[48;5;8m'
local bgColorCode='\033[48;5;246m'
local alternateBgColorCode='\033[48;5;240m'
local bgColorChar='\033[48;5;66m'
local alternateBgColorChar='\033[48;5;60m'
local underline='\033[4m'
local currentColorCode="${bgColorCode}"
local currentColorChar="${bgColorChar}"
local reset_color='\033[0m'
local allChars=""
local allCodes=""
local wrapAt=16
[[ "$wrappingValue" =~ ^[0-9]+$ ]] && [ "$wrappingValue" -gt 2 ] && wrapAt="$wrappingValue"
local topLineStart="${bgColorBorder}╔═══"
local topLineMiddle="═══╦═══"
local topLineEnd="═══╗${reset_color}"
local bottomLineStart="${bgColorBorder}╚═══"
local bottomLineMiddle="═══╩═══"
local bottomLineEnd="═══╝${reset_color}"
local lineStart="${bgColorBorder}╠═══"
local lineMiddle="═══╬═══"
local lineEnd="═══╣${reset_color}"
local bar="${bgColorBorder}║${reset_color}"
local originalSequenceLength=${#originalSequence[@]}
local leftoverSpaces=$((wrapAt - (originalSequenceLength % wrapAt)))
# add fillers to array to maintain table:
if [ "$leftoverSpaces" -lt "$wrapAt" ]; then
for ((c = 1; c <= leftoverSpaces; c++)); do
originalSequence+=(0)
done
fi
local sequenceLength=${#originalSequence[@]}
printf "%b" "$topLineStart"
for ((c = 2; c <= wrapAt; c++)); do
printf "%b" "$topLineMiddle"
done
printf "%b\\n" "$topLineEnd"
for decimalCode in "${originalSequence[@]}"; do
local hexCode
hexCode=$(printf '%x' "${decimalCode}")
local code="${hexCode}"
local char="\\U${hexCode}"
# fill in placeholder cells properly formatted:
if [ "${char}" = "\\U0" ]; then
char=" "
code=""
fi
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))
if [[ $count -eq 0 ]]; then
if [[ "${currentColorCode}" = "${alternateBgColorCode}" ]]; then
currentColorCode="${bgColorCode}"
currentColorChar="${bgColorChar}"
else
currentColorCode="${alternateBgColorCode}"
currentColorChar="${alternateBgColorChar}"
fi
printf "%b%b%b" "$bar" "$allCodes" "$reset_color"
printf "\\n"
printf "%b%b%b" "$bar" "$allChars" "$reset_color"
printf "\\n"
if [ "$counter" != "$sequenceLength" ]; then
printf "%b" "$lineStart"
for ((c = 2; c <= wrapAt; c++)); do
printf "%b" "$lineMiddle"
done
printf "%b\\n" "$lineEnd"
fi
allCodes=""
allChars=""
fi
done
printf "%b" "$bottomLineStart"
for ((c = 2; c <= wrapAt; c++)); do
printf "%b" "$bottomLineMiddle"
done
printf "%b\\n" "$bottomLineEnd"
}
function print-unicode-ranges() {
echo ''
local arr=("$@")
local len=$#
local combinedRanges=()
for ((j=0; j<len; j+=2)); do
local start="${arr[$j]}"
local end="${arr[(($j+1))]}"
local startDecimal=$((16#$start))
local endDecimal=$((16#$end))
# shellcheck disable=SC2207 # We DO WANT the output to be split
combinedRanges+=($(seq "$startDecimal" "$endDecimal"))
done
print-decimal-unicode-range "${combinedRanges[@]}"
}
function test-fonts() {
echo "Nerd Fonts - Pomicons"
print-unicode-ranges e000 e00d
echo; echo
echo "Nerd Fonts - Powerline"
print-unicode-ranges e0a0 e0a2 e0b0 e0b3
echo; echo
echo "Nerd Fonts - Powerline Extra"
print-unicode-ranges e0a3 e0a3 e0b4 e0c8 e0cc e0d2 e0d4 e0d4
echo; echo
echo "Nerd Fonts - Symbols original"
print-unicode-ranges e5fa e62b
echo; echo
echo "Nerd Fonts - Devicons"
print-unicode-ranges e700 e7c5
echo; echo
echo "Nerd Fonts - Font awesome"
print-unicode-ranges f000 f2e0
echo; echo
echo "Nerd Fonts - Font awesome extension"
print-unicode-ranges e200 e2a9
echo; echo
echo "Nerd Fonts - Octicons"
print-unicode-ranges f400 f4a8 2665 2665 26A1 26A1 f27c f27c
echo; echo
echo "Nerd Fonts - Font Logos"
print-unicode-ranges f300 f32f
echo; echo
echo "Nerd Fonts - Font Power Symbols"
print-unicode-ranges 23fb 23fe 2b58 2b58
echo; echo
echo "Nerd Fonts - Material Design Icons (first few)"
print-unicode-ranges f0001 f0010
echo; echo
echo "Nerd Fonts - Weather Icons"
print-unicode-ranges e300 e3eb
echo; echo
}
wrappingValue="$1"
test-fonts