% \iffalse meta-comment
%
% File: ctex-fontset.dtx
% -----------------------------------------------------------------------
% Copyright (C) 2003--2026
% CTEX.ORG and any individual authors listed elsewhere in this file.
% -----------------------------------------------------------------------
% This work may be distributed and/or modified under the conditions *
% of the LaTeX Project Public License (LPPL), either version 1.3c of *
% this license or (at your option) any later version. *
% The latest version of this license is in *
% *
% http://www.latex-project.org/lppl.txt *
% *
% and version 1.3c or later is part of all distributions of LaTeX *
% version 2008 or later. *
% *
% This work has the LPPL maintenance status `maintained'. *
% -----------------------------------------------------------------------
% This work consists of the files ctex.dtx, *
% ctex-kernel.dtx, *
% ctex-engine.dtx, *
% ctex-scheme.dtx, *
% ctex-auxpkg.dtx, *
% ctex-fontset.dtx, *
% ctexpunct.spa, *
% ctxdoc.cls, *
% ctxdocstrip.tex, *
% ctex-zhconv.lua, *
% ctex-zhconv-index.lua, *
% ctex-zhconv-make.lua, *
% the derived files ctex.ins, *
% ctex.sty, *
% ctexsize.sty, *
% ctexheading.sty, *
% ctexart.cls, *
% ctexbook.cls, *
% ctexrep.cls, *
% ctexbeamer.cls, *
% ctexcap.sty, *
% ctexhook.sty, *
% ctexpatch.sty, *
% ctex-c5size.clo, *
% ctex-cs4size.clo, *
% ctex-heading-article.def, *
% ctex-heading-book.def, *
% ctex-heading-report.def, *
% ctex-heading-beamer.def, *
% ctexbackend.cfg, *
% ctex-engine-pdftex.def, *
% ctex-engine-xetex.def, *
% ctex-engine-luatex.def, *
% ctex-engine-aptex.def, *
% ctex-engine-uptex.def, *
% ctex-name-utf8.cfg, *
% ctex-name-gbk.cfg, *
% ctex.cfg, *
% ctexopts.cfg, *
% ctex-scheme-plain.def, *
% ctex-scheme-plain-article.def, *
% ctex-scheme-plain-book.def, *
% ctex-scheme-plain-report.def, *
% ctex-scheme-plain-beamer.def, *
% ctex-scheme-chinese.def, *
% ctex-scheme-chinese-article.def, *
% ctex-scheme-chinese-book.def, *
% ctex-scheme-chinese-report.def, *
% ctex-scheme-chinese-beamer.def, *
% ctex-fontset-adobe.def, *
% ctex-fontset-fandol.def, *
% ctex-fontset-founder.def, *
% ctex-fontset-hanyi.def, *
% ctex-fontset-mac.def, *
% ctex-fontset-macnew.def, *
% ctex-fontset-macold.def, *
% ctex-fontset-ubuntu.def, *
% ctex-fontset-windows.def, *
% c19rm.fd, *
% c19sf.fd, *
% c19tt.fd, *
% c70rm.fd, *
% c70sf.fd, *
% c70tt.fd, *
% jy2zhrm.fd, *
% jy2zhsf.fd, *
% jy2zhtt.fd, *
% jt2zhrm.fd, *
% jt2zhsf.fd, *
% jt2zhtt.fd, *
% ctexspa.def, *
% translator-theorem-dictionary-ChineseUTF8.dict, *
% translator-theorem-dictionary-ChineseGBK.dict, *
% ctex-spa-make.tex, *
% ctex-spa-macro.tex, *
% ctex-zhmap-adobe.tex, *
% ctex-zhmap-fandol.tex, *
% ctex-zhmap-founder.tex, *
% ctex-zhmap-hanyi.tex, *
% ctex-zhmap-mac.tex, *
% ctex-zhmap-ubuntu.tex, *
% ctex-zhmap-windows.tex, *
% the documentation files ctex.pdf, *
% and README.md. *
% -----------------------------------------------------------------------
% *
% Any modification of this file should ensure that the copyright and *
% license information is placed in the derived files. *
% *
% -----------------------------------------------------------------------
%
%<*!driver>
%<*fd|zhmap>
%\catcode`\ 10\relax \catcode`\^^I9\relax \catcode`\^^M5\relax
\def \GetIdInfo $Id: #1.#2 #3 #4-#5-#6 #7$ #8{%
\edef \ExplFileDate {#4/#5/#6}%
\edef \ExplFileVersion {#3}%
\edef \ExplFileDescription{#8}}%
%
%<*!spa>
%<+!driver>\GetIdInfo $Id: ctex-fontset.dtx 2.6.2 2026-07-06 02:16:01 +0800 5dd4f341 Liam $
%!spa>
%<*fontset>
% {Windows fonts definition (CTEX)}
%\ProvidesExplFile{ctex-fontset-windows.def}
% {Adobe fonts definition (CTEX)}
%\ProvidesExplFile{ctex-fontset-adobe.def}
% {Fandol fonts definition (CTEX)}
%\ProvidesExplFile{ctex-fontset-fandol.def}
% {macOS fonts definition (CTEX)}
%\ProvidesExplFile{ctex-fontset-mac.def}
% {macOS fonts definition for El Capitan or later version (CTEX)}
%\ProvidesExplFile{ctex-fontset-macnew.def}
% {macOS fonts definition for Yosemite or earlier version (CTEX)}
%\ProvidesExplFile{ctex-fontset-macold.def}
% {Founder fonts definition (CTEX)}
%\ProvidesExplFile{ctex-fontset-founder.def}
% {Hanyi fonts definition (CTEX)}
%\ProvidesExplFile{ctex-fontset-hanyi.def}
% {Ubuntu fonts definition (CTEX)}
%\ProvidesExplFile{ctex-fontset-ubuntu.def}
% {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
%
%<*zhmap>
% {Adobe font map loader for DVIPDFMx (CTEX)}%
% {Fandol font map loader for DVIPDFMx (CTEX)}%
% {Founder font map loader for pdfTeX and DVIPDFMx (CTEX)}%
% {Hanyi font map loader for pdfTeX and DVIPDFMx (CTEX)}%
% {Mac font map loader for DVIPDFMx (CTEX)}%
% {Ubuntu font map loader for DVIPDFMx (CTEX)}%
% {Windows font map loader for pdfTeX and DVIPDFMx (CTEX)}%
%
%<*fd|ctexspa>
% {Chinese font definition (CTEX)}%
%\catcode`\ 9\relax \catcode`\^^I9\relax \catcode`\^^M9\relax
% {Space info for CJKpunct (CTEX)}
%\ProvidesFile{c19rm.fd}%
%\ProvidesFile{c19sf.fd}%
%\ProvidesFile{c19tt.fd}%
%\ProvidesFile{c70rm.fd}%
%\ProvidesFile{c70sf.fd}%
%\ProvidesFile{c70tt.fd}%
%\ProvidesFile{jy2zhrm.fd}%
%\ProvidesFile{jy2zhsf.fd}%
%\ProvidesFile{jy2zhtt.fd}%
%\ProvidesFile{jt2zhrm.fd}%
%\ProvidesFile{jt2zhsf.fd}%
%\ProvidesFile{jt2zhtt.fd}%
%\ProvidesFile{ctexspa.def}%
% [\ExplFileDate\space v\ExplFileVersion\space \ExplFileDescription]
%
%!driver>
%
% \fi
%
% \begin{implementation}
%
% \paragraph*{\fbox{\file{\jobname-fontset.dtx}}}
%
% \begin{macrocode}
%<@@=ctex>
% \end{macrocode}
%
% \subsubsection{预定义字库}
%
% \begin{macrocode}
%<*fontset>
% \end{macrocode}
%
% \paragraph{\opt{adobe}}
%
% \tn{pdfmapline} 不支持 OpenType 字体,因而 \opt{adobe} 字体集在 pdf 模式下
% 就没有定义。\opt{fandol} 的情况类似。
% \begin{macrocode}
%<*adobe>
\ctex_fontset_case:nnnn
{ \ctex_fontset_error:n { adobe } }
{
\ctex_zhmap_case:nnn
{
\setCJKmainfont { AdobeSongStd-Light.otf }
[
cmap = UniGB-UTF16-H,
BoldFont = AdobeHeitiStd-Regular.otf,
ItalicFont = AdobeKaitiStd-Regular.otf
]
\setCJKsansfont { AdobeHeitiStd-Regular.otf }
[ cmap = UniGB-UTF16-H ]
\setCJKmonofont { AdobeFangsongStd-Regular.otf }
[ cmap = UniGB-UTF16-H ]
\setCJKfamilyfont { zhsong } { AdobeSongStd-Light.otf }
[ cmap = UniGB-UTF16-H ]
\setCJKfamilyfont { zhhei } { AdobeHeitiStd-Regular.otf }
[ cmap = UniGB-UTF16-H ]
\setCJKfamilyfont { zhkai } { AdobeKaitiStd-Regular.otf }
[ cmap = UniGB-UTF16-H ]
\setCJKfamilyfont { zhfs } { AdobeFangsongStd-Regular.otf }
[ cmap = UniGB-UTF16-H ]
\ctex_punct_set:n { adobe }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { adobe }
\ctex_punct_set:n { adobe }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{ \ctex_fontset_error:n { adobe } }
}
{
\ctex_set_upfonts:nnnnnn
{ AdobeSongStd-Light.otf }
{ AdobeHeitiStd-Regular.otf }
{ AdobeKaitiStd-Regular.otf }
{ AdobeHeitiStd-Regular.otf }
{ AdobeHeitiStd-Regular.otf }
{ AdobeFangsongStd-Regular.otf }
\ctex_set_upfamily:nnn { zhsong } { upzhserif } {}
\ctex_set_upfamily:nnn { zhhei } { upzhsans } {}
\ctex_set_upfamily:nnn { zhfs } { upzhmono } {}
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
}
{
\setCJKmainfont { AdobeSongStd-Light }
[ BoldFont = AdobeHeitiStd-Regular, ItalicFont = AdobeKaitiStd-Regular ]
\setCJKsansfont { AdobeHeitiStd-Regular }
\setCJKmonofont { AdobeFangsongStd-Regular }
\setCJKfamilyfont { zhsong } { AdobeSongStd-Light }
\setCJKfamilyfont { zhhei } { AdobeHeitiStd-Regular }
\setCJKfamilyfont { zhfs } { AdobeFangsongStd-Regular }
\setCJKfamilyfont { zhkai } { AdobeKaitiStd-Regular }
}
%
% \end{macrocode}
%
% \paragraph{\opt{fandol}}
%
% \begin{macrocode}
%<*fandol>
\ctex_fontset_case:nnnn
{ \ctex_fontset_error:n { fandol } }
{
\ctex_zhmap_case:nnn
{
\setCJKmainfont { FandolSong-Regular.otf }
[
cmap = UniGB-UTF16-H,
BoldFont = FandolSong-Bold.otf,
ItalicFont = FandolKai-Regular.otf
]
\setCJKsansfont { FandolHei-Regular.otf }
[ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf ]
\setCJKmonofont { FandolFang-Regular.otf }
[ cmap = UniGB-UTF16-H ]
\setCJKfamilyfont { zhsong } { FandolSong-Regular.otf }
[ cmap = UniGB-UTF16-H, BoldFont = FandolSong-Bold.otf ]
\setCJKfamilyfont { zhhei } { FandolHei-Regular.otf }
[ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf ]
\setCJKfamilyfont { zhfs } { FandolFang-Regular.otf }
[ cmap = UniGB-UTF16-H ]
\setCJKfamilyfont { zhkai } { FandolKai-Regular.otf }
[ cmap = UniGB-UTF16-H ]
\ctex_punct_set:n { fandol }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
\ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhheib }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { fandol }
\ctex_punct_set:n { fandol }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{ \ctex_fontset_error:n { fandol } }
}
{
\ctex_set_upfonts:nnnnnn
{ FandolSong-Regular.otf }
{ FandolSong-Bold.otf }
{ FandolKai-Regular.otf }
{ FandolHei-Regular.otf }
{ FandolHei-Bold.otf }
{ FandolFang-Regular.otf }
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb }
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb }
\ctex_set_upfamily:nnn { zhfs } { upzhmono } {}
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
}
{
\setCJKmainfont { FandolSong-Regular }
[
Extension = .otf,
BoldFont = FandolSong-Bold,
ItalicFont = FandolKai-Regular
]
\setCJKsansfont { FandolHei-Regular }
[ Extension = .otf, BoldFont = FandolHei-Bold ]
\setCJKmonofont { FandolFang-Regular }
[ Extension = .otf ]
\setCJKfamilyfont { zhsong } { FandolSong-Regular }
[ Extension = .otf, BoldFont = FandolSong-Bold ]
\setCJKfamilyfont { zhhei } { FandolHei-Regular }
[ Extension = .otf, BoldFont = FandolHei-Bold ]
\setCJKfamilyfont { zhfs } { FandolFang-Regular }
[ Extension = .otf ]
\setCJKfamilyfont { zhkai } { FandolKai-Regular }
[ Extension = .otf ]
}
%
% \end{macrocode}
%
% \paragraph{\opt{founder}}
%
% \changes{v2.4.15}{2019/03/28}{统一“方正细黑一\_GBK”的名称为 \texttt{FZXiHeiI-Z08}。}
%
% \begin{macrocode}
%<*founder>
\ctex_fontset_case:nnn
{
\ctex_zhmap_case:nnn
{
\setCJKmainfont { FZSSK.TTF }
[ BoldFont = FZXBSK.TTF, ItalicFont = FZKTK.TTF ]
\setCJKsansfont { FZXH1K.TTF } [ BoldFont = FZHTK.TTF ]
\setCJKmonofont { FZFSK.TTF }
\setCJKfamilyfont { zhsong } { FZSSK.TTF } [ BoldFont = FZXBSK.TTF ]
\setCJKfamilyfont { zhhei } { FZHTK.TTF }
\setCJKfamilyfont { zhkai } { FZKTK.TTF }
\setCJKfamilyfont { zhfs } { FZFSK.TTF }
\setCJKfamilyfont { zhli } { FZLSK.TTF }
\setCJKfamilyfont { zhyou } { FZY1K.TTF } [ BoldFont = FZY3K.TTF ]
\ctex_punct_set:n { founder }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_family:nn { \CJKsfdefault } { zhheil }
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
\ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
\ctex_punct_map_bfseries:nn { \CJKsfdefault } { zhhei }
\ctex_punct_map_bfseries:nn { zhyou } { zhyoub }
}
{
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { founder }
\ctex_punct_set:n { founder }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{ \ctex_fontset_error:n { founder } }
}
{
\ctex_set_upfonts:nnnnnn
{ FZSSK.TTF }
{ FZXBSK.TTF }
{ FZKTK.TTF }
{ FZXH1K.TTF }
{ FZHTK.TTF }
{ FZFSK.TTF }
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb }
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb }
\ctex_set_upfamily:nnn { zhfs } { upzhmono } {}
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
\ctex_set_upfamily:nnn { zhli } { upschrm } {}
\ctex_set_upfamily:nnn { zhyou } { upschgt } {}
\ctex_set_upmap:nnn { upstsl } { FZLSK.TTF } {}
\ctex_set_upmap:nnn { upstht } { FZY1K.TTF } {}
}
{
\setCJKmainfont { FZShuSong-Z01 }
[ BoldFont = FZXiaoBiaoSong-B05, ItalicFont = FZKai-Z03 ]
\setCJKsansfont { FZXiHeiI-Z08 } [ BoldFont = FZHei-B01 ]
\setCJKmonofont { FZFangSong-Z02 }
\setCJKfamilyfont { zhsong } { FZShuSong-Z01 }
[ BoldFont = FZXiaoBiaoSong-B05 ]
\setCJKfamilyfont { zhhei } { FZHei-B01 }
\setCJKfamilyfont { zhkai } { FZKai-Z03 }
\setCJKfamilyfont { zhfs } { FZFangSong-Z02 }
\setCJKfamilyfont { zhli } { FZLiShu-S01 }
\setCJKfamilyfont { zhyou } { FZXiYuan-M01 }
[ BoldFont = FZZhunYuan-M02 ]
}
%
% \end{macrocode}
%
% \paragraph{\opt{hanyi}}
%
% \begin{macrocode}
%<*hanyi>
\ctex_fontset_case:nnn
{
\ctex_zhmap_case:nnn
{
\setCJKmainfont { HYShuSongErS.ttf }
[ BoldFont = HYZhongSongS.ttf, ItalicFont = HYKaiTiS.ttf ]
\setCJKsansfont { HYZhongHeiS.ttf } [ BoldFont = HYDaHeiS.ttf ]
\setCJKmonofont { HYFangSongS.ttf }
\setCJKfamilyfont { zhsong } { HYShuSongErS.ttf }
[ BoldFont = HYZhongSongS.ttf ]
\setCJKfamilyfont { zhhei } { HYZhongHeiS.ttf }
[ BoldFont = HYDaHeiS.ttf ]
\setCJKfamilyfont { zhkai } { HYKaiTiS.ttf }
\setCJKfamilyfont { zhfs } { HYFangSongS.ttf }
\ctex_punct_set:n { hanyi }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
\ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhheib }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { hanyi }
\ctex_punct_set:n { hanyi }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{ \ctex_fontset_error:n { hanyi } }
}
{
\ctex_set_upfonts:nnnnnn
{ HYShuSongErS.ttf }
{ HYZhongSongS.ttf }
{ HYKaiTiS.ttf }
{ HYZhongHeiS.ttf }
{ HYDaHeiS.ttf }
{ HYFangSongS.ttf }
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb }
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb }
\ctex_set_upfamily:nnn { zhfs } { upzhmono } {}
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
}
{
\setCJKmainfont { HYShuSongEr~S }
[ BoldFont = HYZhongSong~S, ItalicFont = HYKaiTi~S ]
\setCJKsansfont { HYZhongHei~S } [ BoldFont = HYDaHei~S ]
\setCJKmonofont { HYFangSong~S }
\setCJKfamilyfont { zhsong } { HYShuSongEr~S }
[ BoldFont = HYZhongSong~S ]
\setCJKfamilyfont { zhhei } { HYZhongHei~S }
[ BoldFont = HYDaHei~S ]
\setCJKfamilyfont { zhkai } { HYKaiTi~S }
\setCJKfamilyfont { zhfs } { HYFangSong~S }
}
%
% \end{macrocode}
%
% \changes{v2.5.2}{2020/05/06}
% {修正 \opt{macnew} 和 \opt{ubuntu} 字库的 \pkg{CJKpunct} 标点信息。}
%
% \paragraph{\opt{mac} 相关}
%
% \changes{v2.4.14}{2018/05/01}{区分 \opt{macold} 及 \opt{macnew}。}
% \changes{v2.6.0}{2026/04/29}{\opt{macnew} 增加 macOS~15+ 兼容,字体运行时检测。}
%
% 按 \href{https://github.com/CTeX-org/ctex-kit/issues/351}{Issue 351}
% 的讨论,以 El Capitan 为分界,分别设置 |macold|(El Capitan 之前)
% 和 |macnew|(El Capitan 及之后)。检测方式则以 El Capitan 及之后
% 的苹方字体为准。从 macOS~15 (Sequoia) 开始,苹方字体转为
% \emph{downloadable},不再位于传统路径,故增加版本号检测作为后备。
%
% \begin{macrocode}
%<*mac>
\tl_new:N \g_@@_macos_ver_tl
\msg_new:nnn { ctex } { macos-version-detect-failed }
{ Cannot~detect~macOS~version.~Falling~back~to~macold~fontset. }
% \end{macrocode}
% 为方便人类阅读,把 \LuaTeX{} 分支挪到后面,在不忽略空格的 catcode scheme 下编写。
% 这样 Lua 代码就不必以 |~| 代替空格。非 \LuaTeX{} 分支,在末尾使用
% \cs{use_none_delimit_by_q_stop:w} 来跳过 \LuaTeX{} 分支。
% \begin{macrocode}
\sys_if_engine_luatex:F
{
\ior_new:N \g_@@_macos_ver_ior
\bool_new:N \g_@@_macos_ver_found_bool
\file_if_exist:nT { /System/Library/CoreServices/SystemVersion.plist }
{
\ior_open:Nn \g_@@_macos_ver_ior
{ /System/Library/CoreServices/SystemVersion.plist }
\ior_map_inline:Nn \g_@@_macos_ver_ior
{
\bool_if:NTF \g_@@_macos_ver_found_bool
{
\tl_set:Nn \l_tmpa_tl {#1}
\regex_replace_once:nnN
{ .*? (\d+) .* } { \1 } \l_tmpa_tl
\tl_gset:NV \g_@@_macos_ver_tl \l_tmpa_tl
\ior_map_break:
}
{
\tl_if_in:nnT {#1} { ProductVersion }
{ \bool_gset_true:N \g_@@_macos_ver_found_bool }
}
}
\ior_close:N \g_@@_macos_ver_ior
}
\use_none_delimit_by_q_stop:w
}
\char_set_catcode_space:n { 32 }
\lua_now:n
{
local f = io.open("/System/Library/CoreServices/SystemVersion.plist", "r");
if f then
local content = f:read("*a");
f:close();
local ver = content:match("ProductVersion.-(.-)");
if ver then
local dot = ver:find(".", 1, true);
local major = dot and ver:sub(1, dot - 1) or ver;
if major then
token.set_macro("g_@@_macos_ver_tl", major, "global");
end;
end;
end
}
\char_set_catcode_ignore:n { 32 }
\use_none_delimit_by_q_stop:w \q_stop
\file_if_exist:nTF { /System/Library/Fonts/PingFang.ttc }
{ \ctex_file_input:n { ctex-fontset-macnew.def } }
{
\tl_if_empty:NTF \g_@@_macos_ver_tl
{
\msg_warning:nn { ctex } { macos-version-detect-failed }
\ctex_file_input:n { ctex-fontset-macold.def }
}
{
\int_compare:nNnTF { \g_@@_macos_ver_tl } < { 15 }
{ \ctex_file_input:n { ctex-fontset-macold.def } }
{ \ctex_file_input:n { ctex-fontset-macnew.def } }
}
}
%
% \end{macrocode}
%
% \changes{v2.4.14}{2018/05/01}{配置 \opt{macnew} 的默认字体设置。}
% \changes{v2.5}{2019/11/05}{为 \opt{macnew} 增加粗楷体、隶书和圆体的定义。}
% \changes{v2.5}{2019/11/07}{允许 \opt{macnew} 在 \LaTeX{} 和 \upLaTeX{} 下使用。}
%
% |macold| 的设置参考了
% \href{https://github.com/CTeX-org/ctex-kit/wiki/OS-X-Mavericks-(10.9)-预装的主要简体中文字体}^^A
% {OS X Mavericks (10.9) 预装的主要简体中文字体列表}。
%
% |macnew| 在默认字体设置方面,引入了多字重的宋体作为罗马字族,
% 以及引入了苹方黑体作为无衬线字族。
% 由于 Songti SC Light 的字重与 STSong 及 Windows 上的 SimSun 更接近,故默认字重
% 使用 Songti SC Light,而不带后缀的正常字重事实上没有使用。黑体、圆体等设置
% 也有类似的情况。
%
% \begin{macrocode}
%<*macold|macnew>
\ctex_fontset_case:nnnn
{
\ctex_fontset_error:n { mac }
\use_none_delimit_by_q_stop:w
}
%<*macold>
{ \ctex_fontset_error:n { macold } }
{ \ctex_fontset_error:n { macold } }
%
%<*macnew>
{
\ctex_zhmap_case:nnn
{
\setCJKmainfont { :3:Songti.ttc }
[
BoldFont = :1:Songti.ttc,
ItalicFont = :0:Kaiti.ttc,
BoldItalicFont = :3:Kaiti.ttc,
]
\setCJKsansfont { :2:PingFang.ttc } [ BoldFont = :8:PingFang.ttc ]
\setCJKmonofont { STFANGSO.ttf }
\setCJKfamilyfont { zhsong } { :3:Songti.ttc } [ BoldFont = :1:Songti.ttc ]
\setCJKfamilyfont { zhhei } { :2:PingFang.ttc } [ BoldFont = :8:PingFang.ttc ]
\setCJKfamilyfont { zhkai } { :0:Kaiti.ttc } [ BoldFont = :3:Kaiti.ttc ]
\setCJKfamilyfont { zhfs } { STFANGSO.ttf }
\setCJKfamilyfont { zhli } { :0:Baoli.ttc }
\setCJKfamilyfont { zhyou } { :4:Yuanti.ttc } [ BoldFont = :0:Yuanti.ttc ]
\ctex_punct_set:n { mac }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_family:nn { \CJKsfdefault } { zhpf }
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
\ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhpfb }
\ctex_punct_map_bfseries:nn { zhyou } { zhyoub }
}
{
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { mac }
\ctex_punct_set:n { mac }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_family:nn { \CJKsfdefault } { zhpf }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhpf }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{ \ctex_fontset_error:n { macnew } }
\use_none_delimit_by_q_stop:w
}
{
\ctex_set_upmap:nnn { upserif } { :3:Songti.ttc } { :1:Songti.ttc }
\ctex_set_upmap:nnn { upserifit } { :0:Kaiti.ttc } { }
\ctex_set_upmap:nnn { upstsl } { :0:Baoli.ttc } { }
\ctex_set_upmap:nnn { upstht } { :4:Yuanti.ttc } { }
\ctex_set_upmap_unicode:nnn { upsans } { :2:PingFang.ttc } { :8:PingFang.ttc }
\ctex_set_upmap_unicode:nnn { upmono } { STFANGSO.ttf } { }
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb }
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb }
\ctex_set_upfamily:nnn { zhfs } { upzhmono } { }
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } { }
\ctex_set_upfamily:nnn { zhli } { upschrm } { }
\ctex_set_upfamily:nnn { zhyou } { upschgt } { }
\use_none_delimit_by_q_stop:w
}
%
{
%<*macold>
\setCJKmainfont { STSong }
[ BoldFont = STHeiti, ItalicFont = STKaiti ]
\setCJKsansfont { STXihei } [ BoldFont = STHeiti ]
\setCJKmonofont { STFangsong }
\setCJKfamilyfont { zhsong } { STSong }
\setCJKfamilyfont { zhhei } { STHeiti }
\setCJKfamilyfont { zhfs } { STFangsong }
\setCJKfamilyfont { zhkai } { STKaiti }
%
%<*macnew>
\bool_new:N \g_@@_mac_pingfang_bool
% \end{macrocode}
% 为方便人类阅读,把 \LuaTeX{} 分支挪到 \cs{ctex_fontset_case:nnnn} 之后,在不忽略
% 空格的 catcode scheme 下编写。这样 Lua 代码就不必以 |~| 代替空格。
% |macnew| 的其他 \cs{ctex_fontset_case:nnnn} 和其他 \cs{ctex_zhmap_case:nnn}
% 分支,末尾均使用 \cs{use_none_delimit_by_q_stop:w} 来跳过 \LuaTeX{} 分支。
% \begin{macrocode}
\sys_if_engine_luatex:F
{
\fontspec_font_if_exist:nTF { Kaiti~SC }
{
\setCJKmainfont { Songti~SC~Light }
[
BoldFont = Songti~SC~Bold ,
ItalicFont = Kaiti~SC ,
BoldItalicFont = Kaiti~SC~Bold ,
]
}
{
\setCJKmainfont { Songti~SC~Light }
[ BoldFont = Songti~SC~Bold ]
}
\setCJKfamilyfont { zhsong } { Songti~SC~Light }
[ BoldFont = Songti~SC~Bold ]
\setCJKfamilyfont { zhhei } { Heiti~SC~Light }
[ BoldFont = Heiti~SC~Medium ]
\fontspec_font_if_exist:nTF { PingFang~SC }
{
\setCJKsansfont { PingFang~SC }
\setCJKfamilyfont { zhpf } { PingFang~SC }
\bool_gset_true:N \g_@@_mac_pingfang_bool
}
{ \setCJKsansfont { Heiti~SC~Light } [ BoldFont = Heiti~SC~Medium ] }
\fontspec_font_if_exist:nTF { STFangsong }
{
\setCJKmonofont { STFangsong }
\setCJKfamilyfont { zhfs } { STFangsong }
}
{ \setCJKmonofont { Heiti~SC~Light } }
\fontspec_font_if_exist:nT { Kaiti~SC }
{
\setCJKfamilyfont { zhkai } { Kaiti~SC }
[ BoldFont = Kaiti~SC~Bold ]
}
\fontspec_font_if_exist:nT { Baoli~SC }
{ \setCJKfamilyfont { zhli } { Baoli~SC } }
\fontspec_font_if_exist:nT { Yuanti~SC~Light }
{
\setCJKfamilyfont { zhyou } { Yuanti~SC~Light }
[ BoldFont = Yuanti~SC~Regular ]
}
\use_none_delimit_by_q_stop:w
}
%
}
%<*macnew>
\char_set_catcode_space:n { 32 }
\lua_now:n
{
local lfs = require("lfs");
local search_bases = {};
local asset_roots = {
"/System/Library/AssetsV2",
"/System/Library/AssetsV2/PreinstalledAssetsV2/InstallWithOs",
};
for _, root in ipairs(asset_roots) do
local ok, iter, obj = pcall(lfs.dir, root);
if ok then
for d in iter, obj do
if d:find("^com_apple_MobileAsset_Font") then
table.insert(search_bases, root .. "/" .. d);
end;
end;
end;
end;
local function find_font_dir(filename)
for _, base in ipairs(search_bases) do
local ok, iter, obj = pcall(lfs.dir, base);
if ok then
for entry in iter, obj do
if not (entry == "." or entry == "..") then
local p = base .. "/" .. entry
.. "/AssetData/" .. filename;
if lfs.attributes(p, "mode") then
return base .. "/" .. entry .. "/AssetData/";
end;
end;
end;
end;
end;
return nil;
end;
local fonts = {
{"PingFang.ttc", "g_@@_mac_pingfang_dir_tl"},
{"Kaiti.ttc", "g_@@_mac_kaiti_dir_tl"},
{"STFANGSO.ttf", "g_@@_mac_stfangso_dir_tl"},
{"Baoli.ttc", "g_@@_mac_baoli_dir_tl"},
{"Yuanti.ttc", "g_@@_mac_yuanti_dir_tl"},
};
for _, f in ipairs(fonts) do
local dir = find_font_dir(f[1]);
token.set_macro(f[2], dir or "", "global");
end
}
\char_set_catcode_ignore:n { 32 }
\tl_if_empty:NTF \g_@@_mac_kaiti_dir_tl
{
\setCJKmainfont { Songti~SC~Light }
[ BoldFont = Songti~SC~Bold ]
}
{
\setCJKmainfont { Songti~SC~Light }
[
BoldFont = Songti~SC~Bold ,
ItalicFont = Kaiti.ttc ,
ItalicFeatures = { Path = \g_@@_mac_kaiti_dir_tl , FontIndex = 0 } ,
BoldItalicFont = Kaiti.ttc ,
BoldItalicFeatures = { Path = \g_@@_mac_kaiti_dir_tl , FontIndex = 3 } ,
]
}
\setCJKfamilyfont { zhsong } { Songti~SC~Light }
[ BoldFont = Songti~SC~Bold ]
\setCJKfamilyfont { zhhei } { Heiti~SC~Light }
[ BoldFont = Heiti~SC~Medium ]
\tl_if_empty:NTF \g_@@_mac_pingfang_dir_tl
{ \setCJKsansfont { Heiti~SC~Light } [ BoldFont = Heiti~SC~Medium ] }
{
\setCJKsansfont { PingFang.ttc }
[
Path = \g_@@_mac_pingfang_dir_tl ,
FontIndex = 2 ,
BoldFont = PingFang.ttc ,
BoldFontIndex = 8 ,
]
\setCJKfamilyfont { zhpf } { PingFang.ttc }
[ Path = \g_@@_mac_pingfang_dir_tl , FontIndex = 2 ]
\bool_gset_true:N \g_@@_mac_pingfang_bool
}
\tl_if_empty:NTF \g_@@_mac_stfangso_dir_tl
{ \setCJKmonofont { Heiti~SC~Light } }
{
\setCJKmonofont { STFANGSO.ttf }
[ Path = \g_@@_mac_stfangso_dir_tl ]
\setCJKfamilyfont { zhfs } { STFANGSO.ttf }
[ Path = \g_@@_mac_stfangso_dir_tl ]
}
\tl_if_empty:NF \g_@@_mac_kaiti_dir_tl
{
\setCJKfamilyfont { zhkai } { Kaiti.ttc }
[
Path = \g_@@_mac_kaiti_dir_tl ,
FontIndex = 0 ,
BoldFont = Kaiti.ttc ,
BoldFontIndex = 3 ,
]
}
\tl_if_empty:NF \g_@@_mac_baoli_dir_tl
{
\setCJKfamilyfont { zhli } { Baoli.ttc }
[ Path = \g_@@_mac_baoli_dir_tl , FontIndex = 0 ]
}
\tl_if_empty:NF \g_@@_mac_yuanti_dir_tl
{
\setCJKfamilyfont { zhyou } { Yuanti.ttc }
[
Path = \g_@@_mac_yuanti_dir_tl ,
FontIndex = 4 ,
BoldFont = Yuanti.ttc ,
BoldFontIndex = 0 ,
]
}
\use_none_delimit_by_q_stop:w \q_stop
%
%
% \end{macrocode}
%
% \paragraph{\opt{ubuntu}}
%
% \changes{v2.5}{2019/11/07}{\opt{ubuntu} 改用思源(Noto CJK)和文鼎字库,不再
% 支持使用 \pdfLaTeX{} 编译。}
% \changes{v2.6.2}{2026/07/05}{\opt{ubuntu} 字库新增仿宋配置和 \tn{fangsong}
% 命令。使用 \XeLaTeX{} 或 \LuaLaTeX{} 编译时,按朱雀仿宋、FandolFang、
% 思源宋体的顺序自动选用(\#908)。}
%
% 仿宋在 \XeTeX{} 和 \LuaTeX{} 下按朱雀仿宋(\pkg{lxgw-fonts} 宏包)、
% FandolFang、思源宋体的顺序检测选用,等宽字体(\tn{ttfamily})与之保持一致。
% 其他编译方式无法在运行时检测字体,仿宋直接使用静态映射的思源宋体。
%
% \begin{macrocode}
%<*ubuntu>
\ctex_fontset_case:nnnn
{ \ctex_fontset_error:n { ubuntu } }
{
\ctex_zhmap_case:nnn
{
\setCJKmainfont { :2:NotoSerifCJK-Regular.ttc }
[ BoldFont = :2:NotoSerifCJK-Bold.ttc, ItalicFont = gkai00mp.ttf ]
\setCJKsansfont { :2:NotoSansCJK-Regular.ttc }
[ BoldFont = :2:NotoSansCJK-Bold.ttc ]
\setCJKmonofont { :2:NotoSerifCJK-Regular.ttc }
[ BoldFont = :2:NotoSerifCJK-Bold.ttc ]
\setCJKfamilyfont { zhsong } { :2:NotoSerifCJK-Regular.ttc }
[ BoldFont = :2:NotoSerifCJK-Bold.ttc ]
\setCJKfamilyfont { zhhei } { :2:NotoSansCJK-Regular.ttc }
[ BoldFont = :2:NotoSansCJK-Bold.ttc ]
\setCJKfamilyfont { zhfs } { :2:NotoSerifCJK-Regular.ttc }
\setCJKfamilyfont { zhkai } { gkai00mp.ttf }
\ctex_punct_set:n { ubuntu }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
\ctex_punct_map_family:nn { \CJKttdefault } { zhsong }
\ctex_punct_map_family:nn { zhfs } { zhsong }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhheib }
\ctex_punct_map_bfseries:nn
{ \CJKrmdefault, \CJKttdefault, zhsong }
{ zhsongb }
}
{
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { ubuntu }
\ctex_punct_set:n { ubuntu }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_family:nn { \CJKttdefault } { zhsong }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{ \ctex_fontset_error:n { ubuntu } }
}
{
\ctex_set_upmap_unicode:nnn { upserif }
{ :2:NotoSerifCJK-Regular.ttc } { :2:NotoSerifCJK-Bold.ttc }
\ctex_set_upmap_unicode:nnn { upsans }
{ :2:NotoSansCJK-Regular.ttc } { :2:NotoSansCJK-Bold.ttc }
\ctex_set_upmap_unicode:nnn { upmono }
{ :2:NotoSerifCJK-Regular.ttc } { }
\ctex_set_upmap:nnn { upserifit } { gkai00mp.ttf } { }
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb }
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb }
\ctex_set_upfamily:nnn { zhfs } { upzhmono } { }
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } { }
}
{
\setCJKmainfont { Noto~Serif~CJK~SC }
[ BoldFont = Noto~Serif~CJK~SC~Bold, ItalicFont = AR~PL~KaitiM~GB ]
\setCJKsansfont { Noto~Sans~CJK~SC }
[ BoldFont = Noto~Sans~CJK~SC~Bold ]
\fontspec_font_if_exist:nTF { LXGWZhuqueFangsong-Regular.ttf }
{
\setCJKmonofont { LXGWZhuqueFangsong-Regular.ttf }
\setCJKfamilyfont { zhfs } { LXGWZhuqueFangsong-Regular.ttf }
}
{
\fontspec_font_if_exist:nTF { FandolFang-Regular.otf }
{
\setCJKmonofont { FandolFang-Regular.otf }
\setCJKfamilyfont { zhfs } { FandolFang-Regular.otf }
}
{
\setCJKmonofont { Noto~Serif~CJK~SC }
\setCJKfamilyfont { zhfs } { Noto~Serif~CJK~SC }
}
}
\setCJKfamilyfont { zhsong } { Noto~Serif~CJK~SC }
[ BoldFont = Noto~Serif~CJK~SC~Bold ]
\setCJKfamilyfont { zhhei } { Noto~Sans~CJK~SC }
[ BoldFont = Noto~Sans~CJK~SC~Bold ]
\setCJKfamilyfont { zhkai } { AR~PL~KaitiM~GB }
}
%
% \end{macrocode}
%
% \paragraph{\opt{windows}}
%
% \changes{v2.4.1}{2016/05/14}{使用 \file{bootfont.bin} 判断 Windows XP 以避免
% 权限问题。}
% \changes{v2.5}{2019/11/04}{使用环境变量代替绝对路径查找字体。}
% \changes{v2.5}{2019/11/05}{不再支持 Windows XP 系统,\opt{windowsold} 和
% \opt{windowsnew} 成为过时字库选项。}
% \changes{v2.6.1}{2026/07/01}{补全字库选项 \opt{windows} 的 \pdfTeX{} 分支中,
% \cs{ctex_zhmap_case:nnn} 的第三个子分支 \opt{zhmap != false} 缺失的报错。}
%
% \begin{variable}{ \c_@@_msyh_suffix_tl}
% Windows 8 以后,微软雅黑由原来的 \file{.ttf} 后缀改为 \file{.ttc} 后缀,需要
% 加以区分。
% \begin{macrocode}
%<*windows>
\file_if_exist:nTF { \c_dollar_str WINDIR/Fonts/msyh.ttc }
{ \tl_const:Nn \c_@@_msyh_suffix_tl { ttc } }
{
\file_if_exist:nTF { msyh.ttc }
{ \tl_const:Nn \c_@@_msyh_suffix_tl { ttc } }
{ \tl_const:Nn \c_@@_msyh_suffix_tl { ttf } }
}
% \end{macrocode}
% \end{variable}
%
% \begin{macrocode}
\ctex_fontset_case:nnn
{
\ctex_zhmap_case:nnn
{
\ctex_punct_set:n { windows }
\setCJKmainfont { simsun.ttc }
[ BoldFont = simhei.ttf, ItalicFont = simkai.ttf ]
\setCJKsansfont { msyh.\c_@@_msyh_suffix_tl }
[ BoldFont = msyhbd.\c_@@_msyh_suffix_tl ]
\setCJKmonofont { simfang.ttf }
\setCJKfamilyfont { zhsong } { simsun.ttc }
\setCJKfamilyfont { zhhei } { simhei.ttf }
\setCJKfamilyfont { zhfs } { simfang.ttf }
\setCJKfamilyfont { zhkai } { simkai.ttf }
\setCJKfamilyfont { zhyahei } { msyh.\c_@@_msyh_suffix_tl }
[ BoldFont = msyhbd.\c_@@_msyh_suffix_tl ]
\setCJKfamilyfont { zhli } { simli.ttf }
\setCJKfamilyfont { zhyou } { simyou.ttf }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
\ctex_punct_map_family:nn { \CJKsfdefault } { zhyahei }
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhyahei } { zhyaheib }
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
}
{
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { windows }
\ctex_punct_set:n { windows }
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
}
{ \ctex_fontset_error:n { windows } }
}
{
\ctex_set_upfonts:nnnnnn
{ simsun.ttc }
{ simhei.ttf }
{ simkai.ttf }
{ msyh.\c_@@_msyh_suffix_tl }
{ msyhbd.\c_@@_msyh_suffix_tl }
{ simfang.ttf }
\ctex_set_upfamily:nnn { zhsong } { upzhserif } {}
\ctex_set_upfamily:nnn { zhhei } { upzhserifb } {}
\ctex_set_upfamily:nnn { zhfs } { upzhmono } {}
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
\ctex_set_upfamily:nnn { zhyahei } { upzhsans } { upzhsansb }
\ctex_set_upfamily:nnn { zhli } { upschrm } {}
\ctex_set_upfamily:nnn { zhyou } { upschgt } {}
\ctex_set_upmap:nnn { upstsl } { simli.ttf } {}
\ctex_set_upmap:nnn { upstht } { simyou.ttf } {}
}
{
\setCJKmainfont { SimSun } [ BoldFont = SimHei , ItalicFont = KaiTi ]
\setCJKsansfont { Microsoft~YaHei } [ BoldFont = *~Bold ]
\setCJKmonofont { FangSong }
\setCJKfamilyfont { zhsong } { SimSun }
\setCJKfamilyfont { zhhei } { SimHei }
\setCJKfamilyfont { zhfs } { FangSong }
\setCJKfamilyfont { zhkai } { KaiTi }
\setCJKfamilyfont { zhyahei } { Microsoft~YaHei } [ BoldFont = *~Bold ]
\setCJKfamilyfont { zhli } { LiSu }
\setCJKfamilyfont { zhyou } { YouYuan }
}
%
% \end{macrocode}
%
% \subsubsection{中文字体命令}
% \changes{v2.4.14}{2018/05/01}{为 \opt{macnew} 配置字体命令。}
%
% \begin{macro}{\songti,\heiti,\fangsong,\kaishu,\lishu,\youyuan,\yahei,\pingfang}
% 使用 \upLaTeX{} 编译时,\opt{macnew} 字库中由于传统黑体(黑体-简)无法使用,
% 我们用苹方来代替。同时 \tn{yahei}、\tn{pingfang} 命令被设置为与 \tn{heiti} 相同。
% \begin{macrocode}
%<*!mac>
\NewDocumentCommand \songti { } { \CJKfamily { zhsong } }
\NewDocumentCommand \heiti { } { \CJKfamily { zhhei } }
\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs } }
\NewDocumentCommand \kaishu { } { \CJKfamily { zhkai } }
%<*windows|founder|macnew>
\NewDocumentCommand \lishu { } { \CJKfamily { zhli } }
\NewDocumentCommand \youyuan { } { \CJKfamily { zhyou } }
%
%\NewDocumentCommand \yahei { } { \CJKfamily { zhyahei } }
%<*macnew>
\bool_lazy_or:nnTF
{ \sys_if_engine_pdftex_p: }
{ \sys_if_engine_uptex_p: }
{
\cs_new_eq:NN \yahei \heiti
\cs_new_eq:NN \pingfang \heiti
}
{
\bool_if:NTF \g_@@_mac_pingfang_bool
{
\NewDocumentCommand \yahei { } { \CJKfamily { zhpf } }
\NewDocumentCommand \pingfang { } { \CJKfamily { zhpf } }
}
{
\cs_new_eq:NN \yahei \heiti
\cs_new_eq:NN \pingfang \heiti
}
}
%
%!mac>
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
%
% \end{macrocode}
%
% \subsubsection{\pkg{zhmetrics} 的字体映射}
%
% \changes{v2.5.2}{2020/05/05}{\file{zhadobefonts.tex} 等字体映射文件更名为
% \file{ctex-zhmap-*.tex}。}
%
% 确认 \tn{catcode},没有重复载入检查。
% \begin{macrocode}
%<*zhmap>
\begingroup\catcode61\catcode48\catcode32=10\relax%
\catcode 35=6 % #
\catcode 45=12 % -
\catcode123=1 % {
\catcode125=2 % }
\toks0{\endlinechar=\the\endlinechar\relax}%
\toks2{\endlinechar=-1 }%
\def\x#1 #2 {%
\toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}%
\toks2\expandafter{\the\toks2 \catcode#1=#2 }}%
\x 13 5 % carriage return
\x 32 10 % space
\x 35 6 % #
\x 40 12 % (
\x 41 12 % )
\x 45 12 % -
\x 46 12 % .
\x 47 12 % /
\x 58 12 % :
\x 60 12 % <
\x 61 12 % =
\x 64 11 % @
\x 91 12 % [
\x 93 12 % ]
\x 123 1 % {
\x 125 2 % }
\edef\x#1{\endgroup%
\edef\noexpand#1{%
\the\toks0 %
\let\noexpand\noexpand\noexpand#1%
\noexpand\noexpand\noexpand\undefined%
\noexpand\noexpand\noexpand\endinput}%
\the\toks2}%
\expandafter\x\csname ctex@zhmap@endinput\endcsname
% \end{macrocode}
%
% \begin{macro}[int]{\ifzhmappdf}
% \begin{macrocode}
\begingroup\expandafter\endgroup
\expandafter\let\csname ifzhmappdf\expandafter\endcsname\csname
\expandafter\ifx\csname ifctexpdf\endcsname\relax
\expandafter\ifx\csname pdfoutput\endcsname\relax
iffalse\else\ifnum\pdfoutput < 1 iffalse\else iftrue\fi\fi
\else ifctexpdf\fi
\endcsname
% \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\ProvidesFile}
% 提供非 \LaTeX{} 格式下的 \tn{ProvidesFile}。
% \begin{macrocode}
\begingroup
\expandafter\ifx\csname ProvidesFile\endcsname\relax
\long\def\x#1\ProvidesFile#2[#3]{%
#1%
\immediate\write-1{File: #2 #3}%
\expandafter\xdef\csname ver@#2\endcsname{#3}}
\expandafter\x%
\fi
\endgroup
% \end{macrocode}
% \end{macro}
%
% 文件标识信息。
% \begin{macrocode}
%<*zhmap>
%\ProvidesFile{ctex-zhmap-adobe.tex}%
%\ProvidesFile{ctex-zhmap-fandol.tex}%
%\ProvidesFile{ctex-zhmap-founder.tex}%
%\ProvidesFile{ctex-zhmap-hanyi.tex}%
%\ProvidesFile{ctex-zhmap-mac.tex}%
%\ProvidesFile{ctex-zhmap-ubuntu.tex}%
%\ProvidesFile{ctex-zhmap-windows.tex}%
% [\ExplFileDate\space v\ExplFileVersion\space \ExplFileDescription]
%
% \end{macrocode}
%
% \paragraph{\pkg{ctex-zhmap-adobe.tex}}
%
% \begin{macrocode}
%<*adobe>
\ifzhmappdf
%% pdfTeX does not support OTF fonts
\else
\special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf}
\special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf}
\special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
\special{pdf:mapline gbkhei@UGBK@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
\special{pdf:mapline gbkfs@UGBK@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
\special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf}
\special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf}
\special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
\special{pdf:mapline unihei@Unicode@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
\special{pdf:mapline unifs@Unicode@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
\special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167}
\special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167}
\special{pdf:mapline gbkheisl@UGBK@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167}
\special{pdf:mapline gbkfssl@UGBK@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167}
\special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167}
\special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167}
\special{pdf:mapline uniheisl@Unicode@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167}
\special{pdf:mapline unifssl@Unicode@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167}
\fi
%
% \end{macrocode}
%
% \paragraph{\pkg{ctex-zhmap-fandol.tex}}
%
% \begin{macrocode}
%<*fandol>
\ifzhmappdf
%% pdfTeX does not support OTF fonts
\else
\special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf}
\special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf}
\special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H FandolKai-Regular.otf}
\special{pdf:mapline gbkhei@UGBK@ UniGB-UTF16-H FandolHei-Regular.otf}
\special{pdf:mapline gbkfs@UGBK@ UniGB-UTF16-H FandolFang-Regular.otf}
\special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf}
\special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf}
\special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H FandolKai-Regular.otf}
\special{pdf:mapline unihei@Unicode@ UniGB-UTF16-H FandolHei-Regular.otf}
\special{pdf:mapline unifs@Unicode@ UniGB-UTF16-H FandolFang-Regular.otf}
\special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf -s .167}
\special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H FandolKai-Regular.otf -s .167}
\special{pdf:mapline gbkheisl@UGBK@ UniGB-UTF16-H FandolHei-Regular.otf -s .167}
\special{pdf:mapline gbkfssl@UGBK@ UniGB-UTF16-H FandolFang-Regular.otf -s .167}
\special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf -s .167}
\special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H FandolKai-Regular.otf -s .167}
\special{pdf:mapline uniheisl@Unicode@ UniGB-UTF16-H FandolHei-Regular.otf -s .167}
\special{pdf:mapline unifssl@Unicode@ UniGB-UTF16-H FandolFang-Regular.otf -s .167}
\fi
%
% \end{macrocode}
%
% \paragraph{\pkg{ctex-zhmap-founder.tex}}
%
% \begin{macrocode}
%<*founder>
\ifzhmappdf
\pdfmapline{=gbk@UGBK@
% \end{macrocode}
%
% \paragraph{\pkg{ctex-zhmap-hanyi.tex}}
%
% \begin{macrocode}
%<*hanyi>
\ifzhmappdf
\pdfmapline{=gbk@UGBK@
% \end{macrocode}
%
% \paragraph{\pkg{ctex-zhmap-mac.tex}}
%
% \changes{v2.5}{2020/01/15}{增加字体映射文件 \file{zhmacfonts.tex}。}
%
% \begin{macrocode}
%<*mac>
\ifzhmappdf
%% pdfTeX does not support OTF fonts
\else
\special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H :3:Songti.ttc}
\special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H :3:Songti.ttc}
\special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H :0:Kaiti.ttc}
\special{pdf:mapline gbkhei@UGBK@ unicode :2:PingFang.ttc}
\special{pdf:mapline gbkfs@UGBK@ unicode STFANGSO.ttf}
\special{pdf:mapline gbkli@UGBK@ UniGB-UTF16-H :0:Baoli.ttc}
\special{pdf:mapline gbkyou@UGBK@ UniGB-UTF16-H :4:Yuanti.ttc}
\special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H :3:Songti.ttc}
\special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H :3:Songti.ttc}
\special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H :0:Kaiti.ttc}
\special{pdf:mapline unihei@Unicode@ unicode :2:PingFang.ttc}
\special{pdf:mapline unifs@Unicode@ unicode STFANGSO.ttf}
\special{pdf:mapline unili@Unicode@ UniGB-UTF16-H :0:Baoli.ttc}
\special{pdf:mapline uniyou@Unicode@ UniGB-UTF16-H :4:Yuanti.ttc}
\special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H :3:Songti.ttc -s .167}
\special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H :0:Kaiti.ttc -s .167}
\special{pdf:mapline gbkheisl@UGBK@ unicode :2:PingFang.ttc -s .167}
\special{pdf:mapline gbkfssl@UGBK@ unicode STFANGSO.ttf -s .167}
\special{pdf:mapline gbklisl@UGBK@ UniGB-UTF16-H :0:Baoli.ttc -s .167}
\special{pdf:mapline gbkyousl@UGBK@ UniGB-UTF16-H :4:Yuanti.ttc -s .167}
\special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H :3:Songti.ttc -s .167}
\special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H :0:Kaiti.ttc -s .167}
\special{pdf:mapline uniheisl@Unicode@ unicode :2:PingFang.ttc -s .167}
\special{pdf:mapline unifssl@Unicode@ unicode STFANGSO.ttf -s .167}
\special{pdf:mapline unilisl@Unicode@ UniGB-UTF16-H :0:Baoli.ttc -s .167}
\special{pdf:mapline uniyousl@Unicode@ UniGB-UTF16-H :4:Yuanti.ttc -s .167}
\fi
%
% \end{macrocode}
%
% \paragraph{\pkg{ctex-zhmap-ubuntu.tex}}
%
% \begin{macrocode}
%<*ubuntu>
\ifzhmappdf
%% pdfTeX does not support OTF fonts
\else
\special{pdf:mapline gbk@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc}
\special{pdf:mapline gbksong@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc}
\special{pdf:mapline gbkkai@UGBK@ unicode gkai00mp.ttf}
\special{pdf:mapline gbkhei@UGBK@ unicode :2:NotoSansCJK-Regular.ttc}
\special{pdf:mapline gbkfs@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc}
\special{pdf:mapline cyberb@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc}
\special{pdf:mapline unisong@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc}
\special{pdf:mapline unikai@Unicode@ unicode gkai00mp.ttf}
\special{pdf:mapline unihei@Unicode@ unicode :2:NotoSansCJK-Regular.ttc}
\special{pdf:mapline unifs@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc}
\special{pdf:mapline gbksongsl@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc -s .167}
\special{pdf:mapline gbkkaisl@UGBK@ unicode gkai00mp.ttf -s .167}
\special{pdf:mapline gbkheisl@UGBK@ unicode :2:NotoSansCJK-Regular.ttc -s .167}
\special{pdf:mapline gbkfssl@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc -s .167}
\special{pdf:mapline unisongsl@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc -s .167}
\special{pdf:mapline unikaisl@Unicode@ unicode gkai00mp.ttf -s .167}
\special{pdf:mapline uniheisl@Unicode@ unicode :2:NotoSansCJK-Regular.ttc -s .167}
\special{pdf:mapline unifssl@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc -s .167}
\fi
%
% \end{macrocode}
%
% \paragraph{\pkg{ctex-zhmap-windows.tex}}
%
% \begin{macrocode}
%<*windows>
\ifzhmappdf
\pdfmapline{=gbk@UGBK@
% \end{macrocode}
%
% \begin{macrocode}
\ctex@zhmap@endinput
%
% \end{macrocode}
%
% \subsubsection{制作 \texttt{spa} 文件}
%
% \changes{v2.5.2}
% {2020/05/05}{\file{ctexmakespa.tex} 更名为 \file{ctex-spa-make.tex}。}
% \changes{v2.5.2}
% {2020/05/05}{\file{ctexspamacro.tex} 更名为 \file{ctex-spa-macro.tex}。}
% \changes{v2.6.0}{2026/04/30}
% {修复了 \TeX\ tree 字体无法制作 \file{.spa} 文件的问题。}
%
% 我们通过 \XeTeX{} 的 \tn{XeTeXglyphbounds} 取得字体中标点符号的边界信息,为
% \pkg{CJKpunct} 宏包制作 \file{spa}。
%
% \begin{macrocode}
%<*spa>
%<*macro>
\input expl3-generic %
\ExplSyntaxOn
\sys_if_engine_xetex:F
{
\msg_new:nnn { ctex } { xetex }
{ XeTeX~is~required~to~compile~this~document! }
\msg_fatal:nn { ctex } { xetex }
}
% \end{macrocode}
%
% \pkg{CJKpunct} 定义的标点符号是:
% \begin{verbatim}
% ‘“「『〔([{〈《〖【
% —…、。,.:;!?%〕)]}〉》〗】’”」』
% \end{verbatim}
% 注意顺序不能改变。
% \begin{macrocode}
\seq_const_from_clist:Nn \c_@@_punct_seq
{
"2018 , "201C , "300C , "300E , "3014 , "FF08 , "FF3B , "FF5B ,
"3008 , "300A , "3016 , "3010 ,
"2014 , "2026 , "3001 , "3002 , "FF0C , "FF0E , "FF1A , "FF1B ,
"FF01 , "FF1F , "FF05 , "3015 , "FF09 , "FF3D , "FF5D , "3009 ,
"300B , "3017 , "3011 , "2019 , "201D , "300D , "300F
}
% \end{macrocode}
%
% \begin{macro}[int]{\ctex_make_spa:nn}
% |#1| 是 \file{spa} 文件名,|#2| 是由 CJK 族名与字体构成的逗号列表。
% \begin{macrocode}
\cs_new_protected:Npn \ctex_make_spa:nn #1#2
{
\iow_open:Nn \g_@@_spa_iow {#1}
\clist_map_inline:nn {#2}
{ \@@_write_family:nn ##1 }
\iow_close:N \g_@@_spa_iow
}
\iow_new:N \g_@@_spa_iow
\cs_new_eq:NN \MAKESPA \ctex_make_spa:nn
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_write_family:nn #1#2
{
\group_begin:
\@@_if_font_exists:nTF {#2}
{ \tex_font:D \l_@@_punct_font = "[#2]" ~ at ~ 100 pt \scan_stop: }
{ \tex_font:D \l_@@_punct_font = "#2" ~ at ~ 100 pt \scan_stop: }
\l_@@_punct_font
\clist_clear:N \l_@@_punct_bounds_clist
\seq_map_inline:Nn \c_@@_punct_seq
{
\exp_args:No \@@_save_bounds:n
{ \int_use:N \tex_XeTeXcharglyph:D ##1 }
}
\iow_now:Ne \g_@@_spa_iow
{
\token_to_str:N \ctexspadef {#1}
% \end{macrocode}
% 最后这三个逗号对 \pkg{CJKpunct} 来说是必要的。
% \begin{macrocode}
{ \l_@@_punct_bounds_clist , , , }
}
\group_end:
}
% \end{macrocode}
%
% \begin{macro}{\@@_if_font_exists:nTF}
% 优先搜索字体是否为 \TeX\ Tree 字体或是否存在于当前路径下\footnote{^^A
% 事实上 \path{TEXINPUTS} 也会被一并优先搜索。},
% 如果不存在,\cs{@@_write_family:nn} 会根据结果在 |shell| 中调用 |kpathsea| 查文件
% 或 |fontconfig| 查名称\footnote{^^A
% 如果用户把字体目录加入到了 \path{TEXINPUTS} 中,
% \cs{file_if_exist_p:n} 可能找到一个 \XeTeX\ |"[basename]"| 加载不了的文件,
% 因为 \XeTeX\ 搜索字体专属路径 \path{OPENTYPEFONTS}/\path{TTFONTS},
% 不搜索 \path{TEXINPUTS})。
% }。
% \begin{macrocode}
\prg_new_protected_conditional:Nnn \@@_if_font_exists:n { TF }
{
\tl_clear:N \l_@@_if_otf_exists_tl
\tl_clear:N \l_@@_if_ttf_exists_tl
\bool_case:nF
{
{ \file_if_exist_p:n { #1.otf } }
{ \tl_set:Nn \l_@@_if_otf_exists_tl {#1} }
{ \file_if_exist_p:n { #1.ttf } }
{ \tl_set:Nn \l_@@_if_ttf_exists_tl {#1} }
}
{
\sys_get_shell:nnN { kpsewhich ~ #1.otf } { \endlinechar=-1 }
\l_@@_if_otf_exists_tl
\sys_get_shell:nnN { kpsewhich ~ #1.ttf } { \endlinechar=-1 }
\l_@@_if_ttf_exists_tl
}
\bool_lazy_and:nnTF
{ \tl_if_blank_p:V \l_@@_if_otf_exists_tl }
{ \tl_if_blank_p:V \l_@@_if_ttf_exists_tl }
{ \prg_return_false: } { \prg_return_true: }
}
% \end{macrocode}
% \end{macro}
%
% \begin{variable}
% {\l_@@_if_otf_exists_tl, \l_@@_if_ttf_exists_tl}
% 用于存储 |shell| 输出的 |kpsewhich| 结果。
% \begin{macrocode}
\tl_clear_new:N \l_@@_if_otf_exists_tl
\tl_clear_new:N \l_@@_if_ttf_exists_tl
% \end{macrocode}
% \end{variable}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_save_bounds:n #1
{
\clist_put_right:Ne \l_@@_punct_bounds_clist
{
\@@_calc_bounds:nn { 1 } {#1} ,
\@@_calc_bounds:nn { 3 } {#1}
}
}
\clist_new:N \l_@@_punct_bounds_clist
% \end{macrocode}
%
% \pkg{CJKpunct} 要求的格式是边界空白宽度与 1\,em 的比值的一百倍。
% \begin{macrocode}
\cs_new:Npn \@@_calc_bounds:nn #1#2
{
\fp_eval:n
{
round
(
\dim_to_decimal_in_unit:nn
{ 100 \tex_XeTeXglyphbounds:D #1 ~ #2 }
{ 1 em }
)
}
}
\ExplSyntaxOff
%
% \end{macrocode}
%
% 下面是 \CTeX{} 定义的一些字体。
% \begin{macrocode}
%<*make>
\input ctex-spa-macro %
\MAKESPA {ctexpunct.spa}
{
{adobezhsong} {AdobeSongStd-Light} ,
{adobezhhei} {AdobeHeitiStd-Regular} ,
{adobezhkai} {AdobeKaitiStd-Regular} ,
{adobezhfs} {AdobeFangsongStd-Regular} ,
%
{fandolzhsong} {FandolSong-Regular} ,
{fandolzhsongb} {FandolSong-Bold} ,
{fandolzhhei} {FandolHei-Regular} ,
{fandolzhheib} {FandolHei-Bold} ,
{fandolzhkai} {FandolKai-Regular} ,
{fandolzhfs} {FandolFang-Regular} ,
%
{founderzhsong} {FZShuSong-Z01} ,
{founderzhsongb} {FZXiaoBiaoSong-B05} ,
{founderzhhei} {FZHei-B01} ,
{founderzhheil} {FZXiHeiI-Z08} ,
{founderzhkai} {FZKai-Z03} ,
{founderzhfs} {FZFangSong-Z02} ,
{founderzhli} {FZLiShu-S01} ,
{founderzhyou} {FZXiYuan-M01} ,
{founderzhyoub} {FZZhunYuan-M02} ,
%
{hanyizhsong} {HYShuSongEr S} ,
{hanyizhsongb} {HYZhongSong S} ,
{hanyizhhei} {HYZhongHei S} ,
{hanyizhheib} {HYDaHei S} ,
{hanyizhkai} {HYKaiTi S} ,
{hanyizhfs} {HYFangSong S} ,
%
{maczhsong} {Songti SC Light} ,
{maczhsongb} {Songti SC Bold} ,
{maczhhei} {Heiti SC Medium} ,
{maczhheil} {Heiti SC Light} ,
{maczhkai} {Kaiti SC} ,
{maczhkaib} {Kaiti SC Bold} ,
{maczhfs} {STFangsong} ,
{maczhli} {Baoli SC} ,
{maczhyou} {Yuanti SC Light} ,
{maczhyoub} {Yuanti SC Regular} ,
{maczhpf} {PingFang SC} ,
{maczhpfb} {PingFang SC Semibold} ,
%
{ubuntuzhsong} {Noto Serif CJK SC} ,
{ubuntuzhsongb} {Noto Serif CJK SC Bold} ,
{ubuntuzhhei} {Noto Sans CJK SC} ,
{ubuntuzhheib} {Noto Sans CJK SC Bold} ,
{ubuntuzhkai} {AR PL KaitiM GB} ,
%
{windowszhsong} {SimSun} ,
{windowszhhei} {SimHei} ,
{windowszhkai} {KaiTi} ,
{windowszhfs} {FangSong} ,
{windowszhli} {LiSu} ,
{windowszhyou} {YouYuan} ,
{windowszhyahei} {Microsoft YaHei} ,
{windowszhyaheib} {Microsoft YaHei Bold}
}
\primitive\end
%
%
% \end{macrocode}
%
% \subsection{字体定义文件}
%
% \subsubsection{传统定义方式}
%
% \changes{v2.4.15}{2019/04/05}{将 \texttt{JY2} 和 \texttt{JT2} 编码的字体定义提取到单独的文件中。}
%
% \begin{macrocode}
%<*c19|c70>
%%
%% Chinese characters
%%
%%% character set: GBK (extension of GB 2312)
%%% character set: Unicode
%% font encoding: Unicode
%%
%
% \end{macrocode}
%
% \pkg{CJK} 宏包使用的字体族。
% \begin{macrocode}
%\DeclareFontFamily{C19}{rm}{\hyphenchar\font\m@ne}
%\DeclareFontFamily{C70}{rm}{\hyphenchar\font\m@ne}
%\DeclareFontFamily{C19}{sf}{\hyphenchar\font\m@ne}
%\DeclareFontFamily{C70}{sf}{\hyphenchar\font\m@ne}
%\DeclareFontFamily{C19}{tt}{\hyphenchar\font\m@ne}
%\DeclareFontFamily{C70}{tt}{\hyphenchar\font\m@ne}
% \end{macrocode}
%
% \changes{v2.4}{2016/04/25}{提供 \upLaTeX{} 的 NFSS 字体定义。}
% \upLaTeX{} 使用的字体族。\upLaTeX\ 在 NFSS 下使用字体编码 |JY2| 和 |JT2| 来分别
% 表示横排与直排的日文。
% \begin{macrocode}
%\DeclareKanjiFamily{JY2}{zhrm}{}
%\DeclareKanjiFamily{JT2}{zhrm}{}
%\DeclareKanjiFamily{JY2}{zhsf}{}
%\DeclareKanjiFamily{JT2}{zhsf}{}
%\DeclareKanjiFamily{JY2}{zhtt}{}
%\DeclareKanjiFamily{JT2}{zhtt}{}
% \end{macrocode}
%
% \changes{v2.6.0}{2026/05/16}{补全 \upLaTeX\ 字体编码 JY2 和 JT2 的
% Fallback 机制。}
% 在 \upLaTeX\ 字体族 |zhrm| 下采用如下 Fallback 机制:
% 形状 |sl| 优先保留加粗字重,形状 |it| 优先保留楷书字形。
% \begin{macrocode}
%<*rm>
%<*c19>
\DeclareFontShape{C19}{rm}{m}{n}{<-> CJK * gbksong}{\CJKnormal}
\DeclareFontShape{C19}{rm}{b}{n}{<-> CJK * gbkhei}{\CJKnormal}
\DeclareFontShape{C19}{rm}{bx}{n}{<-> CJK * gbkhei}{\CJKnormal}
\DeclareFontShape{C19}{rm}{m}{sl}{<-> CJK * gbksongsl}{\CJKnormal}
\DeclareFontShape{C19}{rm}{b}{sl}{<-> CJK * gbkheisl}{\CJKnormal}
\DeclareFontShape{C19}{rm}{bx}{sl}{<-> CJK * gbkheisl}{\CJKnormal}
\DeclareFontShape{C19}{rm}{m}{it}{<-> CJK * gbkkai}{\CJKnormal}
\DeclareFontShape{C19}{rm}{b}{it}{<-> CJKb * gbkkai}{\CJKbold}
\DeclareFontShape{C19}{rm}{bx}{it}{<-> CJKb * gbkkai}{\CJKbold}
%
%<*c70>
\DeclareFontShape{C70}{rm}{m}{n}{<-> CJK * unisong}{\CJKnormal}
\DeclareFontShape{C70}{rm}{b}{n}{<-> CJK * unihei}{\CJKnormal}
\DeclareFontShape{C70}{rm}{bx}{n}{<-> CJK * unihei}{\CJKnormal}
\DeclareFontShape{C70}{rm}{m}{sl}{<-> CJK * unisongsl}{\CJKnormal}
\DeclareFontShape{C70}{rm}{b}{sl}{<-> CJK * uniheisl}{\CJKnormal}
\DeclareFontShape{C70}{rm}{bx}{sl}{<-> CJK * uniheisl}{\CJKnormal}
\DeclareFontShape{C70}{rm}{m}{it}{<-> CJK * unikai}{\CJKnormal}
\DeclareFontShape{C70}{rm}{b}{it}{<-> CJKb * unikai}{\CJKbold}
\DeclareFontShape{C70}{rm}{bx}{it}{<-> CJKb * unikai}{\CJKbold}
%
%<*jy2>
\DeclareFontShape{JY2}{zhrm}{m}{n}{<-> upzhserif-h}{}
\DeclareFontShape{JY2}{zhrm}{b}{n}{<-> upzhserifb-h}{}
\DeclareFontShape{JY2}{zhrm}{bx}{n}{<-> upzhserifb-h}{}
\DeclareFontShape{JY2}{zhrm}{m}{sl}{<-> upzhserifit-h}{}
\DeclareFontShape{JY2}{zhrm}{b}{sl}{<-> upzhserifb-h}{}
\DeclareFontShape{JY2}{zhrm}{bx}{sl}{<-> upzhserifb-h}{}
\DeclareFontShape{JY2}{zhrm}{m}{it}{<-> upzhserifit-h}{}
\DeclareFontShape{JY2}{zhrm}{b}{it}{<-> upzhserifit-h}{}
\DeclareFontShape{JY2}{zhrm}{bx}{it}{<-> upzhserifit-h}{}
%
%<*jt2>
\DeclareFontShape{JT2}{zhrm}{m}{n}{<-> upzhserif-v}{}
\DeclareFontShape{JT2}{zhrm}{b}{n}{<-> upzhserifb-v}{}
\DeclareFontShape{JT2}{zhrm}{bx}{n}{<-> upzhserifb-v}{}
\DeclareFontShape{JT2}{zhrm}{m}{sl}{<-> upzhserifit-v}{}
\DeclareFontShape{JT2}{zhrm}{b}{sl}{<-> upzhserifb-v}{}
\DeclareFontShape{JT2}{zhrm}{bx}{sl}{<-> upzhserifb-v}{}
\DeclareFontShape{JT2}{zhrm}{m}{it}{<-> upzhserifit-v}{}
\DeclareFontShape{JT2}{zhrm}{b}{it}{<-> upzhserifit-v}{}
\DeclareFontShape{JT2}{zhrm}{bx}{it}{<-> upzhserifit-v}{}
%
%
% \end{macrocode}
%
% \begin{macrocode}
%<*sf>
%<*c19>
\DeclareFontShape{C19}{sf}{m}{n}{<-> CJK * gbkyou}{\CJKnormal}
\DeclareFontShape{C19}{sf}{b}{n}{<-> CJKb * gbkyou}{\CJKbold}
\DeclareFontShape{C19}{sf}{bx}{n}{<-> CJKb * gbkyou}{\CJKbold}
\DeclareFontShape{C19}{sf}{m}{sl}{<-> CJK * gbkyousl}{\CJKnormal}
\DeclareFontShape{C19}{sf}{b}{sl}{<-> CJKb * gbkyousl}{\CJKbold}
\DeclareFontShape{C19}{sf}{bx}{sl}{<-> CJKb * gbkyousl}{\CJKbold}
\DeclareFontShape{C19}{sf}{m}{it}{<-> CJK * gbkyou}{\CJKnormal}
\DeclareFontShape{C19}{sf}{b}{it}{<-> CJKb * gbkyou}{\CJKbold}
\DeclareFontShape{C19}{sf}{bx}{it}{<-> CJKb * gbkyou}{\CJKbold}
%
%<*c70>
\DeclareFontShape{C70}{sf}{m}{n}{<-> CJK * uniyou}{\CJKnormal}
\DeclareFontShape{C70}{sf}{b}{n}{<-> CJKb * uniyou}{\CJKbold}
\DeclareFontShape{C70}{sf}{bx}{n}{<-> CJKb * uniyou}{\CJKbold}
\DeclareFontShape{C70}{sf}{m}{sl}{<-> CJK * uniyousl}{\CJKnormal}
\DeclareFontShape{C70}{sf}{b}{sl}{<-> CJKb * uniyousl}{\CJKbold}
\DeclareFontShape{C70}{sf}{bx}{sl}{<-> CJKb * uniyousl}{\CJKbold}
\DeclareFontShape{C70}{sf}{m}{it}{<-> CJK * uniyou}{\CJKnormal}
\DeclareFontShape{C70}{sf}{b}{it}{<-> CJKb * uniyou}{\CJKbold}
\DeclareFontShape{C70}{sf}{bx}{it}{<-> CJKb * uniyou}{\CJKbold}
%
%<*jy2>
\DeclareFontShape{JY2}{zhsf}{m}{n}{<-> upzhsans-h}{}
\DeclareFontShape{JY2}{zhsf}{b}{n}{<-> upzhsansb-h}{}
\DeclareFontShape{JY2}{zhsf}{bx}{n}{<-> upzhsansb-h}{}
\DeclareFontShape{JY2}{zhsf}{m}{sl}{<-> upzhsans-h}{}
\DeclareFontShape{JY2}{zhsf}{b}{sl}{<-> upzhsansb-h}{}
\DeclareFontShape{JY2}{zhsf}{bx}{sl}{<-> upzhsansb-h}{}
\DeclareFontShape{JY2}{zhsf}{m}{it}{<-> upzhsans-h}{}
\DeclareFontShape{JY2}{zhsf}{b}{it}{<-> upzhsansb-h}{}
\DeclareFontShape{JY2}{zhsf}{bx}{it}{<-> upzhsansb-h}{}
%
%<*jt2>
\DeclareFontShape{JT2}{zhsf}{m}{n}{<-> upzhsans-v}{}
\DeclareFontShape{JT2}{zhsf}{b}{n}{<-> upzhsansb-v}{}
\DeclareFontShape{JT2}{zhsf}{bx}{n}{<-> upzhsansb-v}{}
\DeclareFontShape{JT2}{zhsf}{m}{sl}{<-> upzhsans-v}{}
\DeclareFontShape{JT2}{zhsf}{b}{sl}{<-> upzhsansb-v}{}
\DeclareFontShape{JT2}{zhsf}{bx}{sl}{<-> upzhsansb-v}{}
\DeclareFontShape{JT2}{zhsf}{m}{it}{<-> upzhsans-v}{}
\DeclareFontShape{JT2}{zhsf}{b}{it}{<-> upzhsansb-v}{}
\DeclareFontShape{JT2}{zhsf}{bx}{it}{<-> upzhsansb-v}{}
%
%
% \end{macrocode}
%
% \begin{macrocode}
%<*tt>
%<*c19>
\DeclareFontShape{C19}{tt}{m}{n}{<-> CJK * gbkfs}{\CJKnormal}
\DeclareFontShape{C19}{tt}{b}{n}{<-> CJKb * gbkfs}{\CJKbold}
\DeclareFontShape{C19}{tt}{bx}{n}{<-> CJKb * gbkfs}{\CJKbold}
\DeclareFontShape{C19}{tt}{m}{sl}{<-> CJK * gbkfssl}{\CJKnormal}
\DeclareFontShape{C19}{tt}{b}{sl}{<-> CJKb * gbkfssl}{\CJKbold}
\DeclareFontShape{C19}{tt}{bx}{sl}{<-> CJKb * gbkfssl}{\CJKbold}
\DeclareFontShape{C19}{tt}{m}{it}{<-> CJK * gbkfs}{\CJKnormal}
\DeclareFontShape{C19}{tt}{b}{it}{<-> CJKb * gbkfs}{\CJKbold}
\DeclareFontShape{C19}{tt}{bx}{it}{<-> CJKb * gbkfs}{\CJKbold}
%
%<*c70>
\DeclareFontShape{C70}{tt}{m}{n}{<-> CJK * unifs}{\CJKnormal}
\DeclareFontShape{C70}{tt}{b}{n}{<-> CJKb * unifs}{\CJKbold}
\DeclareFontShape{C70}{tt}{bx}{n}{<-> CJKb * unifs}{\CJKbold}
\DeclareFontShape{C70}{tt}{m}{sl}{<-> CJK * unifssl}{\CJKnormal}
\DeclareFontShape{C70}{tt}{b}{sl}{<-> CJKb * unifssl}{\CJKbold}
\DeclareFontShape{C70}{tt}{bx}{sl}{<-> CJKb * unifssl}{\CJKbold}
\DeclareFontShape{C70}{tt}{m}{it}{<-> CJK * unifs}{\CJKnormal}
\DeclareFontShape{C70}{tt}{b}{it}{<-> CJKb * unifs}{\CJKbold}
\DeclareFontShape{C70}{tt}{bx}{it}{<-> CJKb * unifs}{\CJKbold}
%
%<*jy2>
\DeclareFontShape{JY2}{zhtt}{m}{n}{<-> upzhmono-h}{}
\DeclareFontShape{JY2}{zhtt}{b}{n}{<-> upzhmono-h}{}
\DeclareFontShape{JY2}{zhtt}{bx}{n}{<-> upzhmono-h}{}
\DeclareFontShape{JY2}{zhtt}{m}{sl}{<-> upzhmono-h}{}
\DeclareFontShape{JY2}{zhtt}{b}{sl}{<-> upzhmono-h}{}
\DeclareFontShape{JY2}{zhtt}{bx}{sl}{<-> upzhmono-h}{}
\DeclareFontShape{JY2}{zhtt}{m}{it}{<-> upzhmono-h}{}
\DeclareFontShape{JY2}{zhtt}{b}{it}{<-> upzhmono-h}{}
\DeclareFontShape{JY2}{zhtt}{bx}{it}{<-> upzhmono-h}{}
%
%<*jt2>
\DeclareFontShape{JT2}{zhtt}{m}{n}{<-> upzhmono-v}{}
\DeclareFontShape{JT2}{zhtt}{b}{n}{<-> upzhmono-v}{}
\DeclareFontShape{JT2}{zhtt}{bx}{n}{<-> upzhmono-v}{}
\DeclareFontShape{JT2}{zhtt}{m}{sl}{<-> upzhmono-v}{}
\DeclareFontShape{JT2}{zhtt}{b}{sl}{<-> upzhmono-v}{}
\DeclareFontShape{JT2}{zhtt}{bx}{sl}{<-> upzhmono-v}{}
\DeclareFontShape{JT2}{zhtt}{m}{it}{<-> upzhmono-v}{}
\DeclareFontShape{JT2}{zhtt}{b}{it}{<-> upzhmono-v}{}
\DeclareFontShape{JT2}{zhtt}{bx}{it}{<-> upzhmono-v}{}
%
%
% \end{macrocode}
%
% \begin{macrocode}
%<@@=>
% \end{macrocode}
%
% \end{implementation}