LaTeX fonts: 73 PDF and JPG samples

Introduction
I had a friend ask me to find an alternative font for him to use in LaTeX. I first tried to trawl Google, but only found dated and incomplete pages, so I decided to sample a ton of fonts so he could choose for himself. My friend was running Ubuntu Linux which uses TeX Live and Ubuntu comes with two texlive-fonts packages in the repositories: texlive-fonts-extra and texlive-fonts-recommended. So the first thing I did was to create lists of the fonts in these packages:

aptitude show texlive-fonts-extra | grep " -- " | awk '{print $1}' > texlive-fonts-extra
aptitude show texlive-fonts-recommended | grep " -- " | awk '{print $1}' > texlive-fonts-recommended.txt

This provided 121 fonts for texlive-fonts-extra and 24 for texlive-fonts-recommended.

Automating the font sampling
To automate the font sampling I made a template LaTeX document, where I used the standard dummy text of typesetting: Lorem Ipsum and small equation to see math font in use. The LaTeX template is slightly shortened compared to the version in the downloads.

\documentclass[11pt]{article}
%placeholder
\begin{document}
 
\section*{Lorem ipsum dolor sit amet}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna orci,
commodo eget sollicitudin id, commodo vitae erat. Pellentesque eu dapibus arcu.
Cras tristique, lectus at porta porttitor, enim tellus pulvinar turpis,
pulvinar fringilla elit erat sed sem. Suspendisse elit velit, iaculis id
adipiscing in, convallis et lectus. 
 
\begin{displaymath}
{\left( \frac{\partial}{\partial x}{\left(\frac{\partial g\left(x,y\right)}{\partial y}\right)}_x \right)}_y = 
{\left(\frac{\partial}{\partial y}{\left(\frac{\partial g\left(x,y\right)}{\partial x}\right)}_y \right)}_x
\end{displaymath}
 
\section*{Nullam ac gravida ante}
Nullam ac gravida ante. Ut consequat, arcu vel sodales pharetra, ante nibh
rhoncus justo, pulvinar gravida lorem nunc ut augue. Nullam nec diam libero,
eget aliquam augue. 
\end{document}

Now to the script to automate it all. First the script replaces %placeholder with \usepackage{fontname}, then document is compiled using pdflatex, the pdf is convert to a image using ImageMagick and finally a bit of cleaning. The script reads the list of fonts to use from the file texlive-working-fonts.txt which contains the 73 fonts compiled flawlessly in the two lists compiled earlier. texlive-working-fonts.txt is included in the downloads below.

#!/bin/bash
 
# Times like fonts 
#fonts="times mathptmx pslatex newcent palatino lmodern"
 
if [ ! -d PDFS ]; then
    mkdir PDFS
fi
if [ ! -d JPGS ]; then
    mkdir JPGS
fi
 
for font in $(cat texlive-working-fonts.txt); do
    if [ ! -e PDFS/font-$font.pdf ]; then
        echo "### Creating $font"
        if [ $font = "standardlatex" ]; then
            sed "s/%placeholder//g" document.tex > font-$font.tex
        else
            sed "s/%placeholder/\\\usepackage\{$font\}/g" document.tex > font-$font.tex
        fi
    	pdflatex font-$font.tex
        convert font-$font.pdf font-$font.jpg
        mv font-$font.pdf PDFS/
        mv font-$font.jpg JPGS/
        rm -f font-$font.tex font-$font.log font-$font.aux
    else
        echo "### PDF for font: $font already exist"
    fi
done

Running the script return two folders: a folder containing PDF’s of all the 73 fonts and a folder called JPGS containing all the JPG’s. Below is a sample of 6 of the fonts – the full monty can be found in the downloads.


Download
A minimal download containg only the bash-script, the template LaTex document and the lists of fonts:
latex-font-test.zip (3 kB)
latex-font-test.tar.gz (2.2 kB)

A full download all files along with PDF and JPEG versions of document using 73 different fonts.
latex-font-test-with-pdfs-and-jpgs.zip (8.1 MB)
latex-font-test-with-pdfs-and-jpgs.tar.gz (8.2 MB)

Only registered users can comment.

  1. This was a great idea! Thanks for sharing the script and the output.

    However, I notice that a lot of the fonts actually look the same. Several fonts need more than just \usepackage{fontname}. For example, to see the result of Inconsolata, you would need to add \renewcommand*\familydefault{\ttdefault} or add some \textt text, and to see Trajan, you need to add \trjnfamily and have a sequence of upper-case letters.

    I’ll see if I can add to your script to see the output of more fonts.

Leave a Reply