devanagari
几年前,我曾在 Mac 上成功将文档处理成 PDF。我尝试用 处理一份简单的文档xelatex
,但没有成功。我的文档是:
\documentclass{article}
\usepackage{fontspec}
\begin{document}
\setmainfont[Script=Devanagari]{Nakula}
नमस्ते रुद्र मन्यवे
\end{document}
下面是我的 Mac(运行 Sierra 10.12.1)上安装的所有字体的图片
这是 TeXshop 控制台中显示的日志文件:
This is XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./Untitled.tex
LaTeX2e <2015/01/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2015/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2015/texmf-dist/tex/latex/l3kernel/l3unicode-data.def)
(/usr/local/texlive/2015/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def))
(/usr/local/texlive/2015/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/fontspec/fontspec-patches.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/euenc/eu1enc.def)
(/usr/local/texlive/2015/texmf-dist/tex/latex/euenc/eu1lmr.fd))
(/usr/local/texlive/2015/texmf-dist/tex/xelatex/xunicode/xunicode.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/tipa/t3enc.def
(/usr/local/texlive/2015/texmf-dist/tex/latex/euenc/eu1lmss.fd))
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/local/texlive/2015/texmf-dist/tex/xelatex/xetex-def/xetex.def))))
(/usr/local/texlive/2015/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(./Untitled.aux) (/usr/local/texlive/2015/texmf-dist/tex/latex/tipa/t3cmr.fd)
[1] (./Untitled.aux) )
Output written on Untitled.pdf (1 page).
SyncTeX written on Untitled.synctex.gz.
Transcript written on Untitled.log.
我也尝试将字体类型设置为“Devanagari MT”,但是也不起作用。
更新:
我下载并安装了texlive-2016并通过重新运行我的文件xelatex
。现在它产生了一个有意义的错误字体“Nakula” 不包含“天城文”文字。
This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./Untitled.tex
LaTeX2e <2016/03/31>
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def))
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/euenc/eu1enc.def)
(/usr/local/texlive/2016/texmf-dist/tex/latex/euenc/eu1lmr.fd))
(/usr/local/texlive/2016/texmf-dist/tex/xelatex/xunicode/xunicode.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/tipa/t3enc.def
(/usr/local/texlive/2016/texmf-dist/tex/latex/euenc/eu1lmss.fd))
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2016/texmf-dist/tex/xelatex/xetex-def/xetex.def
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))))
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(./Untitled.aux) (/usr/local/texlive/2016/texmf-dist/tex/latex/tipa/t3cmr.fd)
*************************************************
* fontspec warning: "script-not-exist"
*
* Font 'Nakula' does not contain script 'Devanagari'.
*************************************************
[1] (./Untitled.aux) )
Output written on Untitled.pdf (1 page).
SyncTeX written on Untitled.synctex.gz.
Transcript written on Untitled.log.
答案1
问题是 TeXShop 显然默认将文档保存为latin1
,而不是utf-8
像现代编辑器那样。
虽然!TS
在每个文档中添加一行是一种选择,但最好的办法是更改 TeXShop 首选项中文件的默认编码,以便utf-8
默认使用该编码。!TS
然后可以在必要时使用一行来覆盖此编码。
几周前我的一个学生就遇到了这种情况,我很惊讶 TeXShop 没有默认使用utf-8
。但事实确实如此 - 这是一个全新的安装,并且它就是这样:latin1
将所有文档的编码作为默认设置。
答案2
真正的问题出在 TexShop。它将我的文件保存为 ASCII 而不是 unicode:
$ file zz.tex
zz.tex: LaTeX 2e document text, ASCII text
$ cat zz.tex
\documentclass{article}
\usepackage{fontspec}
\newfontscript{Devanagari}{deva}
\setmainfont{Devanagari MT}
\begin{document}
?????? ????? ??????
\end{document}
这提示我文件类型不正确。以下TeXShop 不记得文件编码,我添加了以下内容作为文件的第一行.tex
:
% !TEX encoding = UTF-8 Unicode
一切运行正常。
$ file zz.tex
zz.tex: LaTeX 2e document text, UTF-8 Unicode text
答案3
评论太长了。
以下文件
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Path=./,Extension=.ttf,Script=Devanagari]{nakula}
\begin{document}
नमस्ते रुद्र मन्यवे
\expandafter\show\the\font
\end{document}
停止 XeLaTeX(如预期)并显示信息
*************************************************
* fontspec warning: "script-not-exist"
*
* Font 'nakula' does not contain script 'Devanagari'.
*************************************************
(./nak.aux) (/usr/local/texlive/2016/texmf-dist/tex/latex/tipa/t3cmr.fd)
> \EU1/nakula(0)/m/n/10=select font "[./nakula.ttf]/OT:script=deva;language=DFL
T;mapping=tex-text;".
<inserted text> \EU1/nakula(0)/m/n/10
l.9 \expandafter\show\the\font
因此,你可以看到警告信息是虚假的,这似乎是 中的一个小错误fontspec
。事实上,如果我这样做
\documentclass{article}
\usepackage{fontspec}
\newfontscript{Devanagari}{deva}
\setmainfont[Path=./,Extension=.ttf,Script=Devanagari]{nakula}
\begin{document}
नमस्ते रुद्र मन्यवे
\expandafter\show\the\font
\end{document}
不会发出任何警告,字体信息也完全相同。如你所见,脚本是已正确加载。
我的系统上的输出是
我看不懂梵文,所以无法判断它是否正确。但是,其他软件显示
答案4
(这只是“无法重现”,但对于评论来说太长了。)我安装了Nakula 网站上的并准确运行问题中的文件
\documentclass{article}
\usepackage{fontspec}
\begin{document}
\setmainfont[Script=Devanagari]{Nakula}
नमस्ते रुद्र मन्यवे
\end{document}
通过xelatex
(在 Mac OS X Yosemite 10.10.5,texlive-2015 上)并得到预期的输出:
因此,我猜测是您的 Nakula 安装出现了一些问题,导致 XeLaTeX 无法正确找到它。