Create a font table for all available characters for a particular font

Similar to the question:

Lualatex: Font table with examples

I have several ornamental fonts and I'd like to create key maps. That is, I want to know what symbol the letter a maps to by having a nice table. The problem is, many of these fonts don't include all the characters and I don't know, a priori, which ones are included. I'd rather not have a mess of empty boxes filling up the table. Is it possible to iterate through the valid characters in a font and just display them? Any (Lua, Con, Xe, La, etc...)-Tex solution is welcome.

-

can be done with luatex. \OD is the font face of the ornament font

\documentclass[a5paper]{article}
\usepackage{luacode}
\usepackage[margin=0.5cm]{geometry}
\usepackage{fontspec}
\usepackage{multicol}
\setlength{\columnsep}{0.3cm} \setlength{\columnseprule}{1pt}
\setmainfont{Linux Libertine O}

\newfontface\OD{OrnamentalDecoration.otf}
\begin{document}

\begin{multicols}{4}\noindent
\begin{luacode*}
local glyphs = {}
for i = 0, f.glyphmax - 1 do
local g = f.glyphs[i]
if g then
table.insert(glyphs, {name = g.name, unicode = g.unicode})
end
end
table.sort(glyphs, function (a,b) return (a.unicode < b.unicode) end)
for i = 1, #glyphs do
tex.sprint(glyphs[i].unicode .. ": ")
if (glyphs[i].unicode > 0) then
tex.sprint("{\\OD\\char" .. glyphs[i].unicode .. "}");
end
tex.print(" {\\small(")
tex.print(-2, glyphs[i].name )
tex.sprint(')}\\\\')
end
\end{luacode*}
\end{multicols}

\end{document}


-
Just so I understand, the check is in (glyphs[i].unicode > 0)? Great work, this is perfect! –  Hooked Feb 18 '13 at 19:18
This is much nicer than my code in tex.stackexchange.com/questions/98188/… –  Charles Stewart Feb 18 '13 at 19:19
@Hooked: and also if g then ...  –  Herbert Feb 18 '13 at 19:20
In ConTeXt you can use the fnt-10 module to display a list of the glyphs of a particular font. See also my answer to “Accessing font ornaments” for a more detailed description of how to use the symbols.
\usemodule [fnt-10]