How to get a list of all available (TTF-) Fonts with XeTeX?

5.5k views Asked by At

Very neat that I can use any available TrueType font on my Windows machine with MikTex and XeTeX.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[]{article}
\usepackage{xltxtra,fontspec,xunicode}
\defaultfontfeatures{Scale=MatchLowercase}
\title{Fonttest}   
\begin{document} 
  \section{Section Title} {
    \setromanfont{Palatino Linotype}
      The quick brown fox jumps over the lazy dog.
  }
  \section{Section Title} {
    \setromanfont{ProggyCleanTTSZBP}
      The quick brown fox jumps over the lazy dog.
  }
\end{document}

Is there a way to automatically generate a font test page for every available font? So that I do not have to type a test page for every available font by hand?

Actually, I do not even know how to get to the Long Font Name required for \setromanfont -- short of typing it from the screen. The Windows directory only lists the file names, obviously. Maybe this can be done in TeX itself, but I could manage it with a Python script or such like.

3

There are 3 answers

0
Philipp On BEST ANSWER

Not a worked out answer, but an idea. All you have to do is iterate over all installed font families, for which an API function exists: EnumFontFamiliesEx.

0
samcarter_is_at_topanswers.xyz On

A two-step-approach

1. Building list of available fonts

For this one can use albatross, a command line tool included in tex distributions like texlive. It is designed to find fonts which include certain glyphs, e.g. if you want to typeset a text in English, you can use something like

 albatross -b 3 T h e

(replace T h e with whatever glyphs your font should be able to typeset)

This will give you a list of font names

2. Producing a test page

You can take the list of font names produced in step 1 and let latex iterate over them

% !TeX TS-program = xelatex

\documentclass{article}

\usepackage{pgffor}
\usepackage{fontspec}
\newcommand{\testphrase}{The quick brown fox jumps over the lazy dog.}

\begin{document}

\foreach \x in {
  Adobe Caslon Pro, 
  Adobe Garamond Pro,
  % many more fonts here
  Zapfino}{
  \section{\x}
  \begingroup
    \setmainfont{\x}
    \testphrase
  \endgroup
}
\end{document}

enter image description here

1
gombok On
fc-list  | cut -d\  -f2-99 | cut -d: -f1 | sort -u