diff options
author | Karl Berry <karl@freefriends.org> | 2022-06-04 20:26:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-06-04 20:26:21 +0000 |
commit | 0f916f34e48ab97878445b2eb4d9959beea94f51 (patch) | |
tree | 69cb435e400a35e30ca49a6000e513511d29c2e8 /Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty | |
parent | e7c28e322ceb0496bd9cd27bd1965e5fdb01da33 (diff) |
xecjk (4jun22)
git-svn-id: svn://tug.org/texlive/trunk@63486 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty')
-rw-r--r-- | Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty | 112 |
1 files changed, 66 insertions, 46 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty index ad05e95c01d..2cac4a0fb2b 100644 --- a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty +++ b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty @@ -7,8 +7,8 @@ %% xeCJK.dtx (with options: `package') %% %% Copyright (C) 2007--2010 by Wenchang Sun <sunwch@nankai.edu.cn> -%% Copyright (C) 2009--2021 by Leo Liu <leoliu.pku@gmail.com> -%% Copyright (C) 2012--2021 by Qing Lee <sobenlee@gmail.com> +%% Copyright (C) 2009--2022 by Leo Liu <leoliu.pku@gmail.com> +%% Copyright (C) 2012--2022 by Qing Lee <sobenlee@gmail.com> %% ---------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -29,10 +29,10 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: xeCJK.dtx d45555d 2021-12-12 18:20:36 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: xeCJK.dtx de49417 2022-06-04 19:40:54 +0800 Qing Lee <sobenlee@gmail.com> $ {Typesetting CJK scripts with XeLaTeX} \ProvidesExplPackage{\ExplFileName} - {\ExplFileDate}{3.8.8}{\ExplFileDescription} + {\ExplFileDate}{3.8.9}{\ExplFileDescription} \msg_new:nnn { xeCJK } { Require-XeTeX } { The~xeCJK~package~requires~XeTeX~to~function.\\\\ @@ -1169,7 +1169,7 @@ { \__xeCJK_punct_if_middle:NTF \g__xeCJK_last_punct_tl { - \__xeCJK_punct_bound_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl + \__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl \xeCJK_class_group_end: \exp_after:wN \xeCJK_punct_node:N \g__xeCJK_last_punct_tl \xeCJK_no_break: @@ -1348,7 +1348,7 @@ { \__xeCJK_punct_if_middle:NTF \g__xeCJK_last_punct_tl { - \__xeCJK_punct_bound_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl + \__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl \xeCJK_no_break: \__xeCJK_punct_glue:NN \c__xeCJK_left_tl \g__xeCJK_last_punct_tl } @@ -1359,7 +1359,7 @@ { \__xeCJK_punct_if_middle:NTF \g__xeCJK_last_punct_tl { - \__xeCJK_punct_bound_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl + \__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl \xeCJK_class_group_end: \xeCJK_no_break: \__xeCJK_punct_glue:NN \c__xeCJK_left_tl \g__xeCJK_last_punct_tl } @@ -1444,22 +1444,37 @@ { \__xeCJK_zero_glue: } \cs_new_protected:cpn { __xeCJK_bound_type_ 1 _glue:Nn } #1 { - \box_set_to_last:N \l__xeCJK_tmp_box + \int_do_while:nNnn \tex_lastnodetype:D = \c_one_int + { \__xeCJK_bound_hbox_auxi: } \int_compare:nNnTF \tex_lastnodetype:D = { -1 } { - \dim_compare:nNnTF - { \box_wd:N \l__xeCJK_tmp_box } = \tex_parindent:D + \dim_case:nnF { \box_wd:N \l__xeCJK_indent_box } { - \dim_compare:nNnTF - { \box_ht:N \l__xeCJK_tmp_box } = \c_zero_dim - { \use_i:nn } - { \use:nn } + { \tex_parindent:D } { \__xeCJK_bound_hbox_auxii:nn } + { \c_zero_dim } { \use_i:nn } } { \use:nn } } { \use:nn } - { \box_use_drop:N \l__xeCJK_tmp_box } + { \hbox_unpack_drop:N \l__xeCJK_indent_box } } +\cs_new_protected:Npn \__xeCJK_bound_hbox_auxi: + { + \box_set_to_last:N \l__xeCJK_tmp_box + \hbox_set:Nn \l__xeCJK_indent_box + { + \box_use:N \l__xeCJK_tmp_box + \hbox_unpack:N \l__xeCJK_indent_box + } + } +\cs_new_protected:Npn \__xeCJK_bound_hbox_auxii:nn + { + \dim_compare:nNnTF + { \box_ht:N \l__xeCJK_tmp_box } = \c_zero_dim + { \use_i:nn } + { \use:nn } + } +\box_new:N \l__xeCJK_indent_box \cs_new_protected:cpn { __xeCJK_bound_type_ 11 _glue:Nn } #1#2 { \skip_if_finite:nTF { \tex_lastskip:D } @@ -1692,7 +1707,7 @@ { \CJKglue \__xeCJK_punct_glue:NN \c__xeCJK_right_tl #1 - \__xeCJK_punct_bound_rule:NN \c__xeCJK_left_tl #1 + \__xeCJK_punct_rule:NN \c__xeCJK_left_tl #1 } } \cs_new_protected:Npn \__xeCJK_Default_and_FullRight_glue:N #1 @@ -1703,7 +1718,7 @@ \__xeCJK_punct_if_middle:NT #1 { \__xeCJK_punct_glue:NN \c__xeCJK_right_tl #1 - \__xeCJK_punct_bound_rule:NN \c__xeCJK_left_tl #1 + \__xeCJK_punct_rule:NN \c__xeCJK_left_tl #1 } } \cs_new_protected:Npn \xeCJK_FullLeft_and_FullLeft:N #1 @@ -2423,10 +2438,11 @@ { \exp_last_unbraced:NNo \xeCJK_get_punct_bounds:NN } \cs_new_protected:Npn \__xeCJK_save_punct_margin_plain:NN #1#2 { - \__xeCJK_save_punct_dim:nNNn { rule } #1 #2 { \c_zero_dim } \__xeCJK_save_punct_dim:nNNn { glue } #1 #2 { \c_zero_dim } \__xeCJK_save_punct_dim:nNNn { offset } #1 #2 { \c_zero_dim } \__xeCJK_save_punct_dim:nNNn { margin } #1 #2 { \c_zero_dim } + \__xeCJK_save_punct_dim:nNNn { rule } \c__xeCJK_left_tl {#2} { \c_zero_dim } + \__xeCJK_save_punct_dim:nNNn { rule } \c__xeCJK_right_tl {#2} { \c_zero_dim } \__xeCJK_save_punct_dim:nNNn { bound } \c__xeCJK_left_tl {#2} { \c_zero_dim } \__xeCJK_save_punct_dim:nNNn { bound } \c__xeCJK_right_tl {#2} { \c_zero_dim } \__xeCJK_save_punct_skip:nNNn { glue } #1 #2 { \c_zero_skip } @@ -2440,19 +2456,18 @@ \group_end: \dim_set:Nn \l__xeCJK_bound_dim { \__xeCJK_use_punct_dim:nNN { bound } #1 #2 } + \tl_if_eq:NNTF #1 \c__xeCJK_right_tl + { \tl_set_eq:NN \l__xeCJK_reverse_tl \c__xeCJK_left_tl } + { \tl_set_eq:NN \l__xeCJK_reverse_tl \c__xeCJK_right_tl } \dim_set:Nn \l__xeCJK_reverse_bound_dim - { - \tl_if_eq:NNTF #1 \c__xeCJK_left_tl - { \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_right_tl } - { \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_left_tl } - #2 - } + { \__xeCJK_use_punct_dim:nNN { bound } \l__xeCJK_reverse_tl #2 } \UseInstance { xeCJK / punctuation } { \l_xeCJK_punct_style_tl } \xeCJK_punct_margin_process:NN #1 #2 \xeCJK_punct_offset_process:NN #1 #2 \__xeCJK_punct_if_long:NT #2 { \__xeCJK_long_punct_kerning:N #2 } } +\tl_new:N \l__xeCJK_reverse_tl \dim_new:N \l__xeCJK_bound_dim \dim_new:N \l__xeCJK_reverse_bound_dim \cs_new_protected:Npn \__xeCJK_long_punct_kerning:N #1 @@ -2578,10 +2593,8 @@ \dim_compare:nNnTF \l__xeCJK_middle_margin_width_dim < \c_max_dim { \l__xeCJK_middle_margin_width_dim } { - \fp_use:N \l__xeCJK_middle_margin_ratio_fp - \tex_dimexpr:D - ( \l__xeCJK_bound_dim + \l__xeCJK_reverse_bound_dim ) / 2 - \scan_stop: + \__xeCJK_dim_ratio:Nn \l__xeCJK_middle_margin_ratio_fp + { ( \l__xeCJK_bound_dim + \l__xeCJK_reverse_bound_dim ) / 2 } } } { @@ -2590,6 +2603,9 @@ { \__xeCJK_margin_width_or_ratio:n { fixed } } } } +\cs_new:Npn \__xeCJK_dim_ratio:Nn #1#2 + { \fp_to_dim:n { #1 \dim_to_fp:n {#2} } } +\cs_generate_variant:Nn \__xeCJK_dim_ratio:Nn { c } \cs_new_protected:Npn \xeCJK_punct_offset_process:NN #1#2 { \dim_set:Nn \l__xeCJK_tmp_dim @@ -2637,6 +2653,8 @@ { \l__xeCJK_tmp_dim } \__xeCJK_save_punct_dim:nNNn { rule } #1 #2 { \l__xeCJK_tmp_dim - \l__xeCJK_bound_dim } + \__xeCJK_save_punct_dim:nNNn { rule } \l__xeCJK_reverse_tl #2 + { \l__xeCJK_tmp_dim - \l__xeCJK_reverse_bound_dim } \__xeCJK_save_punct_dim:nNNn { glue } #1 #2 { \l__xeCJK_margin_dim - \l__xeCJK_tmp_dim } \__xeCJK_save_punct_skip:nNNnnn { glue } #1 #2 @@ -2652,7 +2670,7 @@ } { \__xeCJK_punct_if_middle:NTF #2 - { .5 \l__xeCJK_margin_dim } + { \l__xeCJK_margin_dim / 2 } { \l__xeCJK_margin_dim - \l__xeCJK_reverse_bound_dim } } } @@ -2664,8 +2682,9 @@ \fp_if_nan:nTF { \use:c { l__xeCJK_#1_punct_ratio_fp } } { \c_max_dim } { - \fp_use:c { l__xeCJK_#1_punct_ratio_fp } - \tex_dimexpr:D \__xeCJK_use_punct_dim:nN { width } #2 \scan_stop: + \__xeCJK_dim_ratio:cn + { l__xeCJK_#1_punct_ratio_fp } + { \__xeCJK_use_punct_dim:nN { width } #2 } } } } @@ -2674,8 +2693,9 @@ \dim_compare:nNnTF { \use:c { l__xeCJK_#1_margin_width_dim } } < \c_max_dim { \use:c { l__xeCJK_#1_margin_width_dim } } { - \fp_use:c { l__xeCJK_#1_margin_ratio_fp } - \tex_dimexpr:D \l__xeCJK_bound_dim \scan_stop: + \__xeCJK_dim_ratio:cn + { l__xeCJK_#1_margin_ratio_fp } + { \l__xeCJK_bound_dim } } \bool_if:NT \l__xeCJK_add_min_bound_to_margin_bool { + \dim_min:nn \l__xeCJK_bound_dim \l__xeCJK_reverse_bound_dim } @@ -2781,11 +2801,11 @@ { \__xeCJK_calc_kerning_margin:nNN { - \fp_use:N \l__xeCJK_kerning_total_ratio_fp - \tex_dimexpr:D - \__xeCJK_use_punct_dim:nN { width } #1 + - \__xeCJK_use_punct_dim:nN { width } #2 - \scan_stop: + \__xeCJK_dim_ratio:Nn \l__xeCJK_kerning_total_ratio_fp + { + \__xeCJK_use_punct_dim:nN { width } #1 + + \__xeCJK_use_punct_dim:nN { width } #2 + } } } } @@ -2800,9 +2820,9 @@ { \dim_compare:nNnTF \l__xeCJK_kerning_margin_width_dim < \c_max_dim { \l__xeCJK_kerning_margin_width_dim \use_none:n } - { \fp_use:N \l__xeCJK_kerning_margin_ratio_fp \use:n } + { \__xeCJK_dim_ratio:Nn \l__xeCJK_kerning_margin_ratio_fp } } - { \fp_use:c { l__xeCJK_#1_align_ratio_fp } \use:n } + { \__xeCJK_dim_ratio:cn { l__xeCJK_#1_align_ratio_fp } } { \l__xeCJK_margin_dim } } } @@ -4232,7 +4252,7 @@ } { \skip_set_eq:NN \l__xeCJK_ccglue_skip \l__xeCJK_verb_exspace_skip - \skip_set:Nn \l__xeCJK_ecglue_skip { .5 \l__xeCJK_verb_exspace_skip } + \skip_set:Nn \l__xeCJK_ecglue_skip { \l__xeCJK_verb_exspace_skip / 2 } \cs_set_eq:NN \CJKglue \__xeCJK_nobreak_ccglue: \cs_set_eq:NN \CJKecglue \__xeCJK_nobreak_ecglue: } @@ -4628,13 +4648,13 @@ \__xeCJK_math_robust:N \endmath } \__xeCJK_math_robust:N \ensuremath -\@ifl@t@r \fmtversion { 2020/10/01 } +\ctex_if_format_at_least:nTF { 2020/10/01 } { \cs_set_eq:NN \xeCJK@family \xeCJK_switch_family:x - \AddToHook { rmfamily } { \xeCJK@family { \CJKrmdefault } } - \AddToHook { sffamily } { \xeCJK@family { \CJKsfdefault } } - \AddToHook { ttfamily } { \xeCJK@family { \CJKttdefault } } - \AddToHook { normalfont } { \xeCJK@family { \CJKfamilydefault } } + \ctex_gadd_ltxhook:nn { rmfamily } { \xeCJK@family { \CJKrmdefault } } + \ctex_gadd_ltxhook:nn { sffamily } { \xeCJK@family { \CJKsfdefault } } + \ctex_gadd_ltxhook:nn { ttfamily } { \xeCJK@family { \CJKttdefault } } + \ctex_gadd_ltxhook:nn { normalfont } { \xeCJK@family { \CJKfamilydefault } } } { \cs_if_exist:NTF \@rmfamilyhook |