XeLaTeX 无法识别梵文脚本

XeLaTeX 无法识别梵文脚本

我正在尝试使用 XeLaTeX 直接在代码中使用梵文(和藏文)脚本。似乎出于某种原因,XeLaTeX 无法识别我放入 .tex 文件中的梵文字符。问题似乎与我的系统上的设置有关,因为其他人能够编译相同或相似的 .tex 文件并获得良好的结果。但是,当我编译时,我只得到问号而不是梵文字符。这是一个简单的 MWE,它给了我一排问号。“Nakula”是我系统(Mac OS Yosemite)上安装的梵文字体:

\documentclass{article}

\usepackage{fontspec}

\begin{document}

\setmainfont{Nakula}

शारदा शारदाम्भोजवदना वदनाम्बुजे।
सर्वदा सर्वदास्माकं संनिधिं संनिधिं क्रियात्।।

\end{document} 

以下是汇编记录的摘录,似乎表明字体无法正确访问。我确信 Nakula 通常以这种方式与 XeLaTeX 配合使用,因为我见过其他人使用它制作的示例:

.................................................
. fontspec info: "no-scripts"
. 
. Font Nakula does not contain any OpenType `Script' information.
.................................................
\g__fontspec_family_Nakula_int=\count121
.................................................
. fontspec info: "no-font-shape"
. 
. Could not resolve font Nakula/BI (it probably doesn't exist).
.................................................
.................................................
. fontspec info: "no-font-shape"
. 
. Could not resolve font Nakula/B (it probably doesn't exist).
.................................................
.................................................
. fontspec info: "no-font-shape"
. 
. Could not resolve font Nakula/I (it probably doesn't exist).
.................................................
.................................................
. fontspec info: "defining-font"
. 
. Font family 'Nakula(0)' created for font 'Nakula' with options
. [Ligatures=TeX].
. 
. This font family consists of the following shapes:
. 
. * 'normal' with NFSS spec.:
. <->"Nakula/OT:mapping=tex-text;"
. 
. * 'small caps' with NFSS spec.:
. 
. and font adjustment code:
. 
.................................................
 [1

]

答案1

您需要告诉 fontspec 您想要使用的脚本:

\setmainfont[Script=Devanagari]{Nakula}

这将消除第一个警告(尽管它可能没有任何视觉效果,因为如果没有给出明确的脚本,新版本的 XeTeX 将尝试从所使用的文本中猜测脚本)。

其余警告是因为这是一种单一样式字体(没有斜体或粗体)。

但是问号问题似乎与 XeTeX 本身无关,我认为您的编辑器正在改变文本编码或类似的东西,从而导致 XeTeX 垃圾输入。

相关内容