I am compiling with xelatex sample.tex, but am not able to use a font on the newer version of Ubuntu (Ubuntu Mantic). How can I use the Ubuntu font in my compiled LaTeX PDF documents on Ubuntu Mantic without copying the fonts from an older Ubuntu distribution?
Fonts have been changed from separate files (for example, Ubuntu Focal) to a single one (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
I have installed fonts-ubuntu. It provides:
> 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}
gives the error
! Package fontspec Error: The font "Ubuntu-L" cannot be found.
For immediate help type H <return>.
...
\setmainfont{Ubuntu:style=Light} and \setmainfont{"Ubuntu:style=Light"} (with quotes around name) gives xdvipdfmx:fatal: Invalid font: -1 (0)
Before Ubuntu Mantic, this works:
\setmainfont{Ubuntu Light}[ItalicFont=Ubuntu Light Italic]
On Ubuntu Mantic, it says
! Package fontspec Error: The font "Ubuntu Light" cannot be found.
For immediate help type H <return>.
...
Here is a minimal example:
\documentclass{article}
\usepackage{fontspec}
% Works on Ubuntu distributions before Mantic Minotaur
\setmainfont{Ubuntu Light}[ItalicFont=Ubuntu Light Italic]
\begin{document}
Hello, World!
\end{document}
Important: this works on Ubuntu distributions before Mantic Minotaur, but not on Mantic Minotaur.
fc-cacheto cache the TeX font files. This might do it. – Davislor Sep 29 '23 at 07:32