I wanted to create a table of the fonts on my machine with short examples of each. So I got the function below and tried to modify to print the font in its typeface. (LuaLatex)
\documentclass[10pt,a4paper]{article}
\usepackage{fontspec}
\usepackage{luacode,luaotfload,luatextra}
\usepackage[margin=18mm]{geometry}
\begin{document}
\begin{luacode}
myfonts=dofile(fonts.names.path.localdir..'/otfl-names.lua')
--tex.print('\\begin{verbatim}\\par')
for i,v in ipairs(myfonts.mappings) do
--tex.print('\\fontspec{' .. v.fontname .. '}') % most recent attempt
--tex.print('\\setmainfont{' .. v.fontname .. '}') % first attempt
tex.print(v.familyname..', '..v.fontname..'\\par')
end
--tex.print('\\end{verbatim}\\par')
\end{luacode}
\end{document}
Both of the commented lines does not work (fontspec or setmainfont).
How should go about doing this with lua?
Best Answer
This improves Caramdir's answer to make the table easier to read: