# Testing all available fonts

I need to display some very small numbers in my document (3-5 pt). I want to test out all available fonts within my installation at this size, to find which produces the most readable numbers. Is there a simple way to produce this output (i.e. generate a document which contains a sample text displayed in all fonts at the specified size)??

-
fonts available for latex ord lualatex/xelatex or both? – Herbert Nov 29 '11 at 11:43
I will award the bounty to an answer that works in XeTeX. When I first posted the question, I had not yet discovered XeTeX. – Village Nov 29 '11 at 12:41
You can get the font list with fc-list, see How to get a list of all available (TTF-) Fonts with XeTeX. – Marco Nov 29 '11 at 14:29
fc-list shows the open and true type fonts of the TeX system only with a special config file, eg the TeX Gyre fonts – Herbert Nov 29 '11 at 15:12
@Herbert What do you mean by special config file? The fonts have to ship another file to make it appear within fc-list? – Marco Nov 30 '11 at 10:11

The following ConTeXt/LuaTeX solution prints a pdf with all available fonts in the font size 4pt. Beware: It takes a long time to process and consumes lots of memory.

Edit: I replaced the ugly unix command dependency of cut with a lua solution.

\def\sample{Some Sample text\crlf}
\def\testfont#1{\definedfont[name:#1 at 4pt] #1: \sample}

\starttext

\executesystemcommand {mtxrun --script fonts --list --all --pattern=* > \jobname.filelist}
\startluacode
myfile = assert(io.open('\jobname.filelist', 'r'))
for line in myfile:lines() do
local first, second, third = line:match '(%S+)'
if first~= nil then
context('\\testfont{')
context(line)
context('}')
end
end
myfile:close()
\stopluacode

\stoptext


This is a screenshot of the first few fonts:

Edit:

Unfortunately there is no method for reading the database directly from within Lua (see: How do I get a list of all available fonts for luaotfload). You either have to use an external command or read in the database file (otlf-names.lua for LaTeX). Neither solution is optimal.

-
 Why do you say that there is no method of reading the database in lua? After all, mtx-fonts is a lua script, that uses fonts.name.load function defined in font-syn.lua to read the font database. In principle, you can just rewrite list_matches function of mtx-fonts to fit your needs. – Aditya Dec 2 '11 at 23:00 @Aditya I was referring to Khaled's comment to tex.stackexchange.com/q/14162/5245. I don't know of any way to read in the database without directly reading the database file or parsing external programs output. I'll have a look at the files you mentioned. Maybe I can come up with a better solution. Thanks for the pointers. – Marco Dec 3 '11 at 0:20