Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 508
towi Avatar asked Feb 24 '11 19:02

towi


People also ask

How do I get Times New Roman font in LaTeX?

Setting fonts for different LaTeX elements\setromanfont{Times New Roman} This is the normal font used in most of the document, Times New Roman in the example. The elements that require a sans font, explicitly declared by the \ssfamily in the example, will be typeset with Arial font.

How do I change the font in LaTeX overleaf?

Changing default font typeface The font can also be changed for a specific element in the document. The command \fontfamily{qcr}\selectfont will set the TeX gyre cursor font typeface, whose fontcode is qcr , for the text inside the braces.


2 Answers

fc-list  | cut -d\  -f2-99 | cut -d: -f1 | sort -u
like image 52
gombok Avatar answered Sep 19 '22 00:09

gombok


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

like image 30
samcarter_is_at_topanswers.xyz Avatar answered Sep 18 '22 00:09

samcarter_is_at_topanswers.xyz