Last active
July 28, 2023 20:29
-
-
Save airvzxf/e3e01aa9959e2640d8c63344bbfe6d47 to your computer and use it in GitHub Desktop.
Given a font, it will display all the character sets it contains.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Thanks for this code Lu Xu. | |
# https://stackoverflow.com/a/60475015/1727383 | |
# Make this file executable. | |
# chmod u+x ls-chars.bash | |
# Usage: | |
# ./ls-chars.bash "FontAwesome" | |
# Check the list of installed fonts. | |
# fc-match --all | grep --color=always -ins awesome | |
# It needs the package: 'fontconfig'. | |
# Output the hexadecimal value of the character. | |
# printf "%06X\n" \"\" | |
# Inverse operation: | |
# echo "\UF2DC " | |
count=0 | |
for range in $(fc-match --format='%{charset}\n' "${1}"); do | |
for n in $(seq "0x${range%-*}" "0x${range#*-}"); do | |
printf "%05x\n" "${n}" | |
done | |
done | while read -r n_hex; do | |
count=$((count + 1)) | |
printf "%-6s\U${n_hex} | " "${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