= Fonts and Unicode characters
== List all characters in font
=== ttx
$ sudo apt install fonttools
$ ttx -t cmap -o - /usr/share/fonts/truetype/Arial/arial.ttf
Dumping "/usr/share/fonts/truetype/Arial/arial.ttf" to "-"...
Dumping 'cmap' table...
...
$ ttx -t cmap -o - /usr/share/fonts/truetype/Arial/arial.ttf \
| perl -C -ne '/ code="0x(.*?)"/ && printf "%04s %s\n", $1, chr(hex $1)'
Dumping "/usr/share/fonts/truetype/Arial/arial.ttf" to "-"...
Dumping 'cmap' table...
0020
0021 !
0022 "
0023 #
0024 $
0025 %
0026 &
0027 '
0028 (
0029 )
...
fef4 ﻴ
fef5 ﻵ
fef6 ﻶ
fef7 ﻷ
fef8 ﻸ
fef9 ﻹ
fefa ﻺ
fefb ﻻ
fefc ﻼ
fffc 
=== otfinfo
* [[https://unix.stackexchange.com/a/247114/7286|How to find out which unicode codepoints are defined in a TTF file?]]
* [[https://unix.stackexchange.com/questions/595756/how-to-list-all-supported-glyphs-of-a-given-font|How to list all supported glyphs of a given font]]
# sudo apt install lcdf-typetools
# or on Mac
# brew install lcdf-typetools
$ otfinfo -u /usr/share/fonts/truetype/Arial/arial.ttf | head
uni0020 3 space
uni0021 4 exclam
uni0022 5 quotedbl
uni0023 6 numbersign
uni0024 7 dollar
...
uniFEF9 1017 afii62838
uniFEFA 1018 afii62839
uniFEFB 1019 afii62840
uniFEFC 1020 afii62841
uniFFFC 863 uniFFFC
uniFFFF 0 .notdef
=== Perl Font::FreeType
* https://stackoverflow.com/a/15905540/111036
$ sudo apt install libfont-freetype-perl
$ perl -C -MFont::FreeType -e 'Font::FreeType->new->face(shift)->foreach_char( sub {
$c=$_->char_code(); printf "%04X %s\n", $c, chr($c);
} );' /usr/share/fonts/truetype/Arial/arial.ttf
0020
0021 !
0022 "
0023 #
0024 $
0025 %
0026 &
0027 '
...
FEFA ﻺ
FEFB ﻻ
FEFC ﻼ
FFFC 
== List characters in file
[[https://superuser.com/questions/377793/view-unicode-codepoints-for-all-letters-in-file-on-bash|View unicode codepoints for all letters in file on bash]]
file="some-file.txt"
perl -C -ne 'for (split //) {printf "U+%04X %s\n", ord, $_}' "$file" | sort -u
iconv -f utf8 -t utf32le "$file" | hexdump -v -e '"U+%04X\n"' | sort -u
while IFS= read -d $'\000' -n 1 x; do printf 'U+%04X %s\n' "'$x" "$x"; done < "$file" | sort -u
== List installed fonts having specific character