-
Notifications
You must be signed in to change notification settings - Fork 36
Description
The question is based on this specific font file:
Claim that, since github foesn't support .ttf file, I have to zip the 楷体_GB2312.ttf to upload, and it's hard for me to provide official link to get this font, I was sure that this would not cause copyright issues.
Inside the font.zip, ther would be a 楷体_GB2312.ttf file:
As normal, if installed syetem-wide properly, the fc-list information would be:
$ fs-list
C:/WINDOWS/fonts/楷体_GB2312.ttf: KaiTi_GB2312,???_GB2312:style=Regular
And the otfinfo -i 楷体_GB2312.ttf gives:
$ otfinfo -i 楷体_GB2312.ttf
Family: KaiTi_GB2312
Subfamily: Regular
Full name: KaiTi_GB2312
PostScript name: KaiTi_GB2312
Version: Version 2.00
Unique ID: KaiTi_GB2312
Trademark: Trademark of GreatWall Co., Beijing
Copyright: (C) Copyright GreatWall Computer Co. 1994
Vendor ID: GWIN
Permissions: Installable
My issues want to report is the "font family name" loading approach.
Noted that with "font file name", for example \setmainfont{楷体_GB2312.ttf}, the case is okay.
first example
\documentclass{article}
\usepackage{fontspec}
\setmainfont{KaiTi_GB2312}
\begin{document}
abcde测试
\end{document}
- With
lualatex, it works okay!!! - However, With
xelatex, it reported font not found:
This is XeTeX, Version 3.141592653-2.6-0.999997 (TeX Live 2025) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./aaa.tex
LaTeX2e <2025-11-01>
L3 programming layer <2025-11-14>
(c:/texlive/2025/texmf-dist/tex/latex/base/article.cls
Document Class: article 2025/01/22 v1.4n Standard LaTeX document class
(c:/texlive/2025/texmf-dist/tex/latex/base/size10.clo))
(c:/texlive/2025/texmf-dist/tex/latex/fontspec/fontspec.sty
(c:/texlive/2025/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(c:/texlive/2025/texmf-dist/tex/latex/l3kernel/expl3.sty
(c:/texlive/2025/texmf-dist/tex/latex/l3backend/l3backend-xetex.def)))
(c:/texlive/2025/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(c:/texlive/2025/texmf-dist/tex/latex/base/fontenc.sty)
(c:/texlive/2025/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
kpathsea: Running mktextfm KaiTi_GB2312
The command name is C:\texlive\2025\bin\windows\mktextfm
kpathsea: Running mktexmf KaiTi_GB2312.mf
The command name is C:\texlive\2025\bin\windows\mktexmf
name = KaiTi_GB2312, rootname = KaiTi_GB, pointsize = 2312
mktexmf: empty or non-existent rootfile!
Cannot find KaiTi_GB2312.mf.
kpathsea: Appending font creation commands to missfont.log.
! Package fontspec Error:
(fontspec) The font "KaiTi_GB2312" cannot be found; this may
(fontspec) be but usually is not a fontspec bug. Either there
(fontspec) is a typo in the font name/file, the font is not
(fontspec) installed (correctly), or there is a bug in the
(fontspec) underlying font loading engine (XeTeX/luaotfload).
For immediate help type H <return>.
...
l.5 \begin
{document}
?
second example
or the better CJK-linebreak-friendly xeCJK version:
\documentclass{article}
\usepackage{xeCJK}
% \setCJKmainfont{KaiTi_GB2312}
\setmainfont{楷体_GB2312.ttf} %<- only this "font file name" loading work....
\begin{document}
abcde测试
\end{document}
This mwe xeCJK only supported xelatex, and it get the same fonts not found error as above.....
third example
\documentclass{article}
\usepackage{luatexja-fontspec}
% \setmainfont{Noto Serif CJK SC}
\setmainjfont{KaiTi_GB2312} % work with lualatex
\begin{document}
abcde测试
\end{document}
The luatexja-fontspec font selection scheme works with lualatex.
So, the xelatex is to be blame.
It looks like that with "family name"---KaiTi_GB2312 doesn't work on my windows 11 machine only with xelatex?! but okay for lualatex!!. It's rather strange for me. Other fonts, for example Noto Serif CJK SC, works on my machine as normal with both xelatex and lualatex:
I was afriad that the 楷体_GB2312.ttf file, itself has something different..... Is this the bug of fontspec with xelatex, or the broken font file that jointly cause this issues?
Edited
In summary, now all the fonts case I was confront is as below:
| `fontspec`'s *font family name* loading | xelatex | lualatex |
| Most font(for instance `Noto Serif CJK SC`) | okay | okay |
| Some "bad" font(for instance `KaiTi_GB2312`) | Fonts Not Found | okay |