
TeXlive 2023, Linux, lualatex를 사용합니다.
놀랍게도 파일이 설치되어 있는지 또는 내 홈 디렉토리 인지 여부에 관계없이 파일을 \IfFileExists
찾지 못하는 것 같습니다 . MWE:*.otf
texmf-dist
texmf
% !TeX TS-program = lualatex
% !TeX encoding = UTF-8
\documentclass{article}
\usepackage{fontspec}
\IfFileExists{LibertinusSerif-Regular.otf}{
\typeout{FOUND IT}
}{
\typeout{NOT FOUND} % This is the response.
}
\setmainfont{Libertinus Serif}
\begin{document}
Hello World. % Prints in LibertinusSerif-Regular.otf.
\end{document}
로 컴파일할 때 lualatex
명령줄 출력(및 로그 파일)에는 FOUND IT
파일이 확실히 있을 것으로 예상됩니다. Libertinus Serif 글꼴 모음을 기본 글꼴로 사용하려고 하면 작동합니다. 그러나 \IfFileExists
올바른 파일 확장자를 가진 파일을 찾지 못합니다.
명령어가 있다는 것은 알지만 \IfFontExists
, 폰트가 없으면 시간이 많이 걸릴 수 있으니 그렇게 하고 싶지는 않습니다.
답변1
당신을 사용하면 트리, 즉 (손으로 추가한 것과 함께) 의미가 있는 파일 \IfFileExists
만 검색할 수 있습니다 .$TEXINPUTS
\input
texmf-dist
를 사용하여 (거의) 전체 트리에서 조회를 수행하는 함수를 정의할 수 있습니다 kpsewhich
.
\documentclass{article}
\ExplSyntaxOn
\NewDocumentCommand{\IfFileInTEXTree}{O{}mmm}
{
\sys_get_shell:nnN { kpsewhich~#1~#2 } {\escapechar=-1\scan_stop:} \l_tmpa_tl
\tl_if_blank:VTF \l_tmpa_tl { #4 } { #3 }
}
\ExplSyntaxOff
\IfFileInTEXTree{LibertinusSerif-Regular.otf}{%
\typeout{FOUND IT}%
}{
\typeout{NOT FOUND}%
}
\IfFileInTEXTree{whatever.otf}{%
\typeout{FOUND IT}%
}{
\typeout{NOT FOUND}%
}
\stop
옵션을 추가할 수도 있습니다 kpsewhich
(설명서 참조).
\IfFileInTEXTree[<options>]{<filename>}{<true>}{<false>
이는 무제한 쉘 이스케이프가 필요하지 않고 기본 제한된 쉘 이스케이프만 필요합니다.
로그 파일이 표시됩니다.
(|kpsewhich LibertinusSerif-Regular.otf)
FOUND IT
(|kpsewhich whatever.otf)
NOT FOUND