我安装了一个字体(本例中为“Rubik”)不是在 LaTeX 字体目录中(这些似乎都工作正常),并尝试在简单的 MWE 中使用它:
\documentclass{article}
\usepackage{fontspec}
\setsansfont{Rubik}[
Path = /Users/<USER>/Library/Fonts/,
Extension = .ttf,
UprightFont = *-Regular,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic
]
\begin{document}
Test.
\end{document}
这产生了Package fontspec Error: The font "Rubik-Regular" cannot be found.
。
当然,类似的问题有很多答案,例如如何使用 LuaLaTeX 正确安装和使用新字体?。我尝试按如下方式进行故障排除:
- 尝试了我能想到的任何合理路径
Path = ...,
(并相应地移动字体文件,甚至移动到与根 TeX 文件相同的文件夹)。 - 尝试以不同的方式“调用”字体(特别是“直接”使用
Rubik-Regular.ttf
) - 更新到最新的 tex 发行版,更新所有软件包,重新安装 luaotfload;
- 冉
luaotfload-tool -vvv --update --force
有趣的是,luaotfload
似乎能够找到字体;luaotfload-tool --find="Rubik"
成功:
luaotfload | resolve : Font "Rubik" found!
luaotfload | resolve : Resolved file name "/Users/<USER>/Library/Fonts/Rubik-Regular.ttf"
同样有趣的是,它luaotfload-tool --diagnose="files"
返回一个警告,指出发现以下五个错误:
luaotfload | diagnose : FAILED: file mktests missing.
luaotfload | diagnose : FAILED: file mkstatus missing.
luaotfload | diagnose : FAILED: file mkcharacters missing.
luaotfload | diagnose : FAILED: file mkglyphlist missing.
luaotfload | diagnose : FAILED: file mkimport missing.
luaotfload
我在的 GitHub 存储库中找到了这些脚本,并尝试手动将它们添加到/usr/local/texlive/2022/texmf-dist/tex/luatex/luaotfload/
,但它不会改变上述诊断的输出。所有其他诊断均未发现任何问题。如前所述,我重新安装并更新了luaotfload
,它确实是最新版本:
(base) [...] luaotfload-tool -V
luaotfload-tool version: "3.21"
Revision: nil
Lua interpreter: stock; version "Lua 5.3"
Luatex version: 1.15
Platform: type=unix name=macosx
+ machine: x86_64
[...]
但我不知道那些缺失的脚本是否真的相关。
如果您能提供任何有关进一步排除故障的提示,我将不胜感激。非常感谢!
完整错误日志:
This is LuaHBTeX, Version 1.15.0 (TeX Live 2022) (format=lualatex 2022.5.29) 29 MAY 2022 04:10
system commands enabled.
file:line:error style messages enabled.
**test.tex
(./test.tex
LaTeX2e <2021-11-15> patch level 1
Lua module: luaotfload 2022-03-18 3.21 Lua based OpenType font support
Lua module: lualibs 2021-05-20 2.74 ConTeXt Lua standard libraries.
Lua module: lualibs-extended 2021-05-20 2.74 ConTeXt Lua libraries -- extended collection.
luaotfload | conf : Root cache directory is "/Users/<USER>/Library/texlive/2022/texmf-var/luatex-cache/generic/names".
luaotfload | init : Loading fontloader "fontloader-2022-02-24.lua" from kpse-resolved path "/usr/local/texlive/2022/texmf-dist/tex/luatex/luaotfload/fontloader-2022-02-24.lua".
Lua-only attribute luaotfload@noligature = 1
luaotfload | init : Context OpenType loader version 3.119
Inserting `luaotfload.node_processor' at position 1 in `pre_linebreak_filter'.
Inserting `luaotfload.node_processor' at position 1 in `hpack_filter'.
Inserting `luaotfload.glyph_stream' at position 1 in `glyph_stream_provider'.
Inserting `luaotfload.define_font' at position 1 in `define_font'.
Lua-only attribute luaotfload_color_attribute = 2
luaotfload | conf : Root cache directory is "/Users/<USER>/Library/texlive/2022/texmf-var/luatex-cache/generic/names".
Inserting `luaotfload.harf.strip_prefix' at position 1 in `find_opentype_file'.
Inserting `luaotfload.harf.strip_prefix' at position 1 in `find_truetype_file'.
Removing `luaotfload.glyph_stream' from `glyph_stream_provider'.
Inserting `luaotfload.harf.glyphstream' at position 1 in `glyph_stream_provider'.
Inserting `luaotfload.harf.finalize_vlist' at position 1 in `post_linebreak_filter'.
Inserting `luaotfload.harf.finalize_hlist' at position 2 in `hpack_filter'.
Inserting `luaotfload.cleanup_files' at position 1 in `wrapup_run'.
Inserting `luaotfload.harf.finalize_unicode' at position 1 in `finish_pdffile'.
Inserting `luaotfload.glyphinfo' at position 1 in `glyph_info'.
Lua-only attribute luaotfload.letterspace_done = 3
Inserting `luaotfload.aux.set_sscale_dimens' at position 1 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.set_font_index' at position 2 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.patch_cambria_domh' at position 3 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.fixup_fontdata' at position 1 in `luaotfload.patch_font_unsafe'.
Inserting `luaotfload.aux.set_capheight' at position 4 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.set_xheight' at position 5 in `luaotfload.patch_font'.
Inserting `luaotfload.rewrite_fontname' at position 6 in `luaotfload.patch_font'. L3 programming layer <2022-05-04>
Inserting `tracingstacklevels' at position 1 in `input_level_string'. (/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
luaotfload | db : Font names database loaded from /Users/<USER>/Library/texlive/2022/texmf-var/luatex-cache/generic/names/luaotfload-names.luc.gz)
\c@part=\count183
\c@section=\count184
\c@subsection=\count185
\c@subsubsection=\count186
\c@paragraph=\count187
\c@subparagraph=\count188
\c@figure=\count189
\c@table=\count190
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen137
) (/usr/local/texlive/2022/texmf-dist/tex/latex/fontspec/fontspec.sty (/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/xparse/xparse.sty (/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2022-05-04 L3 programming layer (loader)
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-luatex.def
File: l3backend-luatex.def 2022-04-20 L3 backend support: PDF output (LuaTeX)
\l__color_backend_stack_int=\count191
\l__pdf_internal_box=\box50
))
Package: xparse 2022-01-12 L3 Experimental document command parser
)
Package: fontspec 2022/01/15 v2.8a Font selection for XeLaTeX and LuaLaTeX
Lua module: fontspec 2022/01/15 2.8a Font selection for XeLaTeX and LuaLaTeX (/usr/local/texlive/2022/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
Package: fontspec-luatex 2022/01/15 v2.8a Font selection for XeLaTeX and LuaLaTeX
\l__fontspec_script_int=\count192
\l__fontspec_language_int=\count193
\l__fontspec_strnum_int=\count194
\l__fontspec_tmp_int=\count195
\l__fontspec_tmpa_int=\count196
\l__fontspec_tmpb_int=\count197
\l__fontspec_tmpc_int=\count198
\l__fontspec_em_int=\count199
\l__fontspec_emdef_int=\count266
\l__fontspec_strong_int=\count267
\l__fontspec_strongdef_int=\count268
\l__fontspec_tmpa_dim=\dimen138
\l__fontspec_tmpb_dim=\dimen139
\l__fontspec_tmpc_dim=\dimen140
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2021/04/29 v2.0v Standard LaTeX package
) (/usr/local/texlive/2022/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
./test.tex:11: Package fontspec Error: The font "Rubik-Regular" cannot be found.
For immediate help type H <return>.
...
l.11 ]
A font might not be found for many reasons.
Check the spelling, where the font is installed etc. etc.
When in doubt, ask someone for help!
luaotfload | aux : no font with id 0
luaotfload | aux : no font with id 0
./test.tex:11: Package fontspec Error: The font "Rubik-Regular" cannot be found.
For immediate help type H <return>.
...
l.11 ]
A font might not be found for many reasons.
Check the spelling, where the font is installed etc. etc.
When in doubt, ask someone for help!
./test.tex:11: Package fontspec Error: The font "Rubik-Regular" cannot be found.
For immediate help type H <return>.
...
l.11 ]
A font might not be found for many reasons.
Check the spelling, where the font is installed etc. etc.
When in doubt, ask someone for help!
Package fontspec Info: Font family 'Rubik-Regular.ttf(0)' created for font
(fontspec) 'Rubik-Regular.ttf' with options [Ligatures=TeX,Path =
(fontspec) /Users/<USER>/Library/Fonts/].
(fontspec)
(fontspec) This font family consists of the following NFSS
(fontspec) series/shapes:
(fontspec)
(fontspec) - 'normal' (m/n) with NFSS spec.:
(fontspec) <->"[/Users/<USER>/Library/Fonts/Rubik-Regular.ttf]:mode=node;language=dflt;+tlig;"
(fontspec) - 'small caps' (m/sc) with NFSS spec.:
(./build/test.aux)
\openout1 = test.aux
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 13.
LaTeX Font Info: Trying to load font information for TS1+cmr on input line 13.
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd
File: ts1cmr.fd 2019/12/16 v2.5j Standard LaTeX font definitions
)
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for TU/lmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
Package fontspec Info: Adjusting the maths setup (use [no-math] to avoid
(fontspec) this).
\symlegacymaths=\mathgroup4
LaTeX Font Info: Overwriting symbol font `legacymaths' in version `bold'
(Font) OT1/cmr/m/n --> OT1/cmr/bx/n on input line 13.
LaTeX Font Info: Redeclaring math accent \acute on input line 13.
LaTeX Font Info: Redeclaring math accent \grave on input line 13.
LaTeX Font Info: Redeclaring math accent \ddot on input line 13.
LaTeX Font Info: Redeclaring math accent \tilde on input line 13.
LaTeX Font Info: Redeclaring math accent \bar on input line 13.
LaTeX Font Info: Redeclaring math accent \breve on input line 13.
LaTeX Font Info: Redeclaring math accent \check on input line 13.
LaTeX Font Info: Redeclaring math accent \hat on input line 13.
LaTeX Font Info: Redeclaring math accent \dot on input line 13.
LaTeX Font Info: Redeclaring math accent \mathring on input line 13.
LaTeX Font Info: Redeclaring math symbol \colon on input line 13.
LaTeX Font Info: Redeclaring math symbol \Gamma on input line 13.
LaTeX Font Info: Redeclaring math symbol \Delta on input line 13.
LaTeX Font Info: Redeclaring math symbol \Theta on input line 13.
LaTeX Font Info: Redeclaring math symbol \Lambda on input line 13.
LaTeX Font Info: Redeclaring math symbol \Xi on input line 13.
LaTeX Font Info: Redeclaring math symbol \Pi on input line 13.
LaTeX Font Info: Redeclaring math symbol \Sigma on input line 13.
LaTeX Font Info: Redeclaring math symbol \Upsilon on input line 13.
LaTeX Font Info: Redeclaring math symbol \Phi on input line 13.
LaTeX Font Info: Redeclaring math symbol \Psi on input line 13.
LaTeX Font Info: Redeclaring math symbol \Omega on input line 13.
LaTeX Font Info: Redeclaring math symbol \mathdollar on input line 13.
LaTeX Font Info: Redeclaring symbol font `operators' on input line 13.
LaTeX Font Info: Encoding `OT1' has changed to `TU' for symbol font
(Font) `operators' in the math version `normal' on input line 13.
LaTeX Font Info: Overwriting symbol font `operators' in version `normal'
(Font) OT1/cmr/m/n --> TU/lmr/m/n on input line 13.
LaTeX Font Info: Encoding `OT1' has changed to `TU' for symbol font
(Font) `operators' in the math version `bold' on input line 13.
LaTeX Font Info: Overwriting symbol font `operators' in version `bold'
(Font) OT1/cmr/bx/n --> TU/lmr/m/n on input line 13.
LaTeX Font Info: Overwriting symbol font `operators' in version `normal'
(Font) TU/lmr/m/n --> TU/lmr/m/n on input line 13.
LaTeX Font Info: Overwriting math alphabet `\mathit' in version `normal'
(Font) OT1/cmr/m/it --> TU/lmr/m/it on input line 13.
LaTeX Font Info: Overwriting math alphabet `\mathbf' in version `normal'
(Font) OT1/cmr/bx/n --> TU/lmr/b/n on input line 13.
LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `normal'
(Font) OT1/cmss/m/n --> TU/Rubik-Regular.ttf(0)/m/n on input line 13.
LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `normal'
(Font) OT1/cmtt/m/n --> TU/lmtt/m/n on input line 13.
LaTeX Font Info: Overwriting symbol font `operators' in version `bold'
(Font) TU/lmr/m/n --> TU/lmr/b/n on input line 13.
LaTeX Font Info: Overwriting math alphabet `\mathit' in version `bold'
(Font) OT1/cmr/bx/it --> TU/lmr/b/it on input line 13.
LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `bold'
(Font) OT1/cmss/bx/n --> TU/Rubik-Regular.ttf(0)/b/n on input line 13.
LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `bold'
(Font) OT1/cmtt/m/n --> TU/lmtt/b/n on input line 13.
[1
{/usr/local/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./build/test.aux))
Here is how much of LuaTeX's memory you used:
2798 strings out of 477742
100000,552014 words of node,token memory allocated
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: 2:23,3:4,4:1,5:23,6:2,7:46,9:18,11:2
23571 multiletter control sequences out of 65536+600000
16 fonts using 856399 bytes
72i,5n,79p,237b,243s stack positions out of 10000i,1000n,20000p,200000b,200000s
</usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf>
Output written on test.pdf (1 page, 3288 bytes).
PDF statistics: 15 PDF objects out of 1000 (max. 8388607)
8 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 131072)
1 words of extra memory for PDF output out of 10000 (max. 100000000)
答案1
由于一些不寻常的表,该字体会触发 Node 字体加载器中的错误。此问题将在下一个 luaotfload 版本中修复,在此之前,您可以通过指定Renderer=HarfBuzz
使用不受影响的基于 HarfBuzz 的字体加载器来使用它:
\documentclass{article}
\usepackage{fontspec}
\setsansfont{Rubik}[
Renderer = HarfBuzz,
]
\begin{document}
\textsf{Test.}
\end{document}
如果您想知道为什么错误消息显示“无法找到字体“Rubik-Regular””:LuaTeX 中的字体加载基本上要么成功要么失败,它不会说明失败的原因。由于未找到字体是迄今为止无法加载字体的最常见原因,因此错误消息就是这样说的,但实际上它只是表明“某些事情”出了问题。