我已经下载了这两种字体:
NotoSansMonoCJKSC-VF.otf
(Github 官方仓库文件的永久链接)NotoSansMonoCJKsc-Regular.otf
(Github 官方仓库文件的永久链接)
我运行fc-cache -f -v
,所以fc-list
知道这些字体。
fc-list | grep '\.fonts' | grep 'NotoSansMonoCJKsc'
/home/rodrigo/.fonts/NotoSansMonoCJKsc-VF.otf: Noto Sans Mono CJK SC:style=Medium
/home/rodrigo/.fonts/NotoSansMonoCJKsc-Regular.otf: Noto Sans Mono CJK SC:style=Regular
/home/rodrigo/.fonts/NotoSansMonoCJKsc-VF.otf: Noto Sans Mono CJK SC
/home/rodrigo/.fonts/NotoSansMonoCJKsc-VF.otf: Noto Sans Mono CJK SC:style=Bold
/home/rodrigo/.fonts/NotoSansMonoCJKsc-VF.otf: Noto Sans Mono CJK SC:style=Regular
使用时NotoSansMonoCJKsc-Regular.otf
,文档编译没有问题。
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont[
Path = {\string~/.fonts/},
Extension = .otf
]{NotoSansMonoCJKsc-Regular}
\begin{document}
你好!
\end{document}
xelatex /tmp/main.tex
This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(/tmp/main.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-03-14>
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2024/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-xetex.def))
(/usr/local/texlive/2024/texmf-dist/tex/latex/ctex/ctexhook.sty)
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.st
y
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate-20
23-10-10.sty))
(/usr/local/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/local/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/fontenc.sty)
(/usr/local/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2024/texmf-dist/tex/xelatex/xecjk/xeCJK.cfg)) (./main.aux)
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/ts1cmr.fd) [1] (./main.aux)
)
Output written on main.pdf (1 page).
Transcript written on main.log.
然而,当我使用时NotoSansMonoCJKSC-VF.otf
,会显示该消息file main.pdf may not be valid.
以及一些其他错误。
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont[
Path = {\string~/.fonts/},
Extension = .otf
]{NotoSansMonoCJKsc-VF}
\begin{document}
你好!
\end{document}
xelatex /tmp/main.tex
This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(/tmp/main.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-03-14>
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2024/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-xetex.def))
(/usr/local/texlive/2024/texmf-dist/tex/latex/ctex/ctexhook.sty)
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.st
y
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate-20
23-10-10.sty))
(/usr/local/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/local/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/fontenc.sty)
(/usr/local/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2024/texmf-dist/tex/xelatex/xecjk/xeCJK.cfg)) (./main.aux)
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/ts1cmr.fd) [1] (./main.aux)
xdvipdfmx:fatal: Invalid font: -1 (0)
No output PDF file written.
)
Error 256 (driver return code) generating output;
file main.pdf may not be valid.
Transcript written on main.log.
我猜想发生这种情况是因为xelatex
尚不支持可变字体。
如果xelatex
支持可变字体,有人能告诉我为什么我的系统在尝试编译文档时显示这些错误吗?
如果xelatex
不支持可变字体,如果有人可以提供可靠的来源说明这一点或源代码中的某些部分以便我得出这一结论,我将不胜感激。
附加信息
VF
对于那些不知道文件名中的含义的人来说NotoSansMonoCJKSC-VF
,它代表“可变字体”(维基百科文章链接)。
我发现这个问题在 lists.fedoraproject.org 邮件列表中提到了使用可变字体编译文档的相同问题xelatex
。
下面显示的代码块显示了的版本xelatex
,我用它来编译上面显示的两个文档。
xelatex --version
XeTeX 3.141592653-2.6-0.999996 (TeX Live 2024)
kpathsea version 6.4.0
Copyright 2024 SIL International, Jonathan Kew and Khaled Hosny.
There is NO warranty. Redistribution of this software is
covered by the terms of both the XeTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the XeTeX source.
Primary author of XeTeX: Jonathan Kew.
Compiled with ICU version 74.2; using 74.2
Compiled with zlib version 1.3.1; using 1.3.1
Compiled with FreeType2 version 2.13.2; using 2.13.2
Compiled with Graphite2 version 1.3.14; using 1.3.14
Compiled with HarfBuzz version 8.3.0; using 8.3.0
Compiled with libpng version 1.6.43; using 1.6.43
Compiled with pplib version v2.2
Compiled with fontconfig version 2.13.0; using 2.13.1
答案1
阅读fontspec
文档后,似乎只有 LuaLaTeX 支持可变字体;fontspec
最近在 2.9a 版本中添加了对它们的支持。
答案2
根据文档,当前fontspec
XeTeX 支持 Multiple Master 字体,但不支持 Variable 字体,而 LuaTeX 支持 Variable 字体但不支持 Multiple Master 字体。
fontspec.pdf
第 7 节第 32 页:
目前 OpenType 可变字体仅支持 LuaTeX,而 Multiple Master 字体仅适用于 XeTeX。
fontspec
2024/02/13 v2.9a
这是目前 CTAN 上的版本fontspec
(2024-04-27)。