I now found a solution based on the discussion here that works for my font created with FontLab 8, but not with the example font name cambriai.ttf.
Together with the following code, the linked glyph table can be completed to print all glyphs in the font), but as I said, for some reason it does not work with cambriai.ttf but with others it works...
\documentclass[a4paper]{article}
\usepackage{fontspec}
\begin{document}
\setmainfont{my_fontname.otf}
% the following line prints the glyph with the glyph name S_t that has no code point value assigned (codepoint value = -1). It seems that it does not work with cambriai.ttf but with a OTF-font created by FontLab 8 (maybe otf only solution?)
\char\directlua{tex.print(luaotfload.aux.slot_of_name(font.current(), [[S_t]])) }
\end{document}
Here is the patched glyph table from the linked answer that is now able to also print glyphs which don't have a codepoint value:
\documentclass[a4paper]{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{my_fontname.otf}
\begin{document}
\begin{multicols}{4}\noindent
\begin{luacode*}
local f = fontloader.open('my_fontname.otf')
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 .. "}");
else
-- Here the updated code: the first glyph table in LuaTeX printing ALL glyphs in a font!
tex.sprint("{\OD\char\directlua{tex.print(luaotfload.aux.slot_of_name(font.current(), [[" .. glyphs[i].name .. "]]))}}")
end
tex.print(" {\small(")
tex.print(-2, glyphs[i].name )
tex.sprint(')}\\')
end
fontloader.close(f)
\end{luacode*}
\end{multicols}
\end{document}
cambriai.ttf. WithunicodefonttableI get a smaller table than with the linked code, because it ignores the-1values completely, but that's exactly the interesting ones. Such a table that only works over code point values can't solve the problem of showing all glyphs in a font. – Guest Nov 18 '22 at 17:38