Skip to content

Instantly share code, notes, and snippets.

@ben-cohen
Created August 23, 2020 17:13
Show Gist options
  • Save ben-cohen/314cab3954c39333281bffc43cee6df7 to your computer and use it in GitHub Desktop.
Save ben-cohen/314cab3954c39333281bffc43cee6df7 to your computer and use it in GitHub Desktop.
Use XeLaTeX to create a sampler for each of the fonts available to the local system
#!/bin/bash
#
# fontlist.sh: Create a XeLaTeX document giving samples for each of the fonts
# available to the local system from fc-list, and run XeLaTeX on it ignoring
# errors.
#
# Ben Cohen, August 2020.
#
OUTFILE=fontlist.tex
cat > $OUTFILE <<-EOF
\\documentclass{article}
\\usepackage{fontspec}
\\usepackage[english]{babel}
\\usepackage{blindtext}
\\usepackage{xltxtra}
\\title{Samples of locally available fonts in \\XeLaTeX}
\\begin{document}
\\maketitle
EOF
IFS=$'\n'
for i in $(fc-list :outline -f "%{family}\n" | grep -o "^[^,]*" | grep -v "_")
do
cat >> $OUTFILE <<-EOF
\\setmainfont{$i}
\\section*{$i \\texttt{($i)}}
\\blindtext
EOF
done
cat >> $OUTFILE <<-EOF
\\end{document}
EOF
echo R | xelatex $OUTFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment