如何使用 XeLaTeX 处理具有奇怪名称的 TTF 字体?

如何使用 XeLaTeX 处理具有奇怪名称的 TTF 字体?

我正在尝试使用这种字体http://www.dafont.com/ecran-monochrome.font?fpp=100,在 XeLaTeX 中称为“Écran Monochrome”。

正如您所见,它有一个奇怪的名字,既因为重音又因为空格。XeLaTeX 似乎对此感到困惑,并且它不会编译此文档:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Écran Monochrome}
\begin{document}
123
\end{document}

问题是如何在文档中指定此字体?我尝试了这个名字的多种变体,例如删除重音符号、大写字母和空格(请参阅下文了解当前错误消息。)

给出错误:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
! 
! The font "Écran Monochrome" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

TTF 已安装完毕并可从其他应用程序(如 Linux 中的 LibreOffice)中使用。

$ fc-list | grep cran
/home/user/.local/share/fonts/ecran-monochrome---monochrome-display.ttf: écran monochrome / monochrome display:style=Regular

答案1

Leo Liu 的评论其实是一个解决方案。我们可以使用字体的文件名将字体与包一起加载fontspec。类似的问题是,当字体实际上没有安装或由于用户在计算机上的权限有限而无法安装时,我们仍然希望使用该字体。我们ExternalLocation为此使用选项,我附上了一个示例,其中字体已在工作目录中解压,但尚未安装。

\documentclass{article}
\pagestyle{empty}
\usepackage{fontspec}
\setmainfont[ExternalLocation={./}]{ecran-monochrome---monochrome-display.ttf} % Écran Monochrome
\begin{document}
123
\end{document}

姆韦

相关内容