23

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)??

8
  • fonts available for latex ord lualatex/xelatex or both?
    – user2478
    Commented Nov 29, 2011 at 11:43
  • 1
    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
    Commented Nov 29, 2011 at 12:41
  • 1
    You can get the font list with fc-list, see How to get a list of all available (TTF-) Fonts with XeTeX.
    – Marco
    Commented Nov 29, 2011 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
    – user2478
    Commented Nov 29, 2011 at 15:12
  • 2
    Is there a LaTeX (pdflatex) solution? Commented Jul 5, 2014 at 21:48

1 Answer 1

15
+50

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:

result

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.

7
  • 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
    Commented Dec 2, 2011 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
    Commented Dec 3, 2011 at 0:20
  • I'm trying to implement this code to create a font catalog of our available fonts. However, I have more than 6000 fonts available, and ConTeXt runs out of node memory very soon. I read here that there is no real way (or need) of increasing the node memory; that if you ran out of node memory is because your code is wrong. Is there any way of doing this over a big database of fonts (say, more than 5000 font files)?
    – El Andi
    Commented Jul 22, 2013 at 23:38
  • @ElAndi I just ran the code on a font library of about 5800 fonts and it seemed to work fine. Are you sure you're not just running out of memory? Loading the font cache consumed almost 18GiB of RAM here.
    – Marco
    Commented Jul 23, 2013 at 2:07
  • 3
    May I ask for a complete file? Embedding this into my latex file causes ! Undefined control sequence. l.14 \starttext and searches don't clarify what this belongs to. (running lualatex)
    – qubodup
    Commented Oct 8, 2016 at 0:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .