From 3851cb5112493bb4778c751f24b877d07cc568bf Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 10 Feb 2020 22:12:31 +0000 Subject: xecjk (10feb20) git-svn-id: svn://tug.org/texlive/trunk@53750 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx | 433 +++++++++-------------- 1 file changed, 177 insertions(+), 256 deletions(-) (limited to 'Master/texmf-dist/source') diff --git a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx index 396d478dfb9..1f66d8cff13 100644 --- a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx +++ b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx @@ -26,8 +26,8 @@ Copyright and Licence --------------------- Copyright (C) 2007--2010 by Wenchang Sun - Copyright (C) 2009--2019 by Leo Liu - Copyright (C) 2012--2019 by Qing Lee + Copyright (C) 2009--2020 by Leo Liu + Copyright (C) 2012--2020 by Qing Lee ---------------------------------------------------------------------- This work may be distributed and/or modified under the @@ -92,8 +92,8 @@ Copyright and Licence \preamble Copyright (C) 2007--2010 by Wenchang Sun - Copyright (C) 2009--2019 by Leo Liu - Copyright (C) 2012--2019 by Qing Lee + Copyright (C) 2009--2020 by Leo Liu + Copyright (C) 2012--2020 by Qing Lee ---------------------------------------------------------------------- This work may be distributed and/or modified under the @@ -194,7 +194,7 @@ Copyright and Licence %<*package|config|fntef|listings|xunicode|xunextra> %\NeedsTeXFormat{LaTeX2e} %\RequirePackage{expl3} -%<+!driver>\GetIdInfo$Id: xeCJK.dtx 4449ab5 2019-06-02 23:02:31 +0800 Qing Lee $ +%<+!driver>\GetIdInfo$Id: xeCJK.dtx 06a6ce4 2020-02-10 22:37:50 +0800 Qing Lee $ % {Typesetting CJK scripts with XeLaTeX} % {Configuration file for xeCJK package} % {xeCJK font effect} @@ -207,7 +207,7 @@ Copyright and Licence %\ProvidesExplPackage{xeCJK-listings} %\ProvidesExplPackage{xunicode-addon} %\ProvidesExplFile{xunicode-extra.def} -% {\ExplFileDate}{3.7.4}{\ExplFileDescription} +% {\ExplFileDate}{3.8.0}{\ExplFileDescription} % %<*driver> \documentclass{ctxdoc} @@ -280,8 +280,10 @@ Copyright and Licence % \changes{v3.6.0}{2018/01/13}{同步 \LaTeXiii{} 2017/12/16。} % \changes{v3.6.1}{2018/02/27}{减少 \texttt{bool} 运算。} % \changes{v3.7.2}{2019/03/23}{同步 \LaTeXiii{} 2019/03/05。} +% \changes{v3.8.0}{2020/02/09}{兼容 \LaTeXe\ 2020/02/02 对 \pkg{NFSS} 的修改。} +% \changes{v3.8.0}{2020/02/09}{清理过时的兼容性补丁代码。} % -% \CheckSum{10786} +% \CheckSum{10751} % \GetFileId{xeCJK.sty} % % \title{\bfseries\pkg{xeCJK} 宏包} @@ -1610,7 +1612,7 @@ Copyright and Licence using~your~TeX~package~manager~or~from~CTAN.\\ \str_if_eq:nnT {#1} { expl3 } { Loading~xeCJK~will~abort! } } -\@ifpackagelater { expl3 } { 2019/03/05 } { } +\@ifpackagelater { expl3 } { 2020/02/08 } { } { \msg_critical:nnn { xeCJK } { l3-too-old } { expl3 } } % \end{macrocode} % @@ -1638,12 +1640,13 @@ Copyright and Licence The~`#1'~package~and~xeCJK~are~incompatible.\\\\ Please~load~it~after~xeCJK. } -\clist_map_inline:nn { CJKfntef , CJKnumb } +\clist_map_inline:nn { CJKnumb } { \xeCJK_if_package_loaded:nT {#1} { \msg_error:nnn { xeCJK } { after-package } {#1} } } -\clist_map_inline:nn { CJKulem , CJKvert , CJKpunct , CJKutf8 , CJK } +\clist_map_inline:nn + { CJKfntef , CJKulem , CJKvert , CJKpunct , CJKutf8 , CJK } { \xeCJK_if_package_loaded:nTF {#1} { \msg_error:nnn { xeCJK } { incompatible-package } {#1} } @@ -1651,16 +1654,8 @@ Copyright and Licence } % \end{macrocode} % -% 以下日期以前的 \pkg{xtemplate} 宏包关于 \tn{KeyValue} 的 Bug 会影响到后面 -% 标点符号的处理。 -% \begin{macrocode} -\RequirePackage { xtemplate } -\@ifpackagelater { xtemplate } { 2012/11/10 } { } - { \msg_error:nnn { xeCJK } { l3-too-old } { xtemplate } } -% \end{macrocode} -% % \begin{macrocode} -\RequirePackage { xparse , l3keys2e } +\RequirePackage { l3keys2e , xtemplate , xparse } % \end{macrocode} % % \subsection{内部工具} @@ -1827,14 +1822,12 @@ Copyright and Licence % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\xeCJK_font_gset_to_current:c} +% \begin{macro}[int]{\xeCJK_font_gset_to_current:N} % |#1| 是控制序列的名字,令它等于当前字体命令。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \xeCJK_font_gset_to_current:c #1 - { - \exp_last_unbraced:Nco \cs_gset_eq:NN - {#1} \tex_the:D \tex_font:D - } +\cs_new_protected_nopar:Npn \xeCJK_font_gset_to_current:N #1 + { \exp_after:wN \cs_gset_eq:NN \exp_after:wN #1 \tex_the:D \tex_font:D } +\cs_generate_variant:Nn \xeCJK_font_gset_to_current:N { c } % \end{macrocode} % \end{macro} % @@ -1986,8 +1979,10 @@ Copyright and Licence \cs_new_protected:Npn \xeCJK_peek_catcode_ignore_spaces:NTF #1#2#3 { \cs_set_eq:NN \l_@@_peek_search_token #1 \scan_stop: - \tl_set:Nn \@@_peek_catcode_true:w { \group_align_safe_end: #2 } - \tl_set:Nn \@@_peek_catcode_false:w { \group_align_safe_end: #3 } + \cs_set_protected:Npx \@@_peek_catcode_true:w + { \exp_not:N \group_align_safe_end: \exp_not:n {#2} } + \cs_set_protected:Npx \@@_peek_catcode_false:w + { \exp_not:N \group_align_safe_end: \exp_not:n {#3} } \bool_set_false:N \l_@@_peek_ignore_spaces_bool \group_align_safe_begin: \peek_after:Nw \@@_peek_catcode_ignore_spaces_branches:w @@ -2011,33 +2006,13 @@ Copyright and Licence \fi: } \cs_new_eq:NN \l_@@_peek_search_token ? -\tl_new:N \@@_peek_catcode_true:w -\tl_new:N \@@_peek_catcode_false:w +\cs_new_eq:NN \@@_peek_catcode_true:w \prg_do_nothing: +\cs_new_eq:NN \@@_peek_catcode_false:w \prg_do_nothing: \bool_new:N \l_@@_peek_ignore_spaces_bool % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\xeCJK_peek_after_ignore_spaces:nw} -% 与 \tn{@ifnextchar} 和 \tn{futurenonspacelet} 类似,会省略掉后面的空格。 -% \begin{macrocode} -\cs_new_protected:Npn \xeCJK_peek_after_ignore_spaces:nw #1 - { - \tl_set:Nn \@@_peek_after_do:w { \group_align_safe_end: #1 } - \group_align_safe_begin: - \peek_after:Nw \@@_peek_ignore_spaces_branches:w - } -\cs_new_protected_nopar:Npn \@@_peek_ignore_spaces_branches:w - { - \if_meaning:w \l_peek_token \c_space_token - \exp_after:wN \peek_after:Nw - \exp_after:wN \@@_peek_ignore_spaces_branches:w - \tex_romannumeral:D 0 - \else: - \exp_after:wN \@@_peek_after_do:w - \fi: - } -% \end{macrocode} -% \end{macro} +% \changes{v3.8.0}{2020/02/10}{应用 \cs{peek_remove_spaces:n}。} % % \begin{macro}[int]{\xeCJK_token_value_class:N} % 用于取得记号 |#1| 所在的 \XeTeX 字符类。|#1| 应为 \tn{catcode} 为 |11| 或 |12| @@ -4559,10 +4534,7 @@ Copyright and Licence % \begin{macro}[int]{\xeCJK_check_FullRight_symbol:Nw} % \begin{macrocode} \cs_new_protected_nopar:Npn \xeCJK_check_FullRight_symbol:Nw #1 - { - \xeCJK_peek_after_ignore_spaces:nw - { \@@_save_FullRight_symbol:N #1 } - } + { \peek_remove_spaces:n { \@@_save_FullRight_symbol:N #1 } } % \end{macrocode} % \end{macro} % @@ -5702,6 +5674,7 @@ Copyright and Licence % \end{macro} % % \changes{v3.2.7}{2013/08/25}{标点宽度设置禁用比例选项的值改为 \texttt{nan}。} +% \changes{v3.8.0}{2020/02/10}{应用 \cs{fp_if_nan:nTF}。} % % \begin{macro}{\@@_punct_width_or_ratio:nN} % \begin{macrocode} @@ -5710,7 +5683,7 @@ Copyright and Licence \dim_compare:nNnTF { \use:c { l_@@_#1_punct_width_dim } } < \c_max_dim { \use:c { l_@@_#1_punct_width_dim } } { - \fp_compare:nNnTF { \use:c { l_@@_#1_punct_ratio_fp } } ? \c_zero_fp + \fp_if_nan:nTF { \use:c { l_@@_#1_punct_ratio_fp } } { \c_max_dim } { \fp_use:c { l_@@_#1_punct_ratio_fp } @@ -5853,7 +5826,7 @@ Copyright and Licence \dim_compare:nNnTF \l_@@_kerning_total_width_dim < \c_max_dim { \@@_calc_kerning_margin:nNN \l_@@_kerning_total_width_dim } { - \fp_compare:nNnTF \l_@@_kerning_total_ratio_fp ? \c_zero_fp + \fp_if_nan:nTF { \l_@@_kerning_total_ratio_fp } { \xeCJK_if_same_class:NNTF #1 #2 { \@@_kerning_width_or_ratio:nNN { same } } @@ -5882,7 +5855,7 @@ Copyright and Licence \dim_compare:nNnTF { \use:c { l_@@_#1_align_margin_dim } } < \c_max_dim { \use:c { l_@@_#1_align_margin_dim } } { - \fp_compare:nNnTF { \use:c { l_@@_#1_align_ratio_fp } } ? \c_zero_fp + \fp_if_nan:nTF { \use:c { l_@@_#1_align_ratio_fp } } { \dim_compare:nNnTF \l_@@_kerning_margin_width_dim < \c_max_dim { \l_@@_kerning_margin_width_dim \use_none:n } @@ -6627,12 +6600,19 @@ Copyright and Licence { \@@_font_csname:n { \CJK@family } } \cs_new_protected_nopar:Npn \xeCJK_select_font: { - \exp_args:Nc \cs_if_exist_use:NF { \l_xeCJK_current_font_tl } + \@@_select_font:cn + { \l_xeCJK_current_font_tl } + { \l_xeCJK_family_tl } + } +\cs_new_protected_nopar:Npn \@@_select_font:Nn #1#2 + { + \cs_if_exist_use:NF #1 { - \@@_family_use:n { \l_xeCJK_family_tl } - \xeCJK_font_gset_to_current:c { \l_xeCJK_current_font_tl } + \@@_family_use:n {#2} + \xeCJK_font_gset_to_current:N #1 } } +\cs_generate_variant:Nn \@@_select_font:Nn { c } \tl_new:N \l_@@_current_coor_tl \cs_new_eq:NN \xeCJK@setfont \xeCJK_select_font: % \end{macrocode} @@ -6646,11 +6626,9 @@ Copyright and Licence \cs_new_eq:NN \xeCJK_select_punct_font: \xeCJK_select_font: \cs_new_protected_nopar:Npn \@@_select_punct_font_aux: { - \exp_args:Nc \cs_if_exist_use:NF { \l_xeCJK_current_punct_font_tl } - { - \@@_family_use:n { \l_xeCJK_punct_family_tl } - \xeCJK_font_gset_to_current:c { \l_xeCJK_current_punct_font_tl } - } + \@@_select_font:cn + { \l_xeCJK_current_punct_font_tl } + { \l_xeCJK_punct_family_tl } } \tl_new:N \CJK@punctfamily \tl_new:N \l_xeCJK_punct_family_tl @@ -6688,15 +6666,21 @@ Copyright and Licence % \begin{macrocode} \cs_new_protected_nopar:Npn \xeCJK_select_font:n #1 { - \exp_args:Nc \cs_if_exist_use:NF + \@@_select_font:cnn { \@@_font_csname:n { \CJK@family/#1 } } + { \l_xeCJK_family_tl } + {#1} + } +\cs_new_protected_nopar:Npn \@@_select_font:Nnn #1#2#3 + { + \cs_if_exist_use:NF #1 { - \xeCJK_block_family:nn { \l_xeCJK_family_tl } {#1} - \@@_family_use:n { \l_xeCJK_family_tl/#1 } - \xeCJK_font_gset_to_current:c - { \@@_font_csname:n { \CJK@family/#1 } } + \xeCJK_block_family:nn {#2} {#3} + \@@_family_use:n { #2/#3 } + \xeCJK_font_gset_to_current:N #1 } } +\cs_generate_variant:Nn \@@_select_font:Nnn { c } \cs_new_protected_nopar:Npn \xeCJK_block_family:nn #1#2 { \xeCJK_family_if_exist:xF { #1/#2 } @@ -6729,7 +6713,7 @@ Copyright and Licence { \@@_family_nfss_csname:n {#1} } { \exp_not:N \fontencoding { \c_@@_encoding_tl } - \tl_set:Nn \exp_not:N \f@family {#2} + \@@_nfss_family:n {#2} \exp_not:N \selectfont } } @@ -6737,6 +6721,37 @@ Copyright and Licence % \end{macrocode} % \end{macro} % +% \begin{macro}{\@@_nfss_family:n} +% 用于处理 \LaTeXe\ 2020/02/02 中 \tn{bfseries@rm} 等与 \tn{\bfdefault} 不一致可能导致的问题。 +% \begin{macrocode} +\cs_if_exist:NTF \fontseriesforce + { + \cs_new_protected_nopar:Npn \@@_nfss_family:n #1 + { + \str_if_eq:eeF { \f@series } { \bfdefault } + { + \str_case_e:nn { \f@family } + { + { \rmdefault } { \@@_nfss_series:n { rm } } + { \sfdefault } { \@@_nfss_series:n { sf } } + { \ttdefault } { \@@_nfss_series:n { tt } } + } + } + \fontfamily {#1} + } + \cs_new_protected_nopar:Npn \@@_nfss_series:n #1 + { + \str_if_eq:eeT { \f@series } { \use:c { bfseries@#1 } } + { \fontseriesforce { \bfdefault } } + } + } + { + \cs_new_protected_nopar:Npn \@@_nfss_family:n #1 + { \tl_set:Nn \f@family {#1} } + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[TF,int]{\xeCJK_family_if_exist:n} % \begin{macrocode} \prg_new_protected_conditional:Npnn \xeCJK_family_if_exist:n #1 { T , F , TF } @@ -6853,7 +6868,7 @@ Copyright and Licence % \begin{macrocode} \cs_new_protected_nopar:Npn \@@_gobble_CJKfamily: { \cs_set_eq:NN \CJKfamily \@@_gobble_CJKfamily:wn } -\DeclareExpandableDocumentCommand \@@_gobble_CJKfamily:wn { t+ t- m } { } +\NewExpandableDocumentCommand \@@_gobble_CJKfamily:wn { t+ t- m } { } % \end{macrocode} % \end{macro} % @@ -7754,64 +7769,73 @@ Copyright and Licence % \end{macro} % % \begin{macro}[int]{\xeCJK_visible_space:} +% \begin{macro}[int]{\@setupverbvisiblespace} % \changes{v3.2.5}{2013/07/13}{可视空格考虑传统 \TeX 字体的情况。} +% \changes{v3.8.0}{2020/02/09}{更新可视空格补丁。} % 如果文档不使用 \texttt{EU1} 作为默认字体编码,那么默认的打字机字体族很可能是 % 传统的 \TeX 字体,这时可视空格按照 \texttt{OT1} 编码传统一般就是字体中的 |\char32|。 -% 这里加入 \cs{scan_stop:} 的目的是强制发生状态转移。这样当空格出现在 CJK 文字 -% 后面时,使字体回到西文,保证在当前西文字体而不是在 CJK 字体中检查有没有 |U+2423|。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \xeCJK_visible_space: +\cs_new_protected_nopar:Npn \xeCJK_setup_visible_space: { \xeCJK_make_boundary: \xeCJK_glyph_if_exist:NTF { ^^^^2423 } - { ^^^^2423 } + { \tl_set:Nn \l_@@_visible_space_tl { ^^^^2423 } } { \int_compare:nNnTF { \tex_XeTeXfonttype:D \tex_font:D } = \c_zero_int { - \str_if_eq:eeTF { \f@family } { \ttdefault } - { \c_catcode_other_space_tl } - { \textvisiblespace } + \tl_set:Nx \l_@@_visible_space_tl + { + \str_if_eq:eeTF { \f@family } { \ttdefault } + { \c_catcode_other_space_tl } + { \exp_not:N \textvisiblespace } + } } - { \xeCJK_visible_space_fallback: } + { \@@_visible_space_fallback: } } + \cs_set_eq:NN \@xobeysp \l_@@_visible_space_tl } -\AtEndOfPackage - { \cs_gset_eq:NN \fontspec_visible_space: \xeCJK_visible_space: } +\tl_new:N \l_@@_visible_space_tl +\cs_set_eq:NN \@setupverbvisiblespace \xeCJK_setup_visible_space: % \end{macrocode} % \end{macro} +% \end{macro} % -% \begin{macro}[int]{\xeCJK_visible_space_fallback:} -% \changes{v3.1.0}{2012/11/19} -% {调整 \pkg{fontspec} 的后备可视空格符号,以便于使用时对齐。} -% \pkg{fontspec} 使用 |lmtt| 字体中的可视空格符号(|U+2423|)作为当前字体中相应符号 -% 的后备。但是 |lmtt| 的字体大小未必与当前字体匹配。因此,我们在这里做一些调整,以 +% \begin{macro}{\@@_visible_space_fallback:} +% 我们使用 |lmtt| 字体中的可视空格符号(|U+2423|)作为当前字体中相应符号 +% 的后备,但是 |lmtt| 的字体大小未必与当前字体匹配。因此,这里需要做一些调整,以 % 保证使用后备可视空格符号时,也能保证对齐。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \xeCJK_visible_space_fallback: - { { - \cs_if_exist_use:cF { xeCJK/space/\curr@fontshape/\f@size } - { \xeCJK_set_visible_space_font: } - ^^^^2423 - } } +\cs_new_protected_nopar:Npn \@@_visible_space_fallback: + { + \exp_args:Nc \@@_visible_space_fallback_auxi:N + { xeCJK/space/\curr@fontshape/\f@size } + } +\cs_new_protected_nopar:Npn \@@_visible_space_fallback_auxi:N #1 + { + \cs_if_exist:NF #1 + { \@@_visible_space_fallback_auxii:N #1 } + \tl_set:Nn \l_@@_visible_space_tl {#1} + } % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\xeCJK_set_visible_space_font:} +% \begin{macro}{\@@_visible_space_fallback_auxii:N} % 当前字体空格的宽度与后备字体 |lmtt| 不一样时,就对 \tn{textvisiblespace} 的字体尺寸 % 按相应的比例放缩。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \xeCJK_set_visible_space_font: +\cs_new_protected_nopar:Npn \@@_visible_space_fallback_auxii:N #1 { - \tl_set:Nx \l_@@_current_coor_tl - { xeCJK/space/\curr@fontshape/\f@size } - \exp_args:No \@@_set_visible_space_size:n - { \dim_use:N \tex_fontdimen:D 2 ~ \tex_font:D } - \xeCJK_font_gset_to_current:c { \l_@@_current_coor_tl } + \group_begin: + \exp_args:No \@@_set_visible_space_size:n + { \dim_use:N \tex_fontdimen:D 2 ~ \tex_font:D } + \cs_new_protected_nopar:Npx #1 + { \group_begin: \tex_the:D \tex_font:D ^^^^2423 \group_end: } + \group_end: } \cs_new_protected_nopar:Npn \@@_set_visible_space_size:n #1 { - \fontencoding { \g_fontspec_encoding_tl } - \tl_set:Nx \f@family { lmtt } + \fontencoding { \UnicodeEncodingName } + \tl_set:Nn \f@family { lmtt } \selectfont \dim_compare:nNnF {#1} = { \tex_fontdimen:D 2 ~ \tex_font:D } { @@ -7968,7 +7992,7 @@ Copyright and Licence % 执行宏包选项,并载入 \pkg{fontspec} 宏包。 % \begin{macrocode} \ProcessKeysOptions { xeCJK / options } -\RequirePackage { fontspec } [ 2019/03/15 ] +\RequirePackage { fontspec } [ 2020/02/03 ] % \end{macrocode} % % \begin{variable}{\c_@@_encoding_tl} @@ -7989,7 +8013,7 @@ Copyright and Licence } \@@_msg_new:nn { option-invalid } { - The~`#1'~option~only~can~be~set~in~the~optional~argument~to~the\\ + The~`#1'~option~can~only~be~set~in~the~optional~argument~to~the\\ \token_to_str:N \usepackage \ command~when~xeCJK~is~being~loaded.\\\\ Please~do~not~set~it~via~the~\token_to_str:N \xeCJKsetup \ command. } @@ -8086,40 +8110,8 @@ Copyright and Licence % % \subsection{兼容性修补} % -% \begin{macro}[int]{\hbar} % \changes{v3.2.16}{2014/11/20}{修复 \tn{hbar}。} -% \pkg{fontspec} 会设置 operators 数学字体族(|\fam0|)为 \texttt{EU1} 编码的 -% \tn{rmdefault} 字体。这导致 \LaTeXe{} 定义的 \tn{hbar} 只显示为 $h$。 -% \begin{macrocode} -\cs_new_protected_nopar:Npn \xeCJK_fix_hbar: - { - \cs_if_free:NF \symlegacymaths - { - \group_begin: - \cs_set_nopar:Npn \@@_tmp:w - { { \mathchar '26 \mkern -9mu h } } - \exp_after:wN \group_end: - \if_meaning:w \@@_tmp:w \hbar - \cs_set_protected_nopar:Npx \hbar - { { - \mathchar - \int_eval:n { \symlegacymaths * 256 + '26 } ~ - \mkern -9mu h - } } - \fi: - } - } -\cs_if_exist:NTF \fontspec_maybe_setup_maths: - { - \cs_gset_protected_nopar:Npx \fontspec_maybe_setup_maths: - { - \exp_not:o { \fontspec_maybe_setup_maths: } - \xeCJK_fix_hbar: - } - } - { \AtBeginDocument { \xeCJK_fix_hbar: } } -% \end{macrocode} -% \end{macro} +% \changes{v3.8.0}{2020/02/09}{删除 \tn{hbar} 补丁。} % % \begin{macro}[int]{\xeCJK@update@fam,\Url@MathSetup} % \changes{v3.2.7}{2013/11/09}{使通过 \tn{UrlFont} 等命令设置的 CJK 字体生效。} @@ -8170,29 +8162,8 @@ Copyright and Licence % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\fontspec_setup_maths:,\mathrm} % \changes{v3.2.6}{2013/08/02}{为 \tn{mathrm} 减少一个可能的数学字体族。} -% 如果没有设置 \tn{setboldmathrm},即 \cs{g_fontspec_bfmathrm_tl} 为空,那么 -% \tn{mathrm} 的字体实际与 \texttt{operators} 字体族完全一致。这时候应该通过 -% \tn{DeclareSymbolFontAlphabet} 来定义 \tn{mathrm},避免使用它的时候再声明 -% 一个重复的数学字体族。\pkg{fontspec} v2.4a 已经正确定义了 \tn{mathrm}。 -% \begin{macrocode} -\@ifpackagelater { fontspec } { 2014/06/21 } { } - { - \cs_gset_protected_nopar:Npx \fontspec_setup_maths: - { - \exp_not:o - { - \fontspec_setup_maths: - \bool_lazy_or:nnT - { \tl_if_empty_p:N \g__fontspec_bfmathrm_tl } - { \tl_if_empty_p:N \g_fontspec_bfmathrm_tl } - { \DeclareSymbolFontAlphabet \mathrm { operators } } - } - } - } -% \end{macrocode} -% \end{macro} +% \changes{v3.8.0}{2020/02/09}{删除 \tn{mathrm} 补丁。} % % \changes{v3.4.5}{2017/01/02}{更新 \LaTeXiii{} 的过时用法。} % @@ -8297,72 +8268,52 @@ Copyright and Licence % \changes{v3.7.0}{2018/03/18}{对 \tn{nobreakspace} 的恢复放到 \pkg{xunicode-addon} 中处理。} % % \changes{v3.1.1}{2012/12/13}{对于与 \pkg{xltxtra} 的冲突给出错误警告。} -% 比较老版本的 \pkg{realscripts} 定义了 \cs{dim_max:nn} 和 \cs{dim_min:nn},这与 -% 新版本的 \pkg{expl3} 冲突。 -% \begin{macrocode} -\@@_msg_new:nn { conflict-package } - { - The~`#1'~package~is~too~old. \\ - Please~update~an~up~to~date~version~of~it\\ - using~your~TeX~package~manager~or~from~CTAN. - } -\xeCJK_if_package_loaded:nTF { realscripts } - { - \@ifpackagelater { realscripts } { 2010/10/10 } { } - { - \@@_error:nx { conflict-package } - { - \xeCJK_if_package_loaded:nTF { xltxtra } - { xltxtra } { realscripts } - } - } - } - { - \cs_new_eq:NN \@@_dim_max:nn \dim_max:nn - \cs_new_eq:NN \@@_dim_min:nn \dim_min:nn - \@@_at_end_preamble:n - { - \xeCJK_if_package_loaded:nT { realscripts } - { - \@ifpackagelater { realscripts } { 2010/10/10 } { } - { - \cs_gset_eq:NN \dim_max:nn \@@_dim_max:nn - \cs_gset_eq:NN \dim_min:nn \@@_dim_min:nn - } - } - \cs_undefine:N \@@_dim_max:nn - \cs_undefine:N \@@_dim_min:nn - } - } -% \end{macrocode} +% \changes{v3.8.0}{2020/02/09}{删除 \pkg{realscripts} 补丁。} % % \begin{macro}[int]{\fontfamily} -% \begin{macro}[int]{\xeCJK@fontfamily} +% \begin{macro}[int]{\xeCJK@fontfamily,\xeCJK@family} % \changes{v3.1.1}{2012/12/06}{修改主要 \texttt{CJK} 字体族的自动更新方式。} % \changes{v3.1.2}{2013/01/01}{不将参数完全展开。} % \changes{v3.4.6}{2017/02/23} % {将族名参数完全展开,以解决与 \pkg{fontspec} 2017/01/24 v2.5d 的兼容问题。} -% 修改 \tn{fontfamily},使主要 |CJK| 字体族能随西文主要字体更新。 +% 对于 \LaTeXe\ 2020/02/02 之前的版本,修改 \tn{fontfamily}, +% 使主要 |CJK| 字体族能随西文主要字体更新,之后的版本可以使用 \tn{@rmfamilyhook} 等新钩子处理。 % \begin{macrocode} -\RenewDocumentCommand \fontfamily { m } - { - \tl_set:Nx \f@family {#1} - \xeCJK@fontfamily {#1} - } -\cs_new_protected_nopar:Npn \xeCJK@fontfamily #1 +\cs_if_exist:NTF \@rmfamilyhook { - \str_if_eq:nnTF {#1} { \familydefault } - { \xeCJK_switch_family:x { \CJKfamilydefault } } - { \@@_update_family_aux: } + \cs_set_eq:NN \xeCJK@family \xeCJK_switch_family:x + \g@addto@macro \@rmfamilyhook { \xeCJK@family { \CJKrmdefault } } + \g@addto@macro \@sffamilyhook { \xeCJK@family { \CJKsfdefault } } + \g@addto@macro \@ttfamilyhook { \xeCJK@family { \CJKttdefault } } + \exp_args:Nx \g@addto@macro + { + \cs_if_exist:NTF \@defaultfamilyhook + { \exp_not:N \@defaultfamilyhook } + { \exp_not:c { normalfont ~ } } + } + { \xeCJK@family { \CJKfamilydefault } } } -\cs_new_protected_nopar:Npn \@@_update_family_aux: { - \str_case_e:nn { \f@family } + \RenewDocumentCommand \fontfamily { m } + { + \tl_set:Nx \f@family {#1} + \xeCJK@fontfamily {#1} + } + \cs_new_protected_nopar:Npn \xeCJK@fontfamily #1 { - { \rmdefault } { \xeCJK_switch_family:x { \CJKrmdefault } } - { \sfdefault } { \xeCJK_switch_family:x { \CJKsfdefault } } - { \ttdefault } { \xeCJK_switch_family:x { \CJKttdefault } } - { \familydefault } { \xeCJK_switch_family:x { \CJKfamilydefault } } + \str_if_eq:nnTF {#1} { \familydefault } + { \xeCJK_switch_family:x { \CJKfamilydefault } } + { \@@_update_family_aux: } + } + \cs_new_protected_nopar:Npn \@@_update_family_aux: + { + \str_case_e:nn { \f@family } + { + { \rmdefault } { \xeCJK_switch_family:x { \CJKrmdefault } } + { \sfdefault } { \xeCJK_switch_family:x { \CJKsfdefault } } + { \ttdefault } { \xeCJK_switch_family:x { \CJKttdefault } } + { \familydefault } { \xeCJK_switch_family:x { \CJKfamilydefault } } + } } } % \end{macrocode} @@ -8790,31 +8741,7 @@ Copyright and Licence % \end{macrocode} % % \changes{v3.2.11}{2014/03/14}{删除 \tn{xeCJKcaption}。} -% -% 由于 \pkg{xeCJK} 禁止 \pkg{CJKulem} 的载入,因此当使用 \pkg{ctex} 宏包的 |fntef| -% 选项时,就会出现 \tn{normalem} 没有定义的问题。此时改用 \pkg{xeCJKfntef} 以便 -% 载入 \pkg{ulem}。 -% -% 判断过于繁琐,应该在 \pkg{ctex} 包中妥善处理。这段代码应在 \pkg{ctex} 包发布 -% 新版本后删去。 -% \begin{macrocode} -\cs_if_eq:NNTF \ifCTEX@fntef \tex_iftrue:D - { \AtEndOfPackage { \RequirePackage { xeCJKfntef } } } - { - \@@_at_end_preamble:n - { - \xeCJK_if_package_loaded:nF { xeCJKfntef } - { - \xeCJK_if_package_loaded:nTF { CJKfntef } - { \RequirePackage { xeCJKfntef } } - { - \xeCJK_if_package_loaded:nT { ulem } - { \RequirePackage { xeCJKfntef } } - } - } - } - } -% \end{macrocode} +% \changes{v3.8.0}{2020/02/09}{删除 \pkg{CJKfntef} 补丁。} % % 导言区末尾检测到 \pkg{listings} 时,自动载入 \pkg{xeCJK-listings}。 % \begin{macrocode} @@ -8912,12 +8839,6 @@ Copyright and Licence \RequirePackage { ulem } % \end{macrocode} % -% 虽然我们不再依赖 \pkg{CJKfntef},但基于历史原因,我们仍然载入它。 -% \begin{macrocode} -\file_if_exist:nT { CJKfntef.sty } - { \RequirePackage { CJKfntef } } -% \end{macrocode} -% % \begin{macrocode} \addto@hook \UL@hook { \xeCJK_hook_for_ulem: } % \end{macrocode} @@ -9718,7 +9639,7 @@ Copyright and Licence % % \begin{macro}{\CJKunderline} % \begin{macrocode} -\DeclareDocumentCommand \CJKunderline { s t- s o } +\NewDocumentCommand \CJKunderline { s t- s o } { \xeCJK_ulem_group_begin: \xeCJK_fntef_boot:nnNNNn { underline } { uline } #1#2#3 {#4} @@ -9734,14 +9655,14 @@ Copyright and Licence } \xeCJK_ulem_on:n } -\DeclareDocumentCommand \varCJKunderline { } +\NewDocumentCommand \varCJKunderline { } { \CJKunderline - } % \end{macrocode} % \end{macro} % % \begin{macro}{\CJKunderwave} % \begin{macrocode} -\DeclareDocumentCommand \CJKunderwave { s t- s o } +\NewDocumentCommand \CJKunderwave { s t- s o } { \xeCJK_ulem_group_begin: \xeCJK_fntef_boot:nnNNNn { underwave } { uwave } #1#2#3 {#4} @@ -9756,7 +9677,7 @@ Copyright and Licence % % \begin{macro}{\CJKunderdblline} % \begin{macrocode} -\DeclareDocumentCommand \CJKunderdblline { s t- s o } +\NewDocumentCommand \CJKunderdblline { s t- s o } { \xeCJK_ulem_group_begin: \xeCJK_fntef_boot:nnNNNn { underdblline } { udbline } #1#2#3 {#4} @@ -9785,7 +9706,7 @@ Copyright and Licence % % \begin{macro}{\CJKsout} % \begin{macrocode} -\DeclareDocumentCommand \CJKsout { s t- s o } +\NewDocumentCommand \CJKsout { s t- s o } { \xeCJK_ulem_group_begin: \xeCJK_fntef_boot:nnNNNn { sout } { sout } #1#2#3 {#4} @@ -9809,7 +9730,7 @@ Copyright and Licence % % \begin{macro}{\CJKxout} % \begin{macrocode} -\DeclareDocumentCommand \CJKxout { s t- s o } +\NewDocumentCommand \CJKxout { s t- s o } { \xeCJK_ulem_group_begin: \xeCJK_fntef_boot:nnNNNn { xout } { xout } #1#2#3 {#4} @@ -9832,7 +9753,7 @@ Copyright and Licence % \begin{macro}{\CJKunderanyline} % \changes{v3.2.15}{2014/11/07}{完善选项。} % \begin{macrocode} -\DeclareDocumentCommand \CJKunderanyline { s t- s o m m } +\NewDocumentCommand \CJKunderanyline { s t- s o m m } { \xeCJK_ulem_group_begin: \xeCJK_ulem_boot:NNNn #1#2#3 {#4} @@ -10061,7 +9982,7 @@ Copyright and Licence % % \begin{macro}{\CJKunderanysymbol} % \begin{macrocode} -\DeclareDocumentCommand \CJKunderanysymbol { o m m m } +\NewDocumentCommand \CJKunderanysymbol { o m m m } { \xeCJK_under_symbol:nnnnnn { symbol } { symbol } {#1} {#2} {#3} {#4} \tex_ignorespaces:D @@ -10073,7 +9994,7 @@ Copyright and Licence % \tn{CJKunderdot} 是 \tn{CJKunderanysymbol} 的特殊情况。\pkg{CJKfntef} 原来使用 % 的是数学符号 \tn{cdot},这里改成更合适的 |.|。 % \begin{macrocode} -\DeclareDocumentCommand \CJKunderdot { o m } +\NewDocumentCommand \CJKunderdot { o m } { \xeCJK_under_symbol:nnnnnn { underdot } { udot } {#1} @@ -10215,7 +10136,7 @@ Copyright and Licence % 可选参数 |#1| 表示环境的垂直对齐位置,默认居中;参数 |#2| 表示环境的宽度。 % 带星号的环境,如果 |#2| 不大于零或者不大于环境最长文本行的宽度,则取环境的自然宽度。 % \begin{macrocode} -\DeclareDocumentEnvironment { CJKfilltwosides } { O { c } m } +\NewDocumentEnvironment { CJKfilltwosides } { O { c } m } { \use:x { \exp_not:N \minipage [#1] { \dim_eval:n {#2} } } \cs_set_eq:NN \CJKglue \xeCJK_fntef_hfilll: @@ -10224,7 +10145,7 @@ Copyright and Licence \endminipage \ignorespacesafterend } -\DeclareDocumentEnvironment { CJKfilltwosides* } { O { c } m +b } +\NewDocumentEnvironment { CJKfilltwosides* } { O { c } m +b } { \mode_leave_vertical: \cs_set_eq:NN \CJKglue \xeCJK_fntef_hfilll: -- cgit v1.2.3