答案1
我现在根据讨论找到了解决方案这里这适用于我用 FontLab 8 创建的字体,但不适用于示例字体名称cambriai.ttf
。 结合以下代码,可以完成链接字形表以打印字体中的所有字形),但正如我所说,由于某种原因它不适用于其他字体,cambriai.ttf
但可以适用于其他字体...
\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}
这是链接答案中的修补字形表,现在也可以打印没有代码点值的字形:
\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}