Skip to content

Commit 5bd8084

Browse files
authored
Merge pull request #818 from myhsia/master
fix(ctex): 增加 makespa 时 `字体是否存在于当前路径` 判断
2 parents 943e10e + 3ac5c55 commit 5bd8084

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

ctex/ctex.dtx

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ Copyright and Licence
589589
% \changes{v2.4.15}{2019/03/23}{同步 \LaTeXiii{} 2019/03/05。}
590590
% \changes{v2.5.1}{2020/05/02}{\pkg{zhconv} 更名为 \pkg{ctex-zhconv}。}
591591
%
592-
% \CheckSum{6905}
592+
% \CheckSum{6916}
593593
%
594594
% \CharacterTable
595595
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -12238,29 +12238,47 @@ Copyright and Licence
1223812238
% \end{macrocode}
1223912239
%
1224012240
% \begin{macro}{\@@_if_font_exists:nTF}
12241-
% 检测字体是否为 \TeX\ Tree 字体,\cs{@@_write_family:nn} 会根据结果调用
12242-
% |kpathsea| 查文件或 |fontconfig| 查名称。
12241+
% 优先搜索字体是否为 \TeX\ Tree 字体或是否存在于当前路径下\footnote{^^A
12242+
% 事实上 \path{TEXINPUTS} 也会被一并优先搜索。},
12243+
% 如果不存在,\cs{@@_write_family:nn} 会根据结果在 |shell| 中调用 |kpathsea| 查文件
12244+
% 或 |fontconfig| 查名称\footnote{^^A
12245+
% 如果用户把字体目录加入到了 \path{TEXINPUTS} 中,
12246+
% \cs{file_if_exist_p:n} 可能找到一个 \XeTeX\ |"[basename]"| 加载不了的文件,
12247+
% 因为 \XeTeX\ 搜索字体专属路径 \path{OPENTYPEFONTS}/\path{TTFONTS},
12248+
% 不搜索 \path{TEXINPUTS})。
12249+
% }。
1224312250
% \begin{macrocode}
1224412251
\prg_new_protected_conditional:Nnn \@@_if_font_exists:n { TF }
1224512252
{
12246-
\sys_get_shell:nnN { kpsewhich ~ #1.otf } { \endlinechar=-1 }
12247-
\l_@@_if_font_exists_otf_tl
12248-
\sys_get_shell:nnN { kpsewhich ~ #1.ttf } { \endlinechar=-1 }
12249-
\l_@@_if_font_exists_ttf_tl
12253+
\tl_clear:N \l_@@_if_otf_exists_tl
12254+
\tl_clear:N \l_@@_if_ttf_exists_tl
12255+
\bool_case:nF
12256+
{
12257+
{ \file_if_exist_p:n { #1.otf } }
12258+
{ \tl_set:Nn \l_@@_if_otf_exists_tl {#1} }
12259+
{ \file_if_exist_p:n { #1.ttf } }
12260+
{ \tl_set:Nn \l_@@_if_ttf_exists_tl {#1} }
12261+
}
12262+
{
12263+
\sys_get_shell:nnN { kpsewhich ~ #1.otf } { \endlinechar=-1 }
12264+
\l_@@_if_otf_exists_tl
12265+
\sys_get_shell:nnN { kpsewhich ~ #1.ttf } { \endlinechar=-1 }
12266+
\l_@@_if_ttf_exists_tl
12267+
}
1225012268
\bool_lazy_and:nnTF
12251-
{ \tl_if_blank_p:V \l_@@_if_font_exists_otf_tl }
12252-
{ \tl_if_blank_p:V \l_@@_if_font_exists_ttf_tl }
12269+
{ \tl_if_blank_p:V \l_@@_if_otf_exists_tl }
12270+
{ \tl_if_blank_p:V \l_@@_if_ttf_exists_tl }
1225312271
{ \prg_return_false: } { \prg_return_true: }
1225412272
}
1225512273
% \end{macrocode}
1225612274
% \end{macro}
1225712275
%
1225812276
% \begin{variable}
12259-
% {\l_@@_if_font_exists_otf_tl, \l_@@_if_font_exists_ttf_tl}
12277+
% {\l_@@_if_otf_exists_tl, \l_@@_if_ttf_exists_tl}
1226012278
% 用于存储 |shell| 输出的 |kpsewhich| 结果。
1226112279
% \begin{macrocode}
12262-
\tl_new:N \l_@@_if_font_exists_otf_tl
12263-
\tl_new:N \l_@@_if_font_exists_ttf_tl
12280+
\tl_clear_new:N \l_@@_if_otf_exists_tl
12281+
\tl_clear_new:N \l_@@_if_ttf_exists_tl
1226412282
% \end{macrocode}
1226512283
% \end{variable}
1226612284
%

0 commit comments

Comments
 (0)