Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

luaotfload uses an internal database that gets updated with mkluatexfontdb. So it knows about a lot of fonts installed on my computer. How can I query this database? Something like

luatexfontdb --list-fonts-on-my-computer-that-are-in-your-database

?

share|improve this question
2  
No, there aren't, it is on the, not written, todo list, but don't hold your breath. –  Khaled Hosny Mar 31 '11 at 16:25

2 Answers 2

up vote 22 down vote accepted

You could open the database in your editor. It is called otfl-names.lua and should be in one of your texmf-trees in \luatex-cache\generic\names.

It is also not very difficult to make lists based on otfl-names.lua. E.g.

\documentclass{article}
\usepackage{luacode,luaotfload}
\begin{document}
\begin{luacode}
myfonts=dofile(fonts.names.path.localdir..'/otfl-names.lua')

for i,v in ipairs(myfonts.mappings) do
 tex.print(-2, v.familyname)
 tex.print(', ')
 tex.print(-2, v.fontname)
 tex.print('\\par')
end

\end{luacode}

\end{document}

Edit in may 2013: With a newer luaotfload (as the one in TL2013 (pretest) one should exchange the myfonts line by this one as the name of the database as changed:

 myfonts=dofile(fonts.names.path.path)

Edit

I tried again in TL 2014 (june 2014). Now the names file is in a .luc and the access name has changed again. I also added some "if exist code" to avoid error if a table entry doesn't exist for a font:

\documentclass{article}
\usepackage{luacode}
\usepackage{luaotfload}
\begin{document}
\begin{luacode}
myfonts=dofile(fonts.names.path.index.luc)

tex.sprint(fonts.names.path.index.luc)

---[[
for i,v in ipairs(myfonts.mappings) do
 if v.familyname then
 tex.print(-2, v.familyname)
 end
 if v.fontname then 
 tex.print(', ')
 tex.print(-2, v.fontname)
 end
 tex.print('\\par')
end
--]]

\end{luacode}

\end{document}
share|improve this answer
1  
I think this is the best way to generate a font list at the moment, as there seems to be no tool like fc-list doing this job yet - see this newsgroup entry. –  diabonas Mar 24 '11 at 16:31
    
On my Windows box with MiKTex 2.9, this code triggered warnings about missing math mode delimiters, causing lualatex to insert four $ characters . Wrapping the string printed by tex.print within a verbatim block silenced that warning, although I don't spot which fonts triggered it. –  RBerteig Mar 24 '11 at 22:02
    
The obvious suspects are fonts with underscores in their name so setting its catcode to e.g. 12 should help. –  Ulrike Fischer Mar 25 '11 at 8:31
1  
@RBerteig, @Ulrike: You can use something like tex.tprint({-2, v.familyname, ', ', v.fontname},{-1, '\\par'}) to get rid of the catcodes problem. –  topskip Mar 30 '11 at 13:22
1  
@LarsH The name has changed. It is now called luaotfload-names.lua. And it is in texmf-var. (I didn't test if the code above still work. It is quite possible that the structure of the tables has changed too.) –  Ulrike Fischer Nov 4 '13 at 16:40

Based on Ulrike's answer:

Because I don't want to create a TeX document every time I need the font list, here is a simple script for that:

#!/usr/bin/env texlua

kpse.set_program_name("listluatexfonts")

cachefile  = kpse.expand_var("$TEXMFVAR")  .. "/luatex-cache/generic/names/otfl-names.lua"
fontlist = dofile(cachefile)
assert(fontlist,"Could not load font name database")

local tmp = {}

for _,font in ipairs(fontlist.mappings) do
  tmp[#tmp + 1] = font.fontname
end
table.sort(tmp)

for _,fontname in ipairs(tmp) do
  print(fontname)
end

call it with

./listluatexfonts
share|improve this answer
    
Can anyone tell how to do this with TeXLive 2013? There doesn't appear to be a generic directory under luatex-cache anymore... at least not in my installation. –  LarsH Sep 20 '13 at 18:58
    
OK, those folders may be specific to LuaLaTeX. See comment discussion with Ulrike. –  LarsH Nov 4 '13 at 18:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.