Closed dbitouze closed 6 months ago
Where did you get the fonts? There is no FiraCode-Regular.ttf in texlive, and at https://github.com/tonsky/FiraCode I only find ttf-files and no FiraCode-RegularItalic.otf
After I installed the firacode fonts (in my system), \setmonofont{FiraCode-Regular.ttf}
worked fine for me with lualatex and xelatex.
Where did you get the fonts? There is no FiraCode-Regular.ttf in texlive, and at https://github.com/tonsky/FiraCode I only find ttf-files and no
FiraCode-RegularItalic.otf
A friend gave them to me. But I guess they come from this repository.
After I installed the firacode fonts (in my system),
\setmonofont{FiraCode-Regular.ttf}
worked fine for me with lualatex and xelatex.
Strange! My system is GNU/Linux Mageia 9 with a vanilla install of TeX Live 2024. And:
$ fc-list | grep FiraCode-Regular
/usr/share/fonts/drakfont/Type1/FiraCode-Regular.pfb: Fira Code:style=Regular
/usr/share/fonts/drakfont/ttf/FiraCode-Regular.ttf: Fira Code:style=Regular
/usr/share/fonts/drakfont/otf/FiraCode-RegularItalic.otf: Fira Code:style=Regular Italic,Italic
I thought this might be a bug with mixing ttf and otf extensions in the same font family call, but this seems to work for me:
\documentclass{article}
\usepackage{fontspec}
\setmonofont{Ysabeau-Regular.otf}[ItalicFont=Lato-Regular.ttf]
\begin{document}
\ttfamily
Foo
\itshape
Foo
\end{document}
At the moment I am thinking this might not be a fontspec issue, so I'll close this issue now to avoid it lingering -- but let me know if you can find another example.
At the moment I am thinking this might not be a fontspec issue, so I'll close this issue now to avoid it lingering -- but let me know if you can find another example.
But isn't it a bug of fontspec
that the following MCE doesn't compile with xelatex
?
\documentclass{article}
\usepackage{fontspec}
\setmonofont{FiraCode-Regular.ttf}
\begin{document}
Foo
\end{document}
But isn't it a bug of
fontspec
that the following MCE doesn't compile withxelatex
?
It compiles fine for me. But you can test if it is a problem with fontspec or your font installation by compiling without fontspec:
\documentclass{article}
\begin{document}
\font\test="[FiraCode-Regular.ttf]/OT:script=latn;language=dflt;" \test blub
\end{document}
@u-fischer Thanks for the useful hint. Indeed, this MCE:
lualatex
,xelatex
:! Font \test=[FiraCode-Regular.ttf]/OT:script=latn;language=dflt; not loadable:
Metric (TFM) file or installed font not found.
<to be read again>
\test
l.3 ...r.ttf]/OT:script=latn;language=dflt;" \test
blub
? H
I wasn't able to read the size data for this font,
so I will ignore the font specification.
[Wizards can fix TFM files using TFtoPL/PLtoTF.]
You might try inserting a different font spec;
e.g., type `I\font<same font id>=<substitute font name>'.
?
Missing character: There is no b ("62) in font nullfont!
Missing character: There is no l ("6C) in font nullfont!
Missing character: There is no u ("75) in font nullfont!
Missing character: There is no b ("62) in font nullfont!
Another example:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}[
Extension =.otf,
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Italic,
BoldItalicFont = *-BoldItalic,
]
\begin{document}
Test
\end{document}
which:
lualatex
-compile with fontspec-luatex.sty 2024/02/13 v2.9a
,lualatex
-compile with fontspec-luatex.sty 2024/05/03 v2.9c
, with the error:
luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: File not found: "TeX Gyre Pagella-Regular.otf".
! Package fontspec Error: (fontspec) The font "TeX Gyre Pagella-Regular" cannot be (fontspec) found; this may be but usually is not a fontspec (fontspec) bug. Either there is a typo in the font name/file, (fontspec) the font is not installed (correctly), or there is (fontspec) a bug in the underlying font loading engine (fontspec) (XeTeX/luaotfload).
In both case:
$ fc-list | rg Pagella | rg otf /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/tex-gyre/texgyrepagella-bolditalic.otf: TeX Gyre Pagella:style=Bold Italic /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/tex-gyre/texgyrepagella-italic.otf: TeX Gyre Pagella:style=Italic /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/newpx/TeXGyrePagellaX-Slanted.otf: TeX Gyre PagellaX:style=Slanted /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/newpx/TeXGyrePagellaX-Regular.otf: TeX Gyre PagellaX:style=Regular /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/newpx/TeXGyrePagellaX-BoldItalic.otf: TeX Gyre PagellaX:style=Bold Italic /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/newpx/TeXGyrePagellaX-Italic.otf: TeX Gyre PagellaX:style=Italic /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/newpx/TeXGyrePagellaX-BoldSlanted.otf: TeX Gyre PagellaX:style=BoldSlanted /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/newpx/TeXGyrePagellaX-Bold.otf: TeX Gyre PagellaX:style=Bold /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/aesupp/aepagella-italic.otf: AePagella:style=Italic /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/aesupp/aepagella-bolditalic.otf: AePagella:style=BoldItalic /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/tex-gyre/texgyrepagella-bold.otf: TeX Gyre Pagella:style=Bold /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/tex-gyre-math/texgyrepagella-math.otf: TeX Gyre Pagella Math:style=Regular /usr/local/texlive/2024/texmf-dist/fonts/opentype/public/tex-gyre/texgyrepagella-regular.otf: TeX Gyre Pagella:style=Regular
@dbitouze — I don't understand this example. The *
notation is intended to copy the first argument into the subsequent arguments, and the Extension
notation is to add .otf
to them. So it seems correct that fontspec would be looking for:
And it also seems correct that it couldn't find these fonts using those filenames. How this ever worked I'm not too sure, but it was surely a mis-feature.
@wspr OK, thanks: removing the Extension = .otf
option makes it work. Nevertheless, another example which used to work and that doesn't work anymore:
\documentclass{article}
\usepackage{fontspec}
\setmonofont{GoMono}[
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Regular-Italic,
BoldItalicFont = *-Bold-Italic,
]
\begin{document}
\ttfamily
Test
\textbf{Test}
\textit{Test}
\textbf{\textit{Test}}
\end{document}
(“luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: Font "GoMono-Regular" not found.”), despite:
$ fc-list | rg GoMono | rg tf
/usr/local/texlive/2024/texmf-dist/fonts/truetype/bh/gofonts/GoMono-Regular.ttf: Go Mono:style=Regular
/usr/local/texlive/2024/texmf-dist/fonts/truetype/bh/gofonts/GoMono-Bold-Italic.ttf: Go Mono:style=Bold Italic
/usr/local/texlive/2024/texmf-dist/fonts/truetype/bh/gofonts/GoMono-Regular-Italic.ttf: Go Mono:style=Italic
/usr/local/texlive/2024/texmf-dist/fonts/truetype/bh/gofonts/GoMono-Bold.ttf: Go Mono:style=Bold
OK, the expected result is obtained with just \setmonofont{GoMono}
(without the options specifying the UprightFont, BoldFont, ItalicFont, and BoldItalicFont).
@dbitouze — hmmm, this seems to be working for me in LuaTeX right now (albeit with a prerelease fontspec). But I think it's dangerous to ask for a file on disk without also giving an extension or specifying "Path" — otherwise you are relying on heuristics of the engine searching for the font name, failing to find it, then falling back to searching on disk.
hmmm, this seems to be working for me in LuaTeX right now (albeit with a prerelease fontspec). But I think it's dangerous to ask for a file on disk without also giving an extension or specifying "Path" — otherwise you are relying on heuristics of the engine searching for the font name, failing to find it, then falling back to searching on disk.
@wspr OK but still it was working before :wink:
But I'm a bit lost: could you please give the code that should be used for this GoMono font with the extension provided and the UprightFont, BoldFont, ItalicFont, BoldItalicFont specified?
@dbitouze — apologies for the inconvenience here! I am sorry that these changes have caused issues.
I prefer to load fonts by filename to avoid portability issues so I would recommend here:
\setmonofont{GoMono}[
Extension = .ttf,
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Regular-Italic,
BoldItalicFont = *-Bold-Italic,
]
@wspr You're welcome! Many thanks to you for your answer, for fontspec
and for your numerous other contributions!
For what it's worth, with fontspec
v2.9d, the file of the OP:
\documentclass{article}
\usepackage{fontspec}
\setmonofont{FiraCode-Regular.ttf}[ItalicFont= FiraCode-RegularItalic.otf]
\begin{document}
Foo
\end{document}
lualatex
,xelatex
, with the same error:
! Package fontspec Error:
(fontspec) The font "FiraCode-Regular" cannot be found; this
(fontspec) may be but usually is not a fontspec bug. Either
(fontspec) there is a typo in the font name/file, the font is
(fontspec) not installed (correctly), or there is a bug in
(fontspec) the underlying font loading engine
(fontspec) (XeTeX/luaotfload).
For immediate help type H
l.3 ...tf}[ItalicFont= FiraCode-RegularItalic.otf]
?
@dbitouze — thanks for letting me know... this was definitely supposed to be fixed! :(
XeTeX does not load system fonts by file name, only TDS fonts, and vice versa. Luaotfload will load system fonts by file names (unless kpse:
prefix is used).
XeTeX does not load system fonts by file name, only TDS fonts, and vice versa. Luaotfload will load system fonts by file names (unless
kpse:
prefix is used).
@khaledhosny Thanks! But, given that:
$ fc-list | rg -v wght | rg -v pfb | rg FiraCode | rg Italic
/usr/share/fonts/drakfont/otf/FiraCode-BoldItalic.otf: Fira Code:style=Bold Italic
/usr/share/fonts/drakfont/otf/FiraCode-RegularItalic.otf: Fira Code:style=Regular Italic,Italic
what would be with XeTeX the code to use in order to get the font provided by FiraCode-RegularItalic.otf
(last line above) as ItalicFont
?
\setmonofont{Fira Code}
should work, you don’t need to explicitly specify ItalicFont
.
Bit if you want to load the fonts by file name, then the simplest solution is to copy them to the current directory.
Shouldn't it also work to write Path=/usr/share/fonts/drakfont/otf/
?
That would work too.
Description
With
fontspec
2.9b, a font is wrongly claimed to be not found.Check/indicate
Minimal example demonstrating the issue
Further details
With
fontspec
:v2.9a, the previous MCE used to:
lualatex
-compile,xelatex
-compile: that failed with the error:v2.9b, the previous MCE fails to both
lualatex
-compile andxelatex
-compile, with the error (the first line only withlualatex
):BTW, with
fontspec
2.9b, the following MCE:lualatex
-compiles,xelatex
-compiles: that failed with the error: