我在 /usr/local/texlive/texmf-local/fonts 安装了一些 .otf 字体,更改了 /usr/local/texlive/2015/texmf-var/fonts/conf/texlive-fontconfig.conf,添加了字符串
<dir>/usr/local/texlive/texmf-local/fonts</dir>
我把这个修改后的文件复制到 /etc/fonts/conf.d/09-texlive.conf 中。最后,我给出了:
fc-缓存-fsv
似乎在系统中找到新的字体:
/usr/local/texlive/texmf-local/fonts/opentype/ArnoPro: caching, new cache contents: 32 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/BriosoPro: caching, new cache contents: 42 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/CaslonPro: caching, new cache contents: 6 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/ChaparralPro: caching, new cache contents: 32 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/Crimson: caching, new cache contents: 6 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/Fontin: caching, new cache contents: 4 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/GaramondPremierePro: caching, new cache contents: 34 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/JensonPro: caching, new cache contents: 32 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/MinionPro: caching, new cache contents: 64 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/MyriadPro: caching, new cache contents: 40 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/opentype/WarnockPro: caching, new cache contents: 32 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/source: caching, new cache contents: 0 fonts, 1 dirs
/usr/local/texlive/texmf-local/fonts/source/local: caching, new cache contents: 0 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/tfm: caching, new cache contents: 0 fonts, 1 dirs
/usr/local/texlive/texmf-local/fonts/tfm/local: caching, new cache contents: 0 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/type1: caching, new cache contents: 0 fonts, 1 dirs
/usr/local/texlive/texmf-local/fonts/type1/local: caching, new cache contents: 0 fonts, 0 dirs
/usr/local/texlive/texmf-local/fonts/vf: caching, new cache contents: 0 fonts, 1 dirs
/usr/local/texlive/texmf-local/fonts/vf/local: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts: caching, new cache contents: 0 fonts, 5 dirs
/usr/X11R6/lib/X11/fonts: skipping, no such directory
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/.local/share/fonts: skipping, no such directory
/usr/local/texlive/2015/texmf-dist/fonts/opentype: caching, new cache contents: 0 fonts, 7 dirs
/usr/local/texlive/2015/texmf-dist/fonts/truetype: caching, new cache contents: 0 fonts, 10 dirs
/usr/local/texlive/2015/texmf-dist/fonts/type1: caching, new cache contents: 0 fonts, 26 dirs
/usr/local/texlive/texmf-local/fonts: caching, new cache contents: 0 fonts, 5 dirs
/var/cache/fontconfig: cleaning cache directory
/.cache/fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded
此外,例如:
samiel@debian:~$ fc-list : family file | grep -i fontin
/usr/local/texlive/texmf-local/fonts/opentype/Fontin/Fontin-SmallCaps.otf: Fontin SmallCaps,Fontin
/usr/local/texlive/texmf-local/fonts/opentype/Fontin/Fontin-Bold.otf: Fontin
/usr/local/texlive/texmf-local/fonts/opentype/Fontin/Fontin-Italic.otf: Fontin
/usr/local/texlive/texmf-local/fonts/opentype/Fontin/Fontin-Regular.otf: Fontin
但是如果我尝试使用刚刚添加的字体之一通过 xelatex 进行编译,我会得到:
(/usr/local/texlive/2015/texmf-dist/tex/latex/unicode-math/unicode-math-table.t
ex)))kpathsea:make_tex: Invalid fontname `Garamond Premier Pro', contains ' '
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "Garamond Premier Pro" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.6 ...TeX,Numbers=OldStyle]{Garamond Premier Pro}
?
我遗漏了什么?谢谢
附言
请考虑:
root@debian:/usr/local/texlive/texmf-local/fonts/opentype/CaslonPro# otfinfo -a ACaslonPro-Regular.otf
Adobe Caslon Pro
数学方程
\documentclass[a4paper]{article}
\usepackage{fontspec}
\defaultfontfeatures{Contextuals=NoAlternate}
\setmainfont[Ligatures=TeX,Numbers=OldStyle]{Adobe Caslon Pro}
\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{italian}
\begin{document}
Quel ramo del lago di Como
\end{document}
输出
(/usr/local/texlive/2015/texmf-dist/tex/latex/fontspec/fontspec.cfg)))kpathsea:make_tex: Invalid fontname `Adobe Caslon Pro', contains ' '
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "Adobe Caslon Pro" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.5 ...res=TeX,Numbers=OldStyle]{Adobe Caslon Pro}
?
我很困惑
进一步补充
在安装了 Debian 的分区中,一切正常。.otf 是 root-staff 的属性,权限是 -rw------。另一个不起作用的分区也是如此...
答案1
在 XeLaTeX 和 LuaLaTeX 中查找字体的算法是不同的。老实说,我并不完全理解它们,但我发现两者的工作原理都是报告的人类可读的名称fc-list
。所以,让我们以 Linux Libertine 系列为例。(在实际的实际使用中,有这个libertine
软件包,但我选择这个例子是因为正确的名称是独一无二的。)
$ fc-list | grep "Linux Libertine" | grep ".otf" | grep 2015
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_MO.otf: Linux Libertine Mono O:style=Mono Oblique
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_RZI.otf: Linux Libertine O:style=Semibold Italic
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_RB.otf: Linux Libertine O:style=Bold
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_M.otf: Linux Libertine Mono O:style=Mono
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_DR.otf: Linux Libertine Display O:style=Regular
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_RZ.otf: Linux Libertine O:style=Semibold
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_RBI.otf: Linux Libertine O:style=Bold Italic
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_RI.otf: Linux Libertine O:style=Italic
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_MBO.otf: Linux Libertine Mono O :style=Mono Bold Oblique
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_MB.otf: Linux Libertine Mono O :style=Mono Bold
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_R.otf: Linux Libertine O:style=Regular
/usr/local/texlive/2015/texmf-dist/fonts/opentype/public/libertine/LinLibertine_I.otf: Linux Libertine Initials O:style=Initials
我们要使用的名称是中间字段中的名称,必要时可附加样式。因此文件
\documentclass[10pt]{standalone}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\setmonofont[ItalicFont={Linux Libertine Mono O Oblique}]{Linux Libertine Mono O}
\newfontface{\lli}{Linux Libertine Display O}
\begin{document}
Linux Libertine Regular \textbf{Bold} \textit{Italic} \textsc{\textit{Italic Small Caps}}
\texttt{Mono} \texttt{\textsl{Mono Oblique}} {\lli Display}
\end{document}
生成:
在这种情况下,我们需要提示使用哪种字体作为单斜体,但fontspec
足够聪明,可以让其他一切都开箱即用。我之前回答的评论中报告的另一个问题是\scshape\itshape
。如果你的字体系列有单独的斜体小写字体,加载该字体的说明位于 §5.1.2手册fontspec
。
答案2
该问题也可能是由缓存问题引起的;在我的计算机上,下面的操作足以修复它:
rm -rf ~/.texlive2016/texmf-var/luatex-cache/ ~/.texmf-var/luatex-cache/
缓存文件夹的名称由 LuaLaTeX 在编译期间打印:
(using write cache: /home/<username>/.texlive2016/texmf-var/luatex-cache/generic)