-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfontcharlist.sh
More file actions
39 lines (32 loc) · 771 Bytes
/
Copy pathfontcharlist.sh
File metadata and controls
39 lines (32 loc) · 771 Bytes
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
#!/bin/bash -
# Source: https://unix.stackexchange.com/a/595816
# To get a list of characters in a font:
# ./fontcharlist.sh /fontdir/font
Usage() {
echo "$0 FontFile"
exit 1
}
SayError() {
local error=$1
shift
echo "$0: $@"
exit "$error"
}
[ "$#" -ne 1 ] && Usage
width=70
fontfile="$1"
[ -f "$fontfile" ] || SayError 4 'File not found'
list=$(fc-query --format='%{charset}\n' "$fontfile")
for range in $list; do
IFS=- read start end <<< "$range"
if [ "$end" ]; then
start=$((16#$start))
end=$((16#$end))
for ((i = start; i <= end; i++)); do
printf -v char '\\U%x' "$i"
printf '%b' "$char"
done
else
printf '%b' "\\U$start"
fi
done | grep -oP '.{'"$width"'}'