Skip to content

Instantly share code, notes, and snippets.

@bfrg
Created June 5, 2022 13:02
Show Gist options
  • Save bfrg/c0626560a94810b53c5c56e0422fb8ea to your computer and use it in GitHub Desktop.
Save bfrg/c0626560a94810b53c5c56e0422fb8ea to your computer and use it in GitHub Desktop.
Print the characters a font provides
#!/bin/bash
#
# Print all characters a font provides
#
# Example:
# $ ls-chars devicon
#
# Note:
# \U in printf is not POSIX standard, therefore we need bash
#
# See also:
# $ fc-query my-font.ttf
#
# From:
# https://stackoverflow.com/questions/4458696/finding-out-what-characters-a-given-font-supports
#
for range in $(fc-match --format='%{charset}\n' "$1"); do
for n in $(seq "0x${range%-*}" "0x${range#*-}"); do
printf "%04x\n" "$n"
done
done | while read -r n_hex; do
count=$((count + 1))
printf "%-5s\U$n_hex\t" "$n_hex"
[ $((count % 10)) = 0 ] && printf "\n"
done
printf "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment