我想从 TeX 源制作一个外观整洁的 PDF 文档。TeX 文件主要是 ASCII 文本,带有少量非 ASCII 符号(方案中的箭头、标记列表项的自定义项目符号、致谢部分贡献者姓名中的象形文字等)。
反过来,TeX 源是由 Sphinx 根据第一个源构建的。
非 ASCII 符号不会打印在输出 PDF 中,因为整个文档默认使用的字体中没有它们的字形。
因此,我编写了一个 shell 脚本,扫描 TeX Live 安装目录中的 .pfb、.otf 和 .ttf 文件,并为找到的每种字体创建如下 TeX 文档:
\documentclass{article}
\usepackage[english]{babel}
\usepackage{fontspec}
\usepackage{multido}
\font\testedfont="[/usr/share/texlive/texmf-dist/fonts/type1/wadalab/dgj/dgjkj.pfb]"
\font\basictextfont="cmr10"
\title{Find glyph for Unicode 80A5 in dgjkj.pfb}
\begin{document}
\newcounter{glyphslotnum}
\newcommand\findglyphslotnum{}
\newcounter{totalglyphnum}
\newcommand\findtotalglyphnum{}
Test glyphs
{\basictextfont{Font filename: dgjkj.pfb}}
\testedfont
\renewcommand\findglyphslotnum{\the\XeTeXcharglyph"80A5}
\setcounter{glyphslotnum}{\findglyphslotnum}
\renewcommand\findtotalglyphnum{\the\XeTeXcountglyphs\testedfont}
\setcounter{totalglyphnum}{\findtotalglyphnum}
%\multido{\i=0+1}{\value{totalglyphnum}\relax}{
%{\basictextfont\i:\,}{\testedfont\XeTeXglyph\i}
%}
\basictextfont
dgjkj.pfb: total \number\value{totalglyphnum} glyphs
\ifnum\value{glyphslotnum}>0{\message{Glyph for 80A5 exists in dgjkj.pfb (slot \number\value{glyphslotnum})}Glyph for Unicode 80A5 exists in dgjkj.pfb at slot \number\value{glyphslotnum}.
It looks like [{\testedfont\XeTeXglyph\value{glyphslotnum}}] (by $\backslash$XeTeXglyph)
or [{\testedfont{\char"80A5}}] (by $\backslash$char)
or [{\testedfont{\symbol{"80A5}}}] (by $\backslash$symbol)
}\fi
\end{document}
它给出如下输出(复制此处:dgjkj.pfb_U80A5.jpg):
取消注释多重循环将提供字体中所有字形的列表。
我找到了具有我需要的所有 Unicode 符号的字形的字体,但我对符号 U279C(“粗圆头向右箭头”)有问题。它是在字体文件 fonts/type1/urw/zapfding/uzdr.pfb 中找到的(编译时打印消息“uzdr.pfb(插槽 168)中存在 279C 的字形”),但构建 PDF 失败并出现错误,完整输出如下:
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./find_glyph_pfb_uzdr.tex
LaTeX2e <2017-04-15>
Babel <3.17> and hyphenation patterns for 3 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty
(/usr/share/texlive/texmf-dist/tex/generic/babel/switch.def)
(/usr/share/texlive/texmf-dist/tex/generic/babel-english/english.ldf
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.def
(/usr/share/texlive/texmf-dist/tex/generic/babel/switch.def)
(/usr/share/texlive/texmf-dist/tex/generic/babel/xebabel.def
(/usr/share/texlive/texmf-dist/tex/generic/babel/txtbabel.def)))))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def))
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/tuenc.def))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/share/texlive/texmf-dist/tex/latex/multido/multido.sty
(/usr/share/texlive/texmf-dist/tex/generic/multido/multido.tex
v1.42, 2010/05/14 <tvz>))
No file find_glyph_pfb_uzdr.aux.
Glyph for 279C exists in uzdr.pfb (slot 168) [1] (./find_glyph_pfb_uzdr.aux)
xdvipdfmx:fatal: pdf_ref_obj(): passed invalid object.
Output file removed.
)
Error 256 (driver return code) generating output;
file find_glyph_pfb_uzdr.pdf may not be valid.
Transcript written on find_glyph_pfb_uzdr.log.
完整日志可以在这里找到:查找_glyph_pfb_uzdr.log。
所以,问题是 - 我应该怎么做才能打印该字形?
更新:失败的 TeX 文档:
\documentclass{article}
\usepackage[english]{babel}
\usepackage{fontspec}
\usepackage{multido}
\font\testedfont="[/usr/share/texlive/texmf-dist/fonts/type1/urw/zapfding/uzdr.pfb]"
\font\basictextfont="cmr10"
\title{Find glyph for Unicode 279C in uzdr.pfb}
\begin{document}
\newcounter{glyphslotnum}
\newcommand\findglyphslotnum{}
\newcounter{totalglyphnum}
\newcommand\findtotalglyphnum{}
Test glyphs
{\basictextfont{Font filename: uzdr.pfb}}
\testedfont
\renewcommand\findglyphslotnum{\the\XeTeXcharglyph"279C}
\setcounter{glyphslotnum}{\findglyphslotnum}
\renewcommand\findtotalglyphnum{\the\XeTeXcountglyphs\testedfont}
\setcounter{totalglyphnum}{\findtotalglyphnum}
%\multido{\i=0+1}{\value{totalglyphnum}\relax}{
%{\basictextfont\i:\,}{\testedfont\XeTeXglyph\i}
%}
\basictextfont
uzdr.pfb: total \number\value{totalglyphnum} glyphs
\ifnum\value{glyphslotnum}>0{\message{Glyph for 279C exists in uzdr.pfb (slot \number\value{glyphslotnum})}Glyph for Unicode 279C exists in uzdr.pfb at slot \number\value{glyphslotnum}.
It looks like [{\testedfont\XeTeXglyph\value{glyphslotnum}}] (by $\backslash$XeTeXglyph)
or [{\testedfont{\char"279C}}] (by $\backslash$char)
or [{\testedfont{\symbol{"279C}}}] (by $\backslash$symbol)
}\fi
\end{document}