-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Description
If a font name with extension is stored in a string variable, neither LuaLaTeX nor XeLaTeX treat it as expected: with LuaLaTeX a warning is issued, but the font is eventually loaded; with XeLaTeX the font is not found.
The problem is that the allowed extensions are stored in a clist as tokens with category code 11 (for the letters), so no match is detected.
Check/indicate
- Relevant for XeTeX
- Relevant for LuaTeX
- Issue tracker has been searched for similar issues?
- https://tex.stackexchange.com/questions/729423/why-filenames-defined-through-expl3-strings-dont-work-with-setmainfont
Minimal example demonstrating the issue
\documentclass{article}
\usepackage{fontspec}
\ExplSyntaxOn
\str_const:Nn \c_my_font_name_str {Erewhon-Regular.otf}
\setmainfont{\c_my_font_name_str}
\ExplSyntaxOff
\begin{document}
Text
\end{document}
Further details
Relevant part of the console output with LuaLaTeX
luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: Font "Erewhon-Regular.otf" not found.
(./dbfont.aux) (/usr/local/texlive/2024/texmf-dist/tex/latex/base/ts1cmr.fd)
[1{/usr/local/texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./dbfont.aux))
406 words of node memory still in use:
3 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 4 attribute, 48 glue_spec
, 4 attribute_list, 1 write nodes
avail lists: 1:1,2:22,3:4,4:1,5:23,6:2,7:36,9:18
</Library/Fonts/erewhon/Erewhon-Regular.otf>
Relevant part of the console output with XeLaTeX
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input Erewhon-Regular
This is METAFONT, Version 2.71828182 (TeX Live 2024) (preloaded base=mf)
kpathsea: Running mktexmf Erewhon-Regular
! I can't find file `Erewhon-Regular'.
<*> ...ag:=1; ; nonstopmode; input Erewhon-Regular
Please type another input file name
! Emergency stop.
<*> ...ag:=1; ; nonstopmode; input Erewhon-Regular
Transcript written on mfput.log.
grep: Erewhon-Regular.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input Erewhon-Regular' failed to make Erewhon-Regular.tfm.
kpathsea: Appending font creation commands to missfont.log.
! Package fontspec Error:
(fontspec) The font "Erewhon-Regular.otf" cannot be found;
(fontspec) this may be but usually is not a fontspec bug.
(fontspec) Either there is a typo in the font name/file, the
(fontspec) font is not installed (correctly), or there is a
(fontspec) bug in the underlying font loading engine
(fontspec) (XeTeX/luaotfload).
Hackish workaround
\cs_set:Nn \__fontspec_main_DeclareFontExtensions:n
{
\clist_set:Ne \l__fontspec_extensions_clist { #1 , \tl_to_str:n {#1} }
}
\__fontspec_main_DeclareFontExtensions:n {.otf,.ttf,.OTF,.TTF,.ttc,.TTC,.dfont}This stores the extensions both with normal catcodes and with catcode 12 for every character, so the match is found anyway.
Long term proposal
Do the entire business with strings.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels