summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx')
-rw-r--r--Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx143
1 files changed, 85 insertions, 58 deletions
diff --git a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx
index d27a4ba9a59..cd087872540 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 <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
@@ -92,8 +92,8 @@ Copyright and Licence
\preamble
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
@@ -194,7 +194,7 @@ Copyright and Licence
%<*package|config|fntef|listings|xunicode|xunextra>
%<!(config|xunextra)>\NeedsTeXFormat{LaTeX2e}
%<!(config|xunextra)>\RequirePackage{expl3}
-%<+!driver>\GetIdInfo$Id: xeCJK.dtx d45555d 2021-12-12 18:20:36 +0800 Qing Lee <sobenlee@gmail.com> $
+%<+!driver>\GetIdInfo$Id: xeCJK.dtx de49417 2022-06-04 19:40:54 +0800 Qing Lee <sobenlee@gmail.com> $
%<package> {Typesetting CJK scripts with XeLaTeX}
%<config> {Configuration file for xeCJK package}
%<fntef> {xeCJK font effect}
@@ -207,7 +207,7 @@ Copyright and Licence
%<listings>\ProvidesExplPackage{xeCJK-listings}
%<xunicode>\ProvidesExplPackage{xunicode-addon}
%<xunextra>\ProvidesExplFile{xunicode-extra.def}
-%<!driver> {\ExplFileDate}{3.8.8}{\ExplFileDescription}
+%<!driver> {\ExplFileDate}{3.8.9}{\ExplFileDescription}
%</package|config|fntef|listings|xunicode|xunextra>
%<*driver>
\documentclass{ctxdoc}
@@ -287,7 +287,7 @@ Copyright and Licence
% \changes{v3.8.0}{2020/02/09}{清理过时的兼容性补丁代码。}
% \changes{v3.8.3}{2020/04/07}{删除 \texttt{\_nopar}。}
%
-% \CheckSum{10934}
+% \CheckSum{10962}
% \GetFileId{xeCJK.sty}
%
% \title{\bfseries\pkg{xeCJK} 宏包}
@@ -380,11 +380,10 @@ Copyright and Licence
% \end{ctexexam}
% \end{function}
%
-% 有些选项或命令后面带有 \exptarget\expstar{} 号,这表示这
-% 个选项或命令只能在导言区中使用,而 \rexptarget\rexpstar{}
-% 号则表示这个选项或命令只能在导言区使用,并且只影响随后定义的 CJK 字体。其余不带特殊标记的
-% 选项或命令,如果没有特别说明,可以在导言区或正文中使用。%
-% 使用粗体来表示 \pkg{xeCJK} 的默认设置。
+% 带有 \exptarget\expstar{} 或者 \rexptarget\rexpstar{} 标记的选项或命令
+% 只能在导言区中使用,其中 \rexptarget\rexpstar{} 还表示这个选项或命令只
+% 影响随后定义的 CJK 字体。其余不带特殊标记的选项或命令,如果没有特别说明,
+% 则可以在导言区或正文中使用。\textbf{粗体}表示 \pkg{xeCJK} 的默认设置。
%
% \begin{function}[EXP,added=2012-11-22]{LocalConfig}
% \begin{syntax}
@@ -3733,7 +3732,7 @@ Copyright and Licence
{
\@@_punct_if_middle:NTF \g_@@_last_punct_tl
{
- \@@_punct_bound_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
+ \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
\xeCJK_class_group_end:
\exp_after:wN \xeCJK_punct_node:N \g_@@_last_punct_tl
\xeCJK_no_break:
@@ -4007,7 +4006,7 @@ Copyright and Licence
{
\@@_punct_if_middle:NTF \g_@@_last_punct_tl
{
- \@@_punct_bound_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
+ \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
\xeCJK_no_break:
\@@_punct_glue:NN \c_@@_left_tl \g_@@_last_punct_tl
}
@@ -4026,7 +4025,7 @@ Copyright and Licence
{
\@@_punct_if_middle:NTF \g_@@_last_punct_tl
{
- \@@_punct_bound_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
+ \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
\xeCJK_class_group_end: \xeCJK_no_break:
\@@_punct_glue:NN \c_@@_left_tl \g_@@_last_punct_tl
}
@@ -4157,27 +4156,43 @@ Copyright and Licence
%
% \begin{macro}{\@@_bound_type_1_glue:Nn}
% \changes{v3.8.5}{2020/06/26}{增加盒子高度判断。}
+% \changes{v3.8.9}{2022/05/26}{增加位于段首的支架盒子判断。}
% $1$ 表示 hlist node,在这里用来判断是否位于段首。基于正常情况下,\TeX 会在段落开头插入宽度为
% \tn{parindent} 的水平盒子用于缩进。
% \begin{macrocode}
\cs_new_protected:cpn { @@_bound_type_ 1 _glue:Nn } #1
{
- \box_set_to_last:N \l_@@_tmp_box
+ \int_do_while:nNnn \tex_lastnodetype:D = \c_one_int
+ { \@@_bound_hbox_auxi: }
\int_compare:nNnTF \tex_lastnodetype:D = { -1 }
{
- \dim_compare:nNnTF
- { \box_wd:N \l_@@_tmp_box } = \tex_parindent:D
+ \dim_case:nnF { \box_wd:N \l_@@_indent_box }
{
- \dim_compare:nNnTF
- { \box_ht:N \l_@@_tmp_box } = \c_zero_dim
- { \use_i:nn }
- { \use:nn }
+ { \tex_parindent:D } { \@@_bound_hbox_auxii:nn }
+ { \c_zero_dim } { \use_i:nn }
}
{ \use:nn }
}
{ \use:nn }
- { \box_use_drop:N \l_@@_tmp_box }
+ { \hbox_unpack_drop:N \l_@@_indent_box }
}
+\cs_new_protected:Npn \@@_bound_hbox_auxi:
+ {
+ \box_set_to_last:N \l_@@_tmp_box
+ \hbox_set:Nn \l_@@_indent_box
+ {
+ \box_use:N \l_@@_tmp_box
+ \hbox_unpack:N \l_@@_indent_box
+ }
+ }
+\cs_new_protected:Npn \@@_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_@@_indent_box
% \end{macrocode}
% \end{macro}
%
@@ -4478,7 +4493,7 @@ Copyright and Licence
{
\CJKglue
\@@_punct_glue:NN \c_@@_right_tl #1
- \@@_punct_bound_rule:NN \c_@@_left_tl #1
+ \@@_punct_rule:NN \c_@@_left_tl #1
}
}
\cs_new_protected:Npn \@@_Default_and_FullRight_glue:N #1
@@ -4489,7 +4504,7 @@ Copyright and Licence
\@@_punct_if_middle:NT #1
{
\@@_punct_glue:NN \c_@@_right_tl #1
- \@@_punct_bound_rule:NN \c_@@_left_tl #1
+ \@@_punct_rule:NN \c_@@_left_tl #1
}
}
% \end{macrocode}
@@ -5494,10 +5509,11 @@ Copyright and Licence
{ \exp_last_unbraced:NNo \xeCJK_get_punct_bounds:NN }
\cs_new_protected:Npn \@@_save_punct_margin_plain:NN #1#2
{
- \@@_save_punct_dim:nNNn { rule } #1 #2 { \c_zero_dim }
\@@_save_punct_dim:nNNn { glue } #1 #2 { \c_zero_dim }
\@@_save_punct_dim:nNNn { offset } #1 #2 { \c_zero_dim }
\@@_save_punct_dim:nNNn { margin } #1 #2 { \c_zero_dim }
+ \@@_save_punct_dim:nNNn { rule } \c_@@_left_tl {#2} { \c_zero_dim }
+ \@@_save_punct_dim:nNNn { rule } \c_@@_right_tl {#2} { \c_zero_dim }
\@@_save_punct_dim:nNNn { bound } \c_@@_left_tl {#2} { \c_zero_dim }
\@@_save_punct_dim:nNNn { bound } \c_@@_right_tl {#2} { \c_zero_dim }
\@@_save_punct_skip:nNNn { glue } #1 #2 { \c_zero_skip }
@@ -5511,19 +5527,18 @@ Copyright and Licence
\group_end:
\dim_set:Nn \l_@@_bound_dim
{ \@@_use_punct_dim:nNN { bound } #1 #2 }
+ \tl_if_eq:NNTF #1 \c_@@_right_tl
+ { \tl_set_eq:NN \l_@@_reverse_tl \c_@@_left_tl }
+ { \tl_set_eq:NN \l_@@_reverse_tl \c_@@_right_tl }
\dim_set:Nn \l_@@_reverse_bound_dim
- {
- \tl_if_eq:NNTF #1 \c_@@_left_tl
- { \@@_use_punct_dim:nNN { bound } \c_@@_right_tl }
- { \@@_use_punct_dim:nNN { bound } \c_@@_left_tl }
- #2
- }
+ { \@@_use_punct_dim:nNN { bound } \l_@@_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
\@@_punct_if_long:NT #2
{ \@@_long_punct_kerning:N #2 }
}
+\tl_new:N \l_@@_reverse_tl
\dim_new:N \l_@@_bound_dim
\dim_new:N \l_@@_reverse_bound_dim
% \end{macrocode}
@@ -5680,10 +5695,8 @@ Copyright and Licence
\dim_compare:nNnTF \l_@@_middle_margin_width_dim < \c_max_dim
{ \l_@@_middle_margin_width_dim }
{
- \fp_use:N \l_@@_middle_margin_ratio_fp
- \tex_dimexpr:D
- ( \l_@@_bound_dim + \l_@@_reverse_bound_dim ) / 2
- \scan_stop:
+ \@@_dim_ratio:Nn \l_@@_middle_margin_ratio_fp
+ { ( \l_@@_bound_dim + \l_@@_reverse_bound_dim ) / 2 }
}
}
{
@@ -5695,6 +5708,16 @@ Copyright and Licence
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_dim_ratio:Nn}
+% \begin{macrocode}
+\cs_new:Npn \@@_dim_ratio:Nn #1#2
+ { \fp_to_dim:n { #1 \dim_to_fp:n {#2} } }
+\cs_generate_variant:Nn \@@_dim_ratio:Nn { c }
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{v3.8.9}{2022/05/26}{修正居中标点悬挂错误。}
+%
% \begin{macro}[int]{\xeCJK_punct_offset_process:NN}
% \begin{macrocode}
\cs_new_protected:Npn \xeCJK_punct_offset_process:NN #1#2
@@ -5744,6 +5767,8 @@ Copyright and Licence
{ \l_@@_tmp_dim }
\@@_save_punct_dim:nNNn { rule } #1 #2
{ \l_@@_tmp_dim - \l_@@_bound_dim }
+ \@@_save_punct_dim:nNNn { rule } \l_@@_reverse_tl #2
+ { \l_@@_tmp_dim - \l_@@_reverse_bound_dim }
\@@_save_punct_dim:nNNn { glue } #1 #2
{ \l_@@_margin_dim - \l_@@_tmp_dim }
\@@_save_punct_skip:nNNnnn { glue } #1 #2
@@ -5759,7 +5784,7 @@ Copyright and Licence
}
{
\@@_punct_if_middle:NTF #2
- { .5 \l_@@_margin_dim }
+ { \l_@@_margin_dim / 2 }
{ \l_@@_margin_dim - \l_@@_reverse_bound_dim }
}
}
@@ -5779,8 +5804,9 @@ Copyright and Licence
\fp_if_nan:nTF { \use:c { l_@@_#1_punct_ratio_fp } }
{ \c_max_dim }
{
- \fp_use:c { l_@@_#1_punct_ratio_fp }
- \tex_dimexpr:D \@@_use_punct_dim:nN { width } #2 \scan_stop:
+ \@@_dim_ratio:cn
+ { l_@@_#1_punct_ratio_fp }
+ { \@@_use_punct_dim:nN { width } #2 }
}
}
}
@@ -5794,8 +5820,9 @@ Copyright and Licence
\dim_compare:nNnTF { \use:c { l_@@_#1_margin_width_dim } } < \c_max_dim
{ \use:c { l_@@_#1_margin_width_dim } }
{
- \fp_use:c { l_@@_#1_margin_ratio_fp }
- \tex_dimexpr:D \l_@@_bound_dim \scan_stop:
+ \@@_dim_ratio:cn
+ { l_@@_#1_margin_ratio_fp }
+ { \l_@@_bound_dim }
}
\bool_if:NT \l_@@_add_min_bound_to_margin_bool
{ + \dim_min:nn \l_@@_bound_dim \l_@@_reverse_bound_dim }
@@ -5928,11 +5955,11 @@ Copyright and Licence
{
\@@_calc_kerning_margin:nNN
{
- \fp_use:N \l_@@_kerning_total_ratio_fp
- \tex_dimexpr:D
- \@@_use_punct_dim:nN { width } #1 +
- \@@_use_punct_dim:nN { width } #2
- \scan_stop:
+ \@@_dim_ratio:Nn \l_@@_kerning_total_ratio_fp
+ {
+ \@@_use_punct_dim:nN { width } #1 +
+ \@@_use_punct_dim:nN { width } #2
+ }
}
}
}
@@ -5952,9 +5979,9 @@ Copyright and Licence
{
\dim_compare:nNnTF \l_@@_kerning_margin_width_dim < \c_max_dim
{ \l_@@_kerning_margin_width_dim \use_none:n }
- { \fp_use:N \l_@@_kerning_margin_ratio_fp \use:n }
+ { \@@_dim_ratio:Nn \l_@@_kerning_margin_ratio_fp }
}
- { \fp_use:c { l_@@_#1_align_ratio_fp } \use:n }
+ { \@@_dim_ratio:cn { l_@@_#1_align_ratio_fp } }
{ \l_@@_margin_dim }
}
}
@@ -7886,7 +7913,7 @@ Copyright and Licence
}
{
\skip_set_eq:NN \l_@@_ccglue_skip \l_@@_verb_exspace_skip
- \skip_set:Nn \l_@@_ecglue_skip { .5 \l_@@_verb_exspace_skip }
+ \skip_set:Nn \l_@@_ecglue_skip { \l_@@_verb_exspace_skip / 2 }
\cs_set_eq:NN \CJKglue \@@_nobreak_ccglue:
\cs_set_eq:NN \CJKecglue \@@_nobreak_ecglue:
}
@@ -8505,13 +8532,13 @@ Copyright and Licence
% 使主要 |CJK| 字体族能随西文主要字体更新,之后的版本可以使用 \tn{@rmfamilyhook} 等新钩子处理。
% \LaTeXe\ 2020/10/01 提供了新的的 \pkg{NFSS} 钩子。
% \begin{macrocode}
-\@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
@@ -9668,7 +9695,7 @@ Copyright and Licence
\@@_punct_if_middle:NT #1
{
\@@_punct_glue:NN \c_@@_right_tl #1
- \@@_punct_bound_rule:NN \c_@@_left_tl #1
+ \@@_punct_rule:NN \c_@@_left_tl #1
}
\UL@start
}
@@ -9694,7 +9721,7 @@ Copyright and Licence
{
\@@_ulem_punct_ccglue:
\@@_punct_glue:NN \c_@@_right_tl #1
- \@@_punct_bound_rule:NN \c_@@_left_tl #1
+ \@@_punct_rule:NN \c_@@_left_tl #1
}
\UL@start
\@@_ulem_class_group_begin:
@@ -9714,7 +9741,7 @@ Copyright and Licence
\@@_punct_if_middle:NTF \g_@@_last_punct_tl
{
\xeCJK_get_punct_bounds:No \c_@@_left_tl \g_@@_last_punct_tl
- \@@_punct_bound_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
+ \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
\xeCJK_class_group_end: \UL@stop \xeCJK_no_break:
\@@_punct_glue:NN \c_@@_left_tl \g_@@_last_punct_tl
}
@@ -9737,7 +9764,7 @@ Copyright and Licence
\@@_punct_if_middle:NTF \g_@@_last_punct_tl
{
\xeCJK_get_punct_bounds:No \c_@@_left_tl \g_@@_last_punct_tl
- \@@_punct_bound_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
+ \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
\xeCJK_class_group_end: \UL@stop \xeCJK_no_break:
\@@_punct_glue:NN \c_@@_left_tl \g_@@_last_punct_tl
}