Renders the output of fc-cat as valid JSON. The fc-cat binary is likely already on your system, as part of the fontconfig package.
Maybe there are other/better tools that already do this, but I did it for the challenge. In particular, figuring out how to create valid JSON, since trailing commas aren't allowed.
GIST='https://gist.githubusercontent.com/ernstki/d3094c51e92383ff5a607c61f50019c7/raw/fc-json'
mkdir -p ~/bin
(curl $GIST || wget -O- $GIST) > ~/bin/fc-json
chmod a+x ~/bin/fc-json
# make sure it works (if not, try logging out and back in)
fc-json | headMost modern Unices will add ~/bin to your search path on login (if it exists), but if not, assuming the Bash shell:
dotprofile=~/.$([[ -f ~/.bash_profile ]] && echo bash_)profile
echo '
# add ~/bin/to my search path
export PATH="$HOME/bin:$PATH"' >> $dotprofilefc-json | jq -SC . | less -R
# list all fonts which do not include `en` language
fc-json | jq -r '.[] | select(.lang?|index("en")|not) | .fullname'- Fontconfig Developers Reference, heading "FONT PROPERTIES" - freedesktop.org
- ISO 639.2 "Codes for the Representation of Names of Languages" - loc.gov
- can convert to JSON, CSV, or tab-delimited with this trick
curl -sS https://www.loc.gov/standards/iso639-2/php/English_list.php \ | pup 'table tbody tr td table tr json{}' \ | jq -r 'map(.children | map(.text))[] | @tsv'
- can convert to JSON, CSV, or tab-delimited with this trick
MIT.