为特定字体的所有可用字符创建字体表

为特定字体的所有可用字符创建字体表

类似问题:

Lualatex:带有示例的字体表

我有几种装饰字体,我想创建键映射。也就是说,我想知道字母a通过一个漂亮的表格来了解字母映射到哪个符号。问题是,许多这些字体并不包含所有字符,我不知道,先验,哪些是包含的。我不希望桌子上堆满一堆空盒子。是否可以遍历有效的字体中的字符并只显示它们?欢迎任何(Lua、Con、Xe、La 等...)-Tex 解决方案。

答案1

可以用 来完成luatex\OD是装饰字体的字体(TeX 级别上需要)

\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 f = fontloader.open('OrnamentalDecoration.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 .. "}");
   end
   tex.print(" {\\small(")
   tex.print(-2, glyphs[i].name )
   tex.sprint(')}\\\\')
end
fontloader.close(f)
\end{luacode*}
\end{multicols}

\end{document}

在此处输入图片描述

答案2

在 ConTeXt 中,您可以使用fnt-10模块显示特定字体的字形列表。另请参阅我对“访问字体装饰”的回答以获得有关如何使用符号的更详细描述。

\usemodule [fnt-10]
\starttext
    \ShowCompleteFont{name:minionproregular}{10pt}{1}
\stoptext

结果

相关内容