我正在使用进行编译xelatex sample.tex
,但无法在较新版本的 Ubuntu(Ubuntu Mantic)上使用字体。如何在 Ubuntu Mantic 上编译的 LaTeX PDF 文档中使用 Ubuntu 字体,而无需从旧的 Ubuntu 发行版复制字体?
字体已从单独的文件(例如,Ubuntu Focal)更改为单个文件(Ubuntu Mantic):
> # Ubuntu Mantic
> ls /usr/share/fonts/truetype/ubuntu
total 2.1M
drwxr-xr-x 2 root root 4.0K Sep 28 03:34 .
drwxr-xr-x 11 root root 4.0K Sep 28 03:34 ..
-rw-r--r-- 1 root root 36 Aug 18 02:26 .uuid
lrwxrwxrwx 1 root root 21 Jun 21 08:35 Ubuntu-B.ttf -> 'Ubuntu[wdth,wght].ttf'
lrwxrwxrwx 1 root root 28 Jun 21 08:35 Ubuntu-BI.ttf -> 'Ubuntu-Italic[wdth,wght].ttf'
lrwxrwxrwx 1 root root 21 Jun 21 08:35 Ubuntu-C.ttf -> 'Ubuntu[wdth,wght].ttf'
-rw-r--r-- 1 root root 664K Jun 21 08:34 'Ubuntu-Italic[wdth,wght].ttf'
lrwxrwxrwx 1 root root 21 Jun 21 08:35 Ubuntu-L.ttf -> 'Ubuntu[wdth,wght].ttf'
lrwxrwxrwx 1 root root 28 Jun 21 08:35 Ubuntu-LI.ttf -> 'Ubuntu-Italic[wdth,wght].ttf'
lrwxrwxrwx 1 root root 21 Jun 21 08:35 Ubuntu-M.ttf -> 'Ubuntu[wdth,wght].ttf'
lrwxrwxrwx 1 root root 28 Jun 21 08:35 Ubuntu-MI.ttf -> 'Ubuntu-Italic[wdth,wght].ttf'
lrwxrwxrwx 1 root root 21 Jun 21 08:35 Ubuntu-R.ttf -> 'Ubuntu[wdth,wght].ttf'
lrwxrwxrwx 1 root root 28 Jun 21 08:35 Ubuntu-RI.ttf -> 'Ubuntu-Italic[wdth,wght].ttf'
lrwxrwxrwx 1 root root 21 Jun 21 08:35 Ubuntu-Th.ttf -> 'Ubuntu[wdth,wght].ttf'
lrwxrwxrwx 1 root root 20 Jun 21 08:35 UbuntuMono-B.ttf -> 'UbuntuMono[wght].ttf'
lrwxrwxrwx 1 root root 27 Jun 21 08:35 UbuntuMono-BI.ttf -> 'UbuntuMono-Italic[wght].ttf'
-rw-r--r-- 1 root root 169K Mar 24 2023 'UbuntuMono-Italic[wght].ttf'
lrwxrwxrwx 1 root root 20 Jun 21 08:35 UbuntuMono-R.ttf -> 'UbuntuMono[wght].ttf'
lrwxrwxrwx 1 root root 27 Jun 21 08:35 UbuntuMono-RI.ttf -> 'UbuntuMono-Italic[wght].ttf'
-rw-r--r-- 1 root root 169K Mar 24 2023 'UbuntuMono[wght].ttf'
-rw-r--r-- 1 root root 1.1M Jun 21 08:34 'Ubuntu[wdth,wght].ttf'
> # Before Ubuntu Mantic
> ls /usr/share/fonts/truetype/ubuntu
total 4.3M
drwxr-xr-x 2 root root 4.0K Jul 31 2020 .
drwxr-xr-x 49 root root 4.0K Jul 31 2020 ..
-rw-r--r-- 1 root root 349K Jul 10 2015 Ubuntu-BI.ttf
-rw-r--r-- 1 root root 326K Jul 10 2015 Ubuntu-B.ttf
-rw-r--r-- 1 root root 343K Jul 10 2015 Ubuntu-C.ttf
-rw-r--r-- 1 root root 401K Jul 10 2015 Ubuntu-LI.ttf
-rw-r--r-- 1 root root 406K Jul 10 2015 Ubuntu-L.ttf
-rw-r--r-- 1 root root 359K Jul 10 2015 Ubuntu-MI.ttf
-rw-r--r-- 1 root root 212K Sep 26 2011 UbuntuMono-BI.ttf
-rw-r--r-- 1 root root 187K Sep 26 2011 UbuntuMono-B.ttf
-rw-r--r-- 1 root root 206K Sep 26 2011 UbuntuMono-RI.ttf
-rw-r--r-- 1 root root 201K Sep 26 2011 UbuntuMono-R.ttf
-rw-r--r-- 1 root root 334K Jul 10 2015 Ubuntu-M.ttf
-rw-r--r-- 1 root root 378K Jul 10 2015 Ubuntu-RI.ttf
-rw-r--r-- 1 root root 346K Jul 10 2015 Ubuntu-R.ttf
-rw-r--r-- 1 root root 235K Mar 8 2019 Ubuntu-Th.ttf
我已经安装fonts-ubuntu
。 它提供:
> fc-list Ubuntu
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Regular
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Medium
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Thin
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Light
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Extra Bold Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Condensed Bold Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Medium
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Medium Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Thin Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Condensed Extra Bold Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Extra Bold
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Extra Bold
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Condensed Medium Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Light
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Condensed Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Light Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Bold Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Thin
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Condensed Thin Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu
/usr/share/fonts/truetype/ubuntu/Ubuntu-Italic[wdth,wght].ttf: Ubuntu:style=Condensed Light Italic
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Bold
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Bold
\setmainfont[Path=/usr/share/fonts/truetype/ubuntu]{Ubuntu-L.ttf}
给出错误
! Package fontspec Error: The font "Ubuntu-L" cannot be found.
For immediate help type H <return>.
...
\setmainfont{Ubuntu:style=Light}
并且\setmainfont{"Ubuntu:style=Light"}
(在名称两边加上引号)给出xdvipdfmx:fatal: Invalid font: -1 (0)
在 Ubuntu Mantic 之前,这个有效:
\setmainfont{Ubuntu Light}[ItalicFont=Ubuntu Light Italic]
在 Ubuntu Mantic 上,它说
! Package fontspec Error: The font "Ubuntu Light" cannot be found.
For immediate help type H <return>.
...
这是一个简单的例子:
\documentclass{article}
\usepackage{fontspec}
% Works on Ubuntu distributions before Mantic Minotaur
\setmainfont{Ubuntu Light}[ItalicFont=Ubuntu Light Italic]
\begin{document}
Hello, World!
\end{document}
重要的:这在 Mantic Minotaur 之前的 Ubuntu 发行版上运行,但在 Mantic Minotaur 上不运行。