Looking at the answer to the question here, it is very close to what I wanted. What I wanted is to create font table with samples for font files that are not system installed or in TEXMF trees, but font files that reside in a path or on CD (no sub-folders, just the current folder will do).
I am still learning and appreciate your help!
Using MiKTeX 2.9 and Windows 7, with LuaLaTeX.
EDIT:
Inspired by Taco
's answer, I have come out with the following (modified from Leo's Code):
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Latin Modern Mono Light}
\usepackage{luacode}
\usepackage[margin=18mm]{geometry}
\parindent=0pt
\usepackage{longtable,makecell}
\renewcommand\arraystretch{2}
\begin{document}
\begin{luacode}
teststring = "0123456789 ABCDEFabcdef"
tex.print(-2, os.getenv('FONTSPEC'))
tex.print('\\\\')
tex.print("\\begin{longtable}{ll}\\hline")
for i,v in ipairs(dir.glob(os.getenv('FONTSPEC'))) do
-- get rid of './' in front of filenames, fontspec don't like that
local f = string.gsub(v, "^./", "")
-- font name
local info = fontloader.info(v)
tex.print('\\makecell[l]{\\bfseries')
tex.print(-2, info.fontname) -- font name here
tex.print('\\\\[-1ex] \\scriptsize')
tex.print(-2, f) -- filename
tex.print('} & \\large\\fontspec{')
tex.print(-2, f)
tex.print('}')
tex.print(teststring)
tex.print('\\\\ \\hline')
end
tex.print("\\end{longtable}")
\end{luacode}
\end{document}
It utilises an environment variable, FONTSPEC
to specify the font files search pattern, eg. *.ttf
for TrueType files in the current directory. Note that the TEX file needs to be at the same directory where the font files is and the glob pattern is CASE SENSITIVE!
Sample run:
set FONTSPEC=*.ttf
lualatex fontsampler.ltx
Result: