附加資訊

附加資訊

我已經下載了這兩種字體:

我跑步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。

fontspec2024/02/13 v2.9a

這是目前 CTAN 上的版本fontspec(2024-04-27)。

相關內容