![使用 Sanskrit 2003 时出现“未找到字体”错误](https://linux22.com/image/337155/%E4%BD%BF%E7%94%A8%20Sanskrit%202003%20%E6%97%B6%E5%87%BA%E7%8E%B0%E2%80%9C%E6%9C%AA%E6%89%BE%E5%88%B0%E5%AD%97%E4%BD%93%E2%80%9D%E9%94%99%E8%AF%AF.png)
.tex
这是我的文件的开头
\usepackage{fontspec}
\makeatletter
\setmainfont[Script=Devanagari]{Sanskrit 2003}
\setsansfont[Script=Devanagari]{Sanskrit 2003}
\setmonofont[Script=Devanagari]{Sanskrit 2003}
但是当我编译时,出现以下错误:
\font\dev="Sanskrit 2003:script=deva" at 12pt\dev
! fontspec error: "font-not-found"
!! The font "Sanskrit 2003" cannot be found.
!! See the fontspec documentation for further information.
!! For immediate help type H<return>.
!...............................................
...ainfont[Script=Devanagari]{Sanskrit 2003}
答案1
This is what you want
\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage[english]{babel}
\newfontfamily\sanskrit[Script=Devanagari]{Sanskrit 2003}
\begin{document}
The main text is in English, and you can add sanskrit quote...
\begin{quotation}\sanskrit
सर्वधर्मान् परित्यज्य मामेकं शरणं व्र्ज
अहं त्वां सर्वपापेभ्यो मोक्षयिष्यामि मा शुचः
\end{quotation}
\end{document}
答案2
\documentclass[12pt]{article}
\usepackage{fontspec}
\newcommand\dn{\catcode`\~=12
\fontspec[Script=Devanagari,%
Mapping=velthuis-sanskrit]{Sanskrit 2003}}
\setlength\parindent{0pt}
\begin{document}
{\dn
namastu"n+ga"sira"scumbicandracaamaracaarave |\\
trailokyanagaraarambhamuulas+tambhaaya "sambhave || 1 ||\\
haraka.n.thagrahaanandamiilitaak.sii.m namaamyumaam |\\
kaalakuu.tavi.saspar"sajaatamuurcchaagamaamiva || 2 ||}
\end{document}