| 1 |
%% |
| 2 |
%% This is file `xeCJK.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% xeCJK.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% Copyright (C) 2007--2010 by Wenchang Sun <[email protected]> |
| 10 |
%% Copyright (C) 2009--2022 by Leo Liu <[email protected]> |
| 11 |
%% Copyright (C) 2012--2022 by Qing Lee <[email protected]> |
| 12 |
%% ---------------------------------------------------------------------- |
| 13 |
%% |
| 14 |
%% This work may be distributed and/or modified under the |
| 15 |
%% conditions of the LaTeX Project Public License, either |
| 16 |
%% version 1.3c of this license or (at your option) any later |
| 17 |
%% version. This version of this license is in |
| 18 |
%% http://www.latex-project.org/lppl/lppl-1-3c.txt |
| 19 |
%% and the latest version of this license is in |
| 20 |
%% http://www.latex-project.org/lppl.txt |
| 21 |
%% and version 1.3 or later is part of all distributions of |
| 22 |
%% LaTeX version 2005/12/01 or later. |
| 23 |
%% |
| 24 |
%% This work has the LPPL maintenance status "maintained". |
| 25 |
%% |
| 26 |
%% The Current Maintainers of this work are Leo Liu and Qing Lee. |
| 27 |
%% |
| 28 |
%% ---------------------------------------------------------------------- |
| 29 |
%% |
| 30 |
\NeedsTeXFormat{LaTeX2e} |
| 31 |
\RequirePackage{expl3} |
| 32 |
\GetIdInfo$Id: xeCJK.dtx c4ccfae 2022-08-05 21:02:32 +0800 Qing Lee <[email protected]> $ |
| 33 |
{Typesetting CJK scripts with XeLaTeX} |
| 34 |
\ProvidesExplPackage{\ExplFileName} |
| 35 |
{\ExplFileDate}{3.9.1}{\ExplFileDescription} |
| 36 |
\msg_new:nnn { xeCJK } { Require-XeTeX } |
| 37 |
{ |
| 38 |
The~xeCJK~package~requires~XeTeX~to~function.\\\\ |
| 39 |
You~must~change~your~typesetting~engine~to~"xelatex" \\ |
| 40 |
instead~of~plain~"latex"~or~"pdflatex"~or~"lualatex".\\ |
| 41 |
Loading~xeCJK~will~abort! |
| 42 |
} |
| 43 |
\sys_if_engine_xetex:F { \msg_critical:nn { xeCJK } { Require-XeTeX } } |
| 44 |
\msg_new:nnn { xeCJK } { l3-too-old } |
| 45 |
{ |
| 46 |
Support~package~`#1'~too~old. \\\\ |
| 47 |
Please~update~an~up~to~date~version~of~the~bundles\\\\ |
| 48 |
`l3kernel'~and~`l3packages'\\\\ |
| 49 |
using~your~TeX~package~manager~or~from~CTAN.\\ |
| 50 |
\str_if_eq:nnT {#1} { expl3 } { Loading~xeCJK~will~abort! } |
| 51 |
} |
| 52 |
\@ifpackagelater { expl3 } { 2020/02/08 } { } |
| 53 |
{ \msg_critical:nnn { xeCJK } { l3-too-old } { expl3 } } |
| 54 |
\RequirePackage { ctexhook } |
| 55 |
\prg_new_conditional:Npnn \xeCJK_if_package_loaded:n #1 { p , T , F , TF } |
| 56 |
{ |
| 57 |
\tl_if_exist:cTF { ver@ #1 . \c__xeCJK_package_ext_tl } |
| 58 |
{ \prg_return_true: } { \prg_return_false: } |
| 59 |
} |
| 60 |
\tl_const:Nx \c__xeCJK_package_ext_tl { \@pkgextension } |
| 61 |
\msg_new:nnn { xeCJK } { after-package } |
| 62 |
{ |
| 63 |
The~`#1'~package~and~xeCJK~are~incompatible.\\\\ |
| 64 |
Please~load~it~after~xeCJK. |
| 65 |
} |
| 66 |
\clist_map_inline:nn { CJKnumb } |
| 67 |
{ |
| 68 |
\xeCJK_if_package_loaded:nT {#1} |
| 69 |
{ \msg_error:nnn { xeCJK } { after-package } {#1} } |
| 70 |
} |
| 71 |
\clist_map_inline:nn |
| 72 |
{ CJKulem , CJKvert , CJKpunct , CJKutf8 , CJK } |
| 73 |
{ \ctex_disable_package:n {#1} } |
| 74 |
\ctex_if_format_at_least:nTF { 2020/10/01 } |
| 75 |
{ \ctex_replace_package:nn { CJKfntef } { xeCJKfntef } } |
| 76 |
{ \ctex_disable_package:n { CJKfntef } } |
| 77 |
\cs_if_exist:NF \NewDocumentCommand |
| 78 |
{ \RequirePackage { xparse } } |
| 79 |
\RequirePackage { xtemplate } |
| 80 |
\tl_new:N \l__xeCJK_tmp_tl |
| 81 |
\int_new:N \l__xeCJK_tmp_int |
| 82 |
\box_new:N \l__xeCJK_tmp_box |
| 83 |
\dim_new:N \l__xeCJK_tmp_dim |
| 84 |
\bool_new:N \l__xeCJK_tmp_bool |
| 85 |
\skip_new:N \l__xeCJK_tmp_skip |
| 86 |
\clist_new:N \l__xeCJK_tmp_clist |
| 87 |
\cs_new_protected:Npn \__xeCJK_msg_new:nn { \msg_new:nnn { xeCJK } } |
| 88 |
\cs_new_protected:Npn \__xeCJK_msg_new:nnn { \msg_new:nnnn { xeCJK } } |
| 89 |
\cs_new_protected:Npn \__xeCJK_error:n { \msg_error:nn { xeCJK } } |
| 90 |
\cs_new_protected:Npn \__xeCJK_error:nx { \msg_error:nnx { xeCJK } } |
| 91 |
\cs_new_protected:Npn \__xeCJK_warning:n { \msg_warning:nn { xeCJK } } |
| 92 |
\cs_new_protected:Npn \__xeCJK_warning:nx { \msg_warning:nnx { xeCJK } } |
| 93 |
\cs_new_protected:Npn \__xeCJK_warning:nxx { \msg_warning:nnxx { xeCJK } } |
| 94 |
\cs_new_protected:Npn \__xeCJK_warning:nxxx { \msg_warning:nnxxx { xeCJK } } |
| 95 |
\cs_new_protected:Npn \__xeCJK_info:nxx { \msg_info:nnxx { xeCJK } } |
| 96 |
\cs_new_protected:Npn \xeCJK_allow_break: |
| 97 |
{ \tex_penalty:D \c_zero_int } |
| 98 |
\cs_new_protected:Npn \xeCJK_no_break: |
| 99 |
{ \tex_penalty:D \c__xeCJK_nobreak_penalty_int } |
| 100 |
\int_const:Nn \c__xeCJK_nobreak_penalty_int { 10 000 } |
| 101 |
\AtBeginDocument { \xeCJK@document@hook } |
| 102 |
\ctex_at_end_preamble:n { \xeCJK@document@left@hook } |
| 103 |
\ctex_after_end_preamble:n { \xeCJK@document@right@hook } |
| 104 |
\cs_new_protected:Npn \xeCJK@document@hook |
| 105 |
{ \tl_use:N \g__xeCJK_after_preamble_hook_tl } |
| 106 |
\cs_new_protected:Npn \xeCJK@document@left@hook |
| 107 |
{ \tl_use:N \g__xeCJK_at_end_preamble_hook_tl } |
| 108 |
\cs_new_protected:Npn \xeCJK@document@right@hook |
| 109 |
{ \tl_use:N \g__xeCJK_after_end_preamble_hook_tl } |
| 110 |
\cs_new_protected:Npn \__xeCJK_at_end_preamble:n |
| 111 |
{ \tl_gput_right:Nn \g__xeCJK_at_end_preamble_hook_tl } |
| 112 |
\cs_new_protected:Npn \__xeCJK_after_preamble:n |
| 113 |
{ \tl_gput_right:Nn \g__xeCJK_after_preamble_hook_tl } |
| 114 |
\cs_new_protected:Npn \__xeCJK_after_end_preamble:n |
| 115 |
{ \tl_gput_right:Nn \g__xeCJK_after_end_preamble_hook_tl } |
| 116 |
\cs_new_protected:Npn \__xeCJK_package_hook:nn |
| 117 |
{ \ctex_at_end_package:nn } |
| 118 |
\tl_new:N \g__xeCJK_at_end_preamble_hook_tl |
| 119 |
\tl_new:N \g__xeCJK_after_preamble_hook_tl |
| 120 |
\tl_new:N \g__xeCJK_after_end_preamble_hook_tl |
| 121 |
\__xeCJK_after_preamble:n |
| 122 |
{ \tl_put_right:Nn \@begindvi { \xeCJK@first@begindvi } } |
| 123 |
\cs_new_protected:Npn \xeCJK@first@begindvi |
| 124 |
{ |
| 125 |
\xeCJKShipoutHook |
| 126 |
\cs_if_exist:NTF \@begindvi |
| 127 |
{ \tl_gput_right:Nn } |
| 128 |
{ \tl_const:Nn } |
| 129 |
\@begindvi { \xeCJKShipoutHook } |
| 130 |
} |
| 131 |
\NewDocumentCommand \xeCJKShipoutHook { } |
| 132 |
{ |
| 133 |
\bool_if:NF \l__xeCJK_shipout_hook_bool |
| 134 |
{ |
| 135 |
\bool_set_true:N \l__xeCJK_shipout_hook_bool |
| 136 |
\tl_use:N \l__xeCJK_shipout_hook_tl |
| 137 |
} |
| 138 |
} |
| 139 |
\cs_new_protected:Npn \xeCJK_add_to_shipout:n |
| 140 |
{ \tl_put_right:Nn \l__xeCJK_shipout_hook_tl } |
| 141 |
\tl_new:N \l__xeCJK_shipout_hook_tl |
| 142 |
\bool_new:N \l__xeCJK_shipout_hook_bool |
| 143 |
\cs_new:Npn \xeCJK_tl_remove_outer_braces:n #1 |
| 144 |
{ |
| 145 |
\exp_last_unbraced:Ne |
| 146 |
\__xeCJK_tl_remove_outer_braces:w { \tl_trim_spaces:n {#1} } \s_stop |
| 147 |
} |
| 148 |
\cs_new:Npn \__xeCJK_tl_remove_outer_braces:w #1 \s_stop |
| 149 |
{ |
| 150 |
\tl_if_single:nTF {#1} |
| 151 |
{ |
| 152 |
\tl_if_head_is_N_type:nTF {#1} |
| 153 |
{ \tl_trim_spaces:n } |
| 154 |
{ \xeCJK_tl_remove_outer_braces:n } |
| 155 |
} |
| 156 |
{ \tl_trim_spaces:n } |
| 157 |
{#1} |
| 158 |
} |
| 159 |
\cs_new_protected:Npn \xeCJK_cs_clear:N #1 |
| 160 |
{ \cs_set_eq:NN #1 \prg_do_nothing: } |
| 161 |
\cs_new_protected:Npn \xeCJK_cs_gclear:N #1 |
| 162 |
{ \cs_gset_eq:NN #1 \prg_do_nothing: } |
| 163 |
\cs_new_protected:Npn \xeCJK_swap_cs:NN #1#2 |
| 164 |
{ |
| 165 |
\cs_set_eq:NN \__xeCJK_swap_cs_aux:w #1 |
| 166 |
\cs_set_eq:NN #1 #2 |
| 167 |
\cs_set_eq:NN #2 \__xeCJK_swap_cs_aux:w |
| 168 |
\cs_undefine:N \__xeCJK_swap_cs_aux:w |
| 169 |
} |
| 170 |
\cs_new_protected:Npn \xeCJK_font_gset_to_current:N |
| 171 |
{ \exp_after:wN \__xeCJK_font_gset_to_current_aux:NN \tex_the:D \tex_font:D } |
| 172 |
\cs_new_protected:Npn \__xeCJK_font_gset_to_current_aux:NN #1#2 |
| 173 |
{ \cs_if_eq:NNF #1 \tex_nullfont:D { \cs_gset_eq:NN #2#1 } } |
| 174 |
\prg_new_conditional:Npnn \xeCJK_glyph_if_exist:N #1 { p , T , F , TF } |
| 175 |
{ |
| 176 |
\tex_iffontchar:D \tex_font:D `#1 \exp_stop_f: |
| 177 |
\prg_return_true: \else: \prg_return_false: \fi: |
| 178 |
} |
| 179 |
\tl_const:Nn \c_xeCJK_space_skip_tl |
| 180 |
{ |
| 181 |
\int_compare:nNnTF \g__xeCJK_space_factor_int = { 1000 } |
| 182 |
{ |
| 183 |
\skip_if_eq:nnTF \tex_spaceskip:D \c_zero_skip |
| 184 |
{ |
| 185 |
\tex_fontdimen:D 2 ~ \tex_font:D |
| 186 |
plus \tex_fontdimen:D 3 ~ \tex_font:D |
| 187 |
minus \tex_fontdimen:D 4 ~ \tex_font:D |
| 188 |
} |
| 189 |
{ \tex_spaceskip:D } |
| 190 |
} |
| 191 |
{ |
| 192 |
\skip_if_eq:nnTF \tex_spaceskip:D \c_zero_skip |
| 193 |
{ |
| 194 |
\int_compare:nNnTF \g__xeCJK_space_factor_int < { 2000 } |
| 195 |
{ |
| 196 |
\__xeCJK_space_skip_scale:nnn |
| 197 |
{ \tex_fontdimen:D 2 ~ \tex_font:D } |
| 198 |
} |
| 199 |
{ |
| 200 |
\skip_if_eq:nnTF \tex_xspaceskip:D \c_zero_skip |
| 201 |
{ |
| 202 |
\__xeCJK_space_skip_scale:nnn |
| 203 |
{ |
| 204 |
\tex_fontdimen:D 2 ~ \tex_font:D + |
| 205 |
\tex_fontdimen:D 7 ~ \tex_font:D |
| 206 |
} |
| 207 |
} |
| 208 |
{ \tex_xspaceskip:D \use_none:nn } |
| 209 |
} |
| 210 |
{ \tex_fontdimen:D 3 ~ \tex_font:D } |
| 211 |
{ \tex_fontdimen:D 4 ~ \tex_font:D } |
| 212 |
} |
| 213 |
{ |
| 214 |
\int_compare:nNnTF \g__xeCJK_space_factor_int < { 2000 } |
| 215 |
{ \__xeCJK_space_skip_scale:nnn { \tex_spaceskip:D } } |
| 216 |
{ |
| 217 |
\skip_if_eq:nnTF \tex_xspaceskip:D \c_zero_skip |
| 218 |
{ |
| 219 |
\__xeCJK_space_skip_scale:nnn |
| 220 |
{ |
| 221 |
\tex_spaceskip:D + |
| 222 |
\tex_fontdimen:D 7 ~ \tex_font:D |
| 223 |
} |
| 224 |
} |
| 225 |
{ \tex_xspaceskip:D \use_none:nn } |
| 226 |
} |
| 227 |
{ \tex_gluestretch:D \tex_spaceskip:D } |
| 228 |
{ \tex_glueshrink:D \tex_spaceskip:D } |
| 229 |
} |
| 230 |
} |
| 231 |
} |
| 232 |
\cs_new:Npn \__xeCJK_space_skip_scale:nnn #1#2#3 |
| 233 |
{ |
| 234 |
\dim_eval:n {#1} |
| 235 |
plus \fp_eval:n { \g__xeCJK_space_factor_int / 1000 } #2 |
| 236 |
minus |
| 237 |
\int_div_truncate:nn |
| 238 |
{ 1000 * \int_value:w #3 } { \g__xeCJK_space_factor_int } sp |
| 239 |
} |
| 240 |
\int_new:N \g__xeCJK_space_factor_int |
| 241 |
\cs_new_protected:Npn \xeCJK_reset_space_factor: |
| 242 |
{ \int_gset:Nn \g__xeCJK_space_factor_int { 1000 } } |
| 243 |
\xeCJK_reset_space_factor: |
| 244 |
\cs_new_protected:Npn \xeCJK_glue_to_skip:nN #1#2 |
| 245 |
{ |
| 246 |
\group_begin: |
| 247 |
\hbox_set:Nw \l__xeCJK_tmp_box #1 \scan_stop: |
| 248 |
\__xeCJK_if_last_glue:TF |
| 249 |
{ |
| 250 |
\exp_args:NNNo \hbox_set_end: |
| 251 |
\skip_set:Nn #2 { \skip_use:N \tex_lastskip:D } |
| 252 |
} |
| 253 |
{ |
| 254 |
\exp_args:NNNo \hbox_set_end: |
| 255 |
\skip_set:Nn #2 { \dim_use:N \box_wd:N \l__xeCJK_tmp_box } |
| 256 |
} |
| 257 |
\exp_args:NNNo \group_end: |
| 258 |
\skip_set:Nn #2 { \skip_use:N #2 } |
| 259 |
} |
| 260 |
\cs_new_protected:Npn \xeCJK_int_until_do:nn #1#2 |
| 261 |
{ |
| 262 |
\__xeCJK_int_until_do:wn \use_none:n |
| 263 |
{ \reverse_if:N \if_int_compare:w #1#2 } |
| 264 |
} |
| 265 |
\cs_new_protected:Npn \__xeCJK_int_until_do:wn \use_none:n #1 |
| 266 |
{ #1 \exp_after:wN \__xeCJK_int_until_do:wn \fi: \use_none:n {#1} } |
| 267 |
\int_new:N \l__xeCJK_begin_int |
| 268 |
\int_new:N \l__xeCJK_end_int |
| 269 |
\cs_new_protected:Npn \xeCJK_peek_catcode_ignore_spaces:NTF #1#2#3 |
| 270 |
{ |
| 271 |
\cs_set_eq:NN \l__xeCJK_peek_search_token #1 \scan_stop: |
| 272 |
\cs_set_protected:Npx \__xeCJK_peek_catcode_true:w |
| 273 |
{ \exp_not:N \group_align_safe_end: \exp_not:n {#2} } |
| 274 |
\cs_set_protected:Npx \__xeCJK_peek_catcode_false:w |
| 275 |
{ \exp_not:N \group_align_safe_end: \exp_not:n {#3} } |
| 276 |
\bool_set_false:N \l__xeCJK_peek_ignore_spaces_bool |
| 277 |
\group_align_safe_begin: |
| 278 |
\peek_after:Nw \__xeCJK_peek_catcode_ignore_spaces_branches:w |
| 279 |
} |
| 280 |
\cs_new_protected:Npn \__xeCJK_peek_catcode_ignore_spaces_branches:w |
| 281 |
{ |
| 282 |
\if_meaning:w \l_peek_token \c_space_token |
| 283 |
\bool_set_true:N \l__xeCJK_peek_ignore_spaces_bool |
| 284 |
\exp_after:wN \peek_after:Nw |
| 285 |
\exp_after:wN \__xeCJK_peek_catcode_ignore_spaces_branches:w |
| 286 |
\tex_romannumeral:D 0 |
| 287 |
\else: |
| 288 |
\if_catcode:w |
| 289 |
\exp_not:N \l_peek_token \exp_not:N \l__xeCJK_peek_search_token |
| 290 |
\exp_after:wN \exp_after:wN |
| 291 |
\exp_after:wN \__xeCJK_peek_catcode_true:w |
| 292 |
\else: |
| 293 |
\exp_after:wN \exp_after:wN |
| 294 |
\exp_after:wN \__xeCJK_peek_catcode_false:w |
| 295 |
\fi: |
| 296 |
\fi: |
| 297 |
} |
| 298 |
\cs_new_eq:NN \l__xeCJK_peek_search_token ? |
| 299 |
\cs_new_eq:NN \__xeCJK_peek_catcode_true:w \prg_do_nothing: |
| 300 |
\cs_new_eq:NN \__xeCJK_peek_catcode_false:w \prg_do_nothing: |
| 301 |
\bool_new:N \l__xeCJK_peek_ignore_spaces_bool |
| 302 |
\cs_new:Npn \xeCJK_token_value_class:N #1 |
| 303 |
{ \tex_XeTeXcharclass:D \xeCJK_token_value_charcode:N #1 } |
| 304 |
\cs_new:Npn \xeCJK_token_value_charcode:N #1 |
| 305 |
{ \exp_after:wN \__xeCJK_get_charcode:w \token_to_meaning:N #1 \q_stop } |
| 306 |
\group_begin: |
| 307 |
\cs_set:Npn \__xeCJK_tmp:w #1 ~ #2 ~ #3#4#5 \q_stop |
| 308 |
{ |
| 309 |
\tl_if_empty:nTF { #4#5 } |
| 310 |
{ |
| 311 |
\cs_new:Npn \__xeCJK_get_charcode:w ##1 ~ ##2 ~ ##3 \q_stop |
| 312 |
{ \int_eval:n { `##3 } } |
| 313 |
} |
| 314 |
{ |
| 315 |
\tl_if_empty:nTF {#5} |
| 316 |
{ |
| 317 |
\cs_new:Npn \__xeCJK_get_charcode:w ##1 ~ ##2 ~ ##3##4 \q_stop |
| 318 |
{ |
| 319 |
\int_eval:n |
| 320 |
{ |
| 321 |
\tl_if_empty:nTF { ##4 } |
| 322 |
{ `##3 } |
| 323 |
{ ( `##3 - "D800 ) * "400 + ( `##4 - "DC00 ) + "10000 } |
| 324 |
} |
| 325 |
} |
| 326 |
} |
| 327 |
{ |
| 328 |
\cs_new:Npn \__xeCJK_get_charcode:w ##1 ~ ##2 ~ ##3##4 \q_stop |
| 329 |
{ \int_eval:n { \tl_if_empty:nTF { ##4 } { `##3 } { "20000 } } } |
| 330 |
} |
| 331 |
} |
| 332 |
} |
| 333 |
\exp_after:wN \__xeCJK_tmp:w \token_to_meaning:N ^^^^^20000 { } \q_stop |
| 334 |
\group_end: |
| 335 |
\prg_new_conditional:Npnn \xeCJK_if_CJK_class:N #1 { p , T , F , TF } |
| 336 |
{ |
| 337 |
\if_cs_exist:w |
| 338 |
\__xeCJK_CJK_class_tl:n { \xeCJK_token_value_class:N #1 } |
| 339 |
\cs_end: |
| 340 |
\prg_return_true: \else: \prg_return_false: \fi: |
| 341 |
} |
| 342 |
\cs_new:Npn \__xeCJK_CJK_class_tl:n #1 |
| 343 |
{ c__xeCJK_CJK_class_ \int_eval:n {#1} _tl } |
| 344 |
\prg_new_conditional:Npnn \xeCJK_if_same_class:NN #1#2 { p , T , F , TF } |
| 345 |
{ |
| 346 |
\if_int_compare:w \xeCJK_token_value_class:N #1 = |
| 347 |
\xeCJK_token_value_class:N #2 \exp_stop_f: |
| 348 |
\prg_return_true: \else: \prg_return_false: \fi: |
| 349 |
} |
| 350 |
\cs_new_protected:Npn \xeCJK_make_boundary: |
| 351 |
{ \bool_if:NT \l__xeCJK_CJK_group_bool { \scan_stop: } } |
| 352 |
\keys_define:nn { xeCJK / options } |
| 353 |
{ |
| 354 |
xeCJKactive .choice: , |
| 355 |
xeCJKactive / true .code:n = { \makexeCJKactive } , |
| 356 |
xeCJKactive / false .code:n = { \makexeCJKinactive } , |
| 357 |
xeCJKactive .default:n = { true } |
| 358 |
} |
| 359 |
\NewDocumentCommand \makexeCJKactive { } |
| 360 |
{ \tex_XeTeXinterchartokenstate:D = \c_one_int } |
| 361 |
\NewDocumentCommand \makexeCJKinactive { } |
| 362 |
{ \tex_XeTeXinterchartokenstate:D = \c_zero_int } |
| 363 |
\char_set_catcode_ignore:n { "FEFF } |
| 364 |
\seq_new:N \g__xeCJK_class_seq |
| 365 |
\seq_new:N \g__xeCJK_new_class_seq |
| 366 |
\cs_new_protected:Npn \xeCJK_new_class:n #1 |
| 367 |
{ |
| 368 |
\int_if_exist:cTF { \__xeCJK_class_csname:n {#1} } |
| 369 |
{ \__xeCJK_error:nx { class-already-defined } {#1} } |
| 370 |
{ |
| 371 |
\exp_args:Nc \newXeTeXintercharclass |
| 372 |
{ \__xeCJK_class_csname:n {#1} } |
| 373 |
\clist_new:c { g__xeCJK_#1_range_clist } |
| 374 |
\seq_gput_right:Nn \g__xeCJK_class_seq {#1} |
| 375 |
\seq_gput_right:Nv \g__xeCJK_new_class_seq |
| 376 |
{ \__xeCJK_class_csname:n {#1} } |
| 377 |
} |
| 378 |
} |
| 379 |
\cs_new_protected:Npn \xeCJK_save_class:nn #1#2 |
| 380 |
{ |
| 381 |
\int_if_exist:cTF { \__xeCJK_class_csname:n {#1} } |
| 382 |
{ \__xeCJK_error:nx { class-already-defined } {#1} } |
| 383 |
{ |
| 384 |
\int_const:cn { \__xeCJK_class_csname:n {#1} } {#2} |
| 385 |
\clist_new:c { g__xeCJK_#1_range_clist } |
| 386 |
\seq_gput_right:Nn \g__xeCJK_class_seq {#1} |
| 387 |
} |
| 388 |
} |
| 389 |
\cs_new:Npn \__xeCJK_class_csname:n #1 { c__xeCJK_#1_class_int } |
| 390 |
\cs_new_eq:cN { \__xeCJK_class_csname:n { Others } } \l__xeCJK_tmp_int |
| 391 |
\__xeCJK_msg_new:nn { class-already-defined } |
| 392 |
{ |
| 393 |
XeTeX~character~class~`#1'~has~been~already~defined.\\\\ |
| 394 |
Please~take~another~name. \\ |
| 395 |
} |
| 396 |
\xeCJK_save_class:nn { Default } { 0 } |
| 397 |
\str_const:Nx \c__xeCJK_xetex_version_str |
| 398 |
{ \int_use:N \tex_XeTeXversion:D \tex_XeTeXrevision:D } |
| 399 |
\fp_compare:nNnTF { \c__xeCJK_xetex_version_str } > { 0.99993 } |
| 400 |
{ \xeCJK_save_class:nn { Boundary } { 4095 } } |
| 401 |
{ \xeCJK_save_class:nn { Boundary } { 255 } } |
| 402 |
\int_compare:nNnTF { \tex_XeTeXcharclass:D "4E00 } = \c_one_int |
| 403 |
{ |
| 404 |
\xeCJK_save_class:nn { CJK } { 1 } |
| 405 |
\xeCJK_save_class:nn { FullLeft } { 2 } |
| 406 |
\xeCJK_save_class:nn { FullRight } { 3 } |
| 407 |
\int_const:Nn \c__xeCJK_class_begin_int { 3 } |
| 408 |
} |
| 409 |
{ |
| 410 |
\xeCJK_new_class:n { CJK } |
| 411 |
\xeCJK_new_class:n { FullLeft } |
| 412 |
\xeCJK_new_class:n { FullRight } |
| 413 |
\int_const:Nn \c__xeCJK_class_begin_int { 0 } |
| 414 |
} |
| 415 |
\xeCJK_new_class:n { HalfLeft } |
| 416 |
\xeCJK_new_class:n { HalfRight } |
| 417 |
\xeCJK_new_class:n { NormalSpace } |
| 418 |
\xeCJK_new_class:n { CM } |
| 419 |
\xeCJK_new_class:n { HangulJamo } |
| 420 |
\clist_const:Nn \c__xeCJK_HalfLeft_chars_clist |
| 421 |
{ "28 , "5B , "60 , "7B , "2329 } |
| 422 |
\clist_const:Nn \c__xeCJK_HalfRight_chars_clist |
| 423 |
{ "21 , "22 , "25 , "27 , "29 , "2C , "2E , "3A , "3B , "3F , "5D , "7D , "232A } |
| 424 |
\clist_const:Nn \c__xeCJK_NormalSpace_chars_clist { "2D , "2F , "5C } |
| 425 |
\clist_const:Nn \c__xeCJK_OP_chars_clist |
| 426 |
{ |
| 427 |
"2018 , "201C , |
| 428 |
"3008 , "300A , "300C , "300E , "3010 , "3014 , "3016 , "3018 , "301A , "301D , |
| 429 |
"FE17 , "FE35 , "FE37 , "FE39 , "FE3B , "FE3D , "FE3F , "FE41 , "FE43 , "FE47 , |
| 430 |
"FE59 , "FE5B , "FE5D , "FF08 , "FF3B , "FF5B , "FF5F , "FF62 |
| 431 |
} |
| 432 |
\clist_const:Nn \c__xeCJK_PR_chars_clist |
| 433 |
{ "FE69 , "FF04 , "FFE1 , "FFE5 , "FFE6 } |
| 434 |
\clist_new:N \c__xeCJK_FullLeft_chars_clist |
| 435 |
\clist_gconcat:NNN \c__xeCJK_FullLeft_chars_clist |
| 436 |
\c__xeCJK_OP_chars_clist |
| 437 |
\c__xeCJK_PR_chars_clist |
| 438 |
\clist_const:Nn \c__xeCJK_CL_chars_clist |
| 439 |
{ |
| 440 |
"00B7 , "2019 , "201D , "2013 , "2014 , "2025 , "2026 , "2027 , "2E3A , |
| 441 |
"3001 , "3002 , "3009 , "300B , "300D , "300F , "3011 , "3015 , "3017 , "3019 , |
| 442 |
"301B , "301E , "301F , "FE11 , "FE12 , "FE18 , "FE36 , "FE38 , "FE3A , "FE3C , |
| 443 |
"FE3E , "FE40 , "FE42 , "FE44 , "FE48 , "FE50 , "FE52 , "FE5A , "FE5C , "FE5E , |
| 444 |
"FF09 , "FF0C , "FF0E , "FF3D , "FF5D , "FF60 , "FF61 , "FF63 , "FF64 |
| 445 |
} |
| 446 |
\clist_const:Nn \c__xeCJK_hyphens_chars_clist |
| 447 |
{ "301C , "30A0 , "FF5E } |
| 448 |
\clist_const:Nn \c__xeCJK_iteration_marks_chars_clist |
| 449 |
{ "3005 , "303B , "309D , "309E , "30FD , "30FE } |
| 450 |
\clist_const:Nn \c__xeCJK_NS_chars_clist |
| 451 |
{ "30FB , "FE54 , "FE55 , "FF1A , "FF1B , "FF65 , "16FE0 } |
| 452 |
\AtEndOfPackage |
| 453 |
{ |
| 454 |
\cs_set:Npn \__xeCJK_tmp:w #1 |
| 455 |
{ \char_generate:nn {#1} { 12 } } |
| 456 |
\__xeCJK_add_special_punct:nn { middle } |
| 457 |
{ \clist_map_function:NN \c__xeCJK_hyphens_chars_clist \__xeCJK_tmp:w } |
| 458 |
\cs_undefine:N \__xeCJK_tmp:w |
| 459 |
} |
| 460 |
\clist_const:Nn \c__xeCJK_EX_chars_clist |
| 461 |
{ "FE15 , "FE16 , "FE56 , "FE57 , "FF01 , "FF1F } |
| 462 |
\clist_const:Nn \c__xeCJK_IS_chars_clist { "FE10 , "FE13 , "FE14 } |
| 463 |
\clist_const:Nn \c__xeCJK_CJ_chars_clist |
| 464 |
{ |
| 465 |
"3041 , "3043 , "3045 , "3047 , "3049 , "3063 , "3083 , "3085 , "3087 , "308E , |
| 466 |
"3095 , "3096 , "30A1 , "30A3 , "30A5 , "30A7 , "30A9 , "30C3 , "30E3 , "30E5 , |
| 467 |
"30E7 , "30EE , "30F5 , "30F6 , "30FC , "31F0 , "31F1 , "31F2 , "31F3 , "31F4 , |
| 468 |
"31F5 , "31F6 , "31F7 , "31F8 , "31F9 , "31FA , "31FB , "31FC , "31FD , "31FE , |
| 469 |
"31FF , "FF67 , "FF68 , "FF69 , "FF6A , "FF6B , "FF6C , "FF6D , "FF6E , "FF6F , |
| 470 |
"FF70 |
| 471 |
} |
| 472 |
\clist_const:Nn \c__xeCJK_PO_chars_clist { "FE6A , "FF05 , "FFE0 } |
| 473 |
\clist_new:N \c__xeCJK_FullRight_chars_clist |
| 474 |
\tl_map_inline:nn |
| 475 |
{ |
| 476 |
\c__xeCJK_CL_chars_clist |
| 477 |
\c__xeCJK_NS_chars_clist |
| 478 |
\c__xeCJK_EX_chars_clist |
| 479 |
\c__xeCJK_IS_chars_clist |
| 480 |
\c__xeCJK_PO_chars_clist |
| 481 |
\c__xeCJK_hyphens_chars_clist |
| 482 |
} |
| 483 |
{ |
| 484 |
\clist_gconcat:NNN \c__xeCJK_FullRight_chars_clist |
| 485 |
\c__xeCJK_FullRight_chars_clist #1 |
| 486 |
} |
| 487 |
\clist_const:Nn \c__xeCJK_CJK_chars_clist |
| 488 |
{ |
| 489 |
"02EA -> "02EB , |
| 490 |
"2E80 -> "2EFF , |
| 491 |
"2F00 -> "2FDF , |
| 492 |
"2FF0 -> "2FFF , |
| 493 |
"3000 -> "303F , |
| 494 |
"3040 -> "309F , |
| 495 |
"30A0 -> "30FF , |
| 496 |
"3100 -> "312F , |
| 497 |
"3130 -> "318F , |
| 498 |
"3190 -> "319F , |
| 499 |
"31A0 -> "31BF , |
| 500 |
"31C0 -> "31EF , |
| 501 |
"31F0 -> "31FF , |
| 502 |
"3200 -> "32FF , |
| 503 |
"3300 -> "33FF , |
| 504 |
"3400 -> "4DBF , |
| 505 |
"4DC0 -> "4DFF , |
| 506 |
"4E00 -> "9FFF , |
| 507 |
"A000 -> "A48F , |
| 508 |
"A490 -> "A4CF , |
| 509 |
"AC00 -> "D7AF , |
| 510 |
"F900 -> "FAFF , |
| 511 |
"FE10 -> "FE1F , |
| 512 |
"FE30 -> "FE4F , |
| 513 |
"FF00 -> "FFEF , |
| 514 |
"16FE0 -> "16FFF , |
| 515 |
"17000 -> "187FF , |
| 516 |
"18800 -> "18AFF , |
| 517 |
"18B00 -> "18CFF , |
| 518 |
"18D00 -> "18D7F , |
| 519 |
"1AFF0 -> "1AFFF , |
| 520 |
"1B000 -> "1B0FF , |
| 521 |
"1B100 -> "1B12F , |
| 522 |
"1B130 -> "1B16F , |
| 523 |
"1B170 -> "1B2FF , |
| 524 |
"1F200 -> "1F2FF , |
| 525 |
"20000 -> "2A6DF , |
| 526 |
"2A700 -> "2B73F , |
| 527 |
"2B740 -> "2B81F , |
| 528 |
"2B820 -> "2CEAF , |
| 529 |
"2CEB0 -> "2EBEF , |
| 530 |
"2F800 -> "2FA1F , |
| 531 |
"30000 -> "3134F |
| 532 |
} |
| 533 |
\clist_const:Nn \c__xeCJK_CM_chars_clist |
| 534 |
{ |
| 535 |
"302A -> "302F , |
| 536 |
"3099 -> "309A , |
| 537 |
"FE00 -> "FE0F , |
| 538 |
"E0100 -> "E01EF |
| 539 |
} |
| 540 |
\clist_const:Nn \c__xeCJK_HangulJamo_chars_clist |
| 541 |
{ |
| 542 |
"1100 -> "11FF , |
| 543 |
"A960 -> "A97F , |
| 544 |
"D7B0 -> "D7FF |
| 545 |
} |
| 546 |
\cs_new:Npn \xeCJK_class_num:n #1 |
| 547 |
{ \use:c { \__xeCJK_class_csname:n {#1} } } |
| 548 |
\NewDocumentCommand \xeCJKDeclareCharClass { s > { \TrimSpaces } m m } |
| 549 |
{ |
| 550 |
\xeCJK_declare_char_class:nn {#2} {#3} |
| 551 |
\IfBooleanT {#1} { \xeCJKResetPunctClass } |
| 552 |
} |
| 553 |
\cs_new_protected:Npn \xeCJK_declare_char_class:nn #1#2 |
| 554 |
{ |
| 555 |
\clist_set:Nx \l__xeCJK_tmp_clist {#2} |
| 556 |
\xeCJK_declare_char_class:nN {#1} \l__xeCJK_tmp_clist |
| 557 |
} |
| 558 |
\cs_new_protected:Npn \xeCJK_declare_char_class:nN #1#2 |
| 559 |
{ |
| 560 |
\clist_gconcat:ccN |
| 561 |
{ g__xeCJK_#1_range_clist } { g__xeCJK_#1_range_clist } #2 |
| 562 |
\clist_map_inline:Nn #2 |
| 563 |
{ |
| 564 |
\str_if_eq:nnF {##1} { -> } |
| 565 |
{ |
| 566 |
\__xeCJK_set_char_class_aux:Nnw \xeCJK_set_char_class:nnn {##1} |
| 567 |
{ \xeCJK_class_num:n {#1} } |
| 568 |
} |
| 569 |
} |
| 570 |
\xeCJK_set_char_class:nnn { "3099 } { "309A } { \xeCJK_class_num:n { CM } } |
| 571 |
} |
| 572 |
\NewDocumentCommand \__xeCJK_set_char_class_aux:Nnw |
| 573 |
{ m > { \SplitArgument { 1 } { -> } } m } { #1 #2 } |
| 574 |
\cs_generate_variant:Nn \clist_gconcat:NNN { cc } |
| 575 |
\cs_new_protected:Npn \__xeCJK_check_num_range:nnNN #1#2#3#4 |
| 576 |
{ |
| 577 |
\bool_lazy_or:nnTF |
| 578 |
{ \tl_if_blank_p:n {#1} } |
| 579 |
{ \tl_if_blank_p:n {#2} } |
| 580 |
{ |
| 581 |
\int_set:Nn #3 { \tl_if_blank:nTF {#1} {#2} {#1} } |
| 582 |
\int_set_eq:NN #3 #4 |
| 583 |
} |
| 584 |
{ |
| 585 |
\int_set:Nn #3 { \int_min:nn {#1} { \tl_if_novalue:nTF {#2} {#1} {#2} } } |
| 586 |
\int_set:Nn #4 { \int_max:nn {#1} { \tl_if_novalue:nTF {#2} {#1} {#2} } } |
| 587 |
} |
| 588 |
} |
| 589 |
\token_if_letter:NF ^^^^ac00 |
| 590 |
{ |
| 591 |
\int_set:Nn \l__xeCJK_begin_int { "AC00 } |
| 592 |
\int_set:Nn \l__xeCJK_end_int { "D7A3 } |
| 593 |
\xeCJK_int_until_do:nn { \l__xeCJK_begin_int > \l__xeCJK_end_int } |
| 594 |
{ |
| 595 |
\char_set_catcode_letter:n { \l__xeCJK_begin_int } |
| 596 |
\int_incr:N \l__xeCJK_begin_int |
| 597 |
} |
| 598 |
} |
| 599 |
\cs_new_protected:Npn \xeCJK_set_char_class:nnn #1#2#3 |
| 600 |
{ |
| 601 |
\__xeCJK_check_num_range:nnNN {#1} {#2} \l__xeCJK_begin_int \l__xeCJK_end_int |
| 602 |
\int_set:Nn \l__xeCJK_tmp_int {#3} |
| 603 |
\xeCJK_int_until_do:nn { \l__xeCJK_begin_int > \l__xeCJK_end_int } |
| 604 |
{ |
| 605 |
\tex_XeTeXcharclass:D \l__xeCJK_begin_int = \l__xeCJK_tmp_int |
| 606 |
\int_incr:N \l__xeCJK_begin_int |
| 607 |
} |
| 608 |
} |
| 609 |
\cs_new_protected:Npn \__xeCJK_set_char_class_eq:nn #1#2 |
| 610 |
{ |
| 611 |
\int_set:Nn \l__xeCJK_tmp_int { \xeCJK_class_num:n {#2} } |
| 612 |
\clist_map_inline:cn { c__xeCJK_#1_chars_clist } |
| 613 |
{ \tex_XeTeXcharclass:D ##1 = \l__xeCJK_tmp_int } |
| 614 |
} |
| 615 |
\NewDocumentCommand \normalspacedchars { m } |
| 616 |
{ |
| 617 |
\tl_map_inline:nn {#1} |
| 618 |
{ \tex_XeTeXcharclass:D `##1 = \xeCJK_class_num:n { NormalSpace } } |
| 619 |
} |
| 620 |
\NewDocumentCommand \xeCJKResetPunctClass { } |
| 621 |
{ |
| 622 |
\clist_gclear:N \g__xeCJK_HalfLeft_range_clist |
| 623 |
\clist_gclear:N \g__xeCJK_HalfRight_range_clist |
| 624 |
\clist_gclear:N \g__xeCJK_FullLeft_range_clist |
| 625 |
\clist_gclear:N \g__xeCJK_FullRight_range_clist |
| 626 |
\xeCJK_declare_char_class:nN { HalfLeft } \c__xeCJK_HalfLeft_chars_clist |
| 627 |
\xeCJK_declare_char_class:nN { HalfRight } \c__xeCJK_HalfRight_chars_clist |
| 628 |
\xeCJK_declare_char_class:nN { FullLeft } \c__xeCJK_FullLeft_chars_clist |
| 629 |
\xeCJK_declare_char_class:nN { FullRight } \c__xeCJK_FullRight_chars_clist |
| 630 |
} |
| 631 |
\NewDocumentCommand \xeCJKResetCharClass { } |
| 632 |
{ |
| 633 |
\clist_gclear:N \g__xeCJK_CJK_range_clist |
| 634 |
\clist_gclear:N \g__xeCJK_NormalSpace_range_clist |
| 635 |
\clist_gclear:N \g__xeCJK_CM_range_clist |
| 636 |
\clist_gclear:N \g__xeCJK_HangulJamo_range_clist |
| 637 |
\xeCJK_declare_char_class:nN { CJK } \c__xeCJK_CJK_chars_clist |
| 638 |
\xeCJK_declare_char_class:nN { NormalSpace } \c__xeCJK_NormalSpace_chars_clist |
| 639 |
\xeCJK_declare_char_class:nN { CM } \c__xeCJK_CM_chars_clist |
| 640 |
\xeCJK_declare_char_class:nN { HangulJamo } \c__xeCJK_HangulJamo_chars_clist |
| 641 |
\xeCJKResetPunctClass |
| 642 |
} |
| 643 |
\xeCJKResetCharClass |
| 644 |
\cs_new_protected:Npn \xeCJK_inter_class_toks:nnn #1#2#3 |
| 645 |
{ |
| 646 |
\tex_XeTeXinterchartoks:D \xeCJK_class_num:n {#1} ~ |
| 647 |
\xeCJK_class_num:n {#2} = {#3} |
| 648 |
} |
| 649 |
\cs_generate_variant:Nn \xeCJK_inter_class_toks:nnn { nne } |
| 650 |
\cs_new:Npn \xeCJK_get_inter_class_toks:nn #1#2 |
| 651 |
{ |
| 652 |
\tex_the:D \tex_XeTeXinterchartoks:D \xeCJK_class_num:n {#1} ~ |
| 653 |
\xeCJK_class_num:n {#2} |
| 654 |
} |
| 655 |
\cs_new_protected:Npn \xeCJK_clear_inter_class_toks:nn #1#2 |
| 656 |
{ \xeCJK_inter_class_toks:nnn {#1} {#2} { \prg_do_nothing: } } |
| 657 |
\cs_new_protected:Npn \xeCJK_pre_inter_class_toks:nnn #1#2#3 |
| 658 |
{ |
| 659 |
\xeCJK_inter_class_toks:nne {#1} {#2} |
| 660 |
{ \exp_not:n {#3} \xeCJK_get_inter_class_toks:nn {#1} {#2} } |
| 661 |
} |
| 662 |
\cs_generate_variant:Nn \xeCJK_pre_inter_class_toks:nnn { nne } |
| 663 |
\cs_new_protected:Npn \xeCJK_app_inter_class_toks:nnn #1#2#3 |
| 664 |
{ |
| 665 |
\xeCJK_inter_class_toks:nne {#1} {#2} |
| 666 |
{ \xeCJK_get_inter_class_toks:nn {#1} {#2} \exp_not:n {#3} } |
| 667 |
} |
| 668 |
\cs_generate_variant:Nn \xeCJK_app_inter_class_toks:nnn { nne } |
| 669 |
\cs_new_protected:Npn \xeCJK_copy_inter_class_toks:nnnn #1#2#3#4 |
| 670 |
{ |
| 671 |
\tl_set:Nx \l__xeCJK_tmp_tl |
| 672 |
{ \xeCJK_get_inter_class_toks:nn {#3} {#4} } |
| 673 |
\tl_if_empty:NTF \l__xeCJK_tmp_tl |
| 674 |
{ |
| 675 |
\tl_set:Nx \l__xeCJK_tmp_tl |
| 676 |
{ \xeCJK_get_inter_class_toks:nn {#1} {#2} } |
| 677 |
\tl_if_empty:NF \l__xeCJK_tmp_tl |
| 678 |
{ \xeCJK_clear_inter_class_toks:nn {#1} {#2} } |
| 679 |
} |
| 680 |
{ \xeCJK_inter_class_toks:nne {#1} {#2} { \exp_not:o \l__xeCJK_tmp_tl } } |
| 681 |
} |
| 682 |
\cs_new_protected:Npn \xeCJK_replace_inter_class_toks:nnnn #1#2#3#4 |
| 683 |
{ |
| 684 |
\tl_set:Nx \l__xeCJK_tmp_tl |
| 685 |
{ \xeCJK_get_inter_class_toks:nn {#1} {#2} } |
| 686 |
\tl_if_empty:NF \l__xeCJK_tmp_tl |
| 687 |
{ |
| 688 |
\tl_replace_all:Nnn \l__xeCJK_tmp_tl {#3} {#4} |
| 689 |
\xeCJK_inter_class_toks:nne {#1} {#2} |
| 690 |
{ \exp_not:o \l__xeCJK_tmp_tl } |
| 691 |
} |
| 692 |
} |
| 693 |
\cs_new_protected:Npn \xeCJK_clear_Boundary_and_CJK_toks: |
| 694 |
{ } |
| 695 |
\cs_new_protected:Npn \__xeCJK_update_clear_toks:n #1 |
| 696 |
{ |
| 697 |
\cs_gset_protected:Npx \xeCJK_clear_Boundary_and_CJK_toks: |
| 698 |
{ |
| 699 |
\exp_not:o { \xeCJK_clear_Boundary_and_CJK_toks: } |
| 700 |
\tex_XeTeXinterchartoks:D |
| 701 |
\xeCJK_class_num:n { Boundary } ~ |
| 702 |
\xeCJK_class_num:n {#1} = { \exp_not:N \prg_do_nothing: } |
| 703 |
} |
| 704 |
} |
| 705 |
\seq_new:N \g__xeCJK_base_class_seq |
| 706 |
\seq_gset_eq:NN \g__xeCJK_base_class_seq \g__xeCJK_class_seq |
| 707 |
\seq_new:N \g__xeCJK_non_CJK_class_seq |
| 708 |
\seq_gset_from_clist:Nn \g__xeCJK_non_CJK_class_seq |
| 709 |
{ Default , HalfLeft , HalfRight , NormalSpace , Boundary } |
| 710 |
\seq_new:N \g__xeCJK_CJK_class_seq |
| 711 |
\cs_new_protected:Npn \__xeCJK_save_CJK_class:n #1 |
| 712 |
{ |
| 713 |
\seq_gput_right:Nn \g__xeCJK_CJK_class_seq {#1} |
| 714 |
\tl_const:cn |
| 715 |
{ \__xeCJK_CJK_class_tl:n { \use:c { \__xeCJK_class_csname:n {#1} } } } |
| 716 |
{#1} |
| 717 |
\__xeCJK_update_clear_toks:n {#1} |
| 718 |
} |
| 719 |
\clist_map_function:nN |
| 720 |
{ CJK , FullLeft , FullRight , CM , HangulJamo } \__xeCJK_save_CJK_class:n |
| 721 |
\cs_new_protected:Npn \xeCJK_class_group_begin: |
| 722 |
{ |
| 723 |
\c_group_begin_token |
| 724 |
\bool_set_true:N \l__xeCJK_CJK_group_bool |
| 725 |
\xeCJK_reset_space_factor: |
| 726 |
\int_zero:N \tex_XeTeXdashbreakstate:D |
| 727 |
} |
| 728 |
\bool_new:N \l__xeCJK_CJK_group_bool |
| 729 |
\cs_new_eq:NN \xeCJK_class_group_end: \c_group_end_token |
| 730 |
\AtEndOfPackage |
| 731 |
{ |
| 732 |
\seq_map_inline:Nn \g__xeCJK_class_seq |
| 733 |
{ |
| 734 |
\str_if_eq:nnTF {#1} { CM } |
| 735 |
{ \xeCJK_copy_inter_class_toks:nnnn { CM } {#1} { CJK } { CJK } } |
| 736 |
{ |
| 737 |
\xeCJK_copy_inter_class_toks:nnnn { CM } {#1} { CJK } {#1} |
| 738 |
\str_if_eq:nnF {#1} { CJK } |
| 739 |
{ \xeCJK_copy_inter_class_toks:nnnn {#1} { CM } {#1} { CJK } } |
| 740 |
} |
| 741 |
} |
| 742 |
} |
| 743 |
\AtEndOfPackage |
| 744 |
{ |
| 745 |
\seq_map_inline:Nn \g__xeCJK_class_seq |
| 746 |
{ |
| 747 |
\str_if_eq:nnF {#1} { HangulJamo } |
| 748 |
{ |
| 749 |
\xeCJK_copy_inter_class_toks:nnnn { HangulJamo } {#1} { CJK } {#1} |
| 750 |
\xeCJK_copy_inter_class_toks:nnnn {#1} { HangulJamo } {#1} { CJK } |
| 751 |
} |
| 752 |
} |
| 753 |
} |
| 754 |
\clist_map_inline:nn { Default , HalfLeft , HalfRight , NormalSpace } |
| 755 |
{ |
| 756 |
\xeCJK_inter_class_toks:nnn {#1} { CJK } |
| 757 |
{ |
| 758 |
\xeCJK_class_group_begin: |
| 759 |
\xeCJK_select_font: |
| 760 |
\xeCJK_clear_inter_class_toks:nn {#1} { CJK } |
| 761 |
\xeCJK_clear_Boundary_and_CJK_toks: |
| 762 |
\xeCJK_fallback_symbol:NN |
| 763 |
\CJKsymbol |
| 764 |
} |
| 765 |
\xeCJK_inter_class_toks:nnn { CJK } {#1} { \xeCJK_class_group_end: } |
| 766 |
} |
| 767 |
\clist_map_inline:nn { Default , HalfLeft } |
| 768 |
{ |
| 769 |
\xeCJK_inter_class_toks:nnn { Boundary } {#1} |
| 770 |
{ \xeCJK_Boundary_and_Default: } |
| 771 |
\xeCJK_app_inter_class_toks:nnn { CJK } {#1} |
| 772 |
{ \CJKecglue } |
| 773 |
} |
| 774 |
\cs_new_protected:Npn \xeCJK_Boundary_and_Default: |
| 775 |
{ \xeCJK_check_for_ecglue: } |
| 776 |
\cs_new_protected:Npn \__xeCJK_check_for_xecglue: |
| 777 |
{ |
| 778 |
\__xeCJK_if_last_glue:TF |
| 779 |
{ \__xeCJK_replace_space: } |
| 780 |
{ \__xeCJK_check_for_ecglue: } |
| 781 |
} |
| 782 |
\cs_new_protected:Npn \__xeCJK_check_for_ecglue: |
| 783 |
{ |
| 784 |
\xeCJK_if_last_node:nTF { CJK } |
| 785 |
{ \use_i:nn } |
| 786 |
{ \xeCJK_if_last_node:nTF { CJK-widow } } |
| 787 |
{ \xeCJK_remove_node: \CJKecglue } |
| 788 |
{ |
| 789 |
\xeCJK_if_last_node:nT { CJK-space } |
| 790 |
{ \xeCJK_remove_node: \xeCJK_space_or_xecglue: } |
| 791 |
} |
| 792 |
} |
| 793 |
\cs_new_eq:NN \xeCJK_check_for_ecglue: \__xeCJK_check_for_ecglue: |
| 794 |
\cs_new_protected:Npn \__xeCJK_replace_space: |
| 795 |
{ |
| 796 |
\skip_set_eq:NN \l__xeCJK_last_skip \tex_lastskip:D |
| 797 |
\tex_unskip:D |
| 798 |
\xeCJK_if_last_node:nTF { CJK-space } |
| 799 |
{ \xeCJK_remove_node: \CJKecglue } |
| 800 |
{ |
| 801 |
\xeCJK_if_last_node:nTF { CJK } |
| 802 |
{ |
| 803 |
\skip_if_eq:nnTF |
| 804 |
{ \l__xeCJK_last_skip } |
| 805 |
{ \c_xeCJK_space_skip_tl } |
| 806 |
{ \xeCJK_remove_node: \CJKecglue } |
| 807 |
{ \skip_horizontal:N \l__xeCJK_last_skip } |
| 808 |
} |
| 809 |
{ \skip_horizontal:N \l__xeCJK_last_skip } |
| 810 |
} |
| 811 |
} |
| 812 |
\skip_new:N \l__xeCJK_last_skip |
| 813 |
\clist_map_inline:nn { Default , HalfRight } |
| 814 |
{ |
| 815 |
\xeCJK_inter_class_toks:nnn {#1} { Boundary } |
| 816 |
{ |
| 817 |
\int_gset_eq:NN \g__xeCJK_space_factor_int \tex_spacefactor:D |
| 818 |
\peek_meaning_remove:NTF \tex_italiccorrection:D |
| 819 |
{ |
| 820 |
\tex_italiccorrection:D |
| 821 |
{ \xeCJK_make_node:n { default } } |
| 822 |
} |
| 823 |
{ |
| 824 |
\token_if_space:NTF \l_peek_token |
| 825 |
{ \xeCJK_make_space_node: } |
| 826 |
{ { \xeCJK_make_node:n { default } } } |
| 827 |
} |
| 828 |
} |
| 829 |
\xeCJK_pre_inter_class_toks:nnn {#1} { CJK } { \CJKecglue } |
| 830 |
} |
| 831 |
\xeCJK_inter_class_toks:nnn { Boundary } { NormalSpace } |
| 832 |
{ \xeCJK_Boundary_and_NormalSp: } |
| 833 |
\cs_new_protected:Npn \xeCJK_Boundary_and_NormalSp: |
| 834 |
{ \xeCJK_check_for_ecglue_normalsp: } |
| 835 |
\cs_new_protected:Npn \__xeCJK_check_for_xecglue_normalsp: |
| 836 |
{ |
| 837 |
\__xeCJK_if_last_glue:TF |
| 838 |
{ \__xeCJK_replace_space: } |
| 839 |
{ \__xeCJK_check_for_ecglue_normalsp: } |
| 840 |
} |
| 841 |
\cs_new_protected:Npn \__xeCJK_check_for_ecglue_normalsp: |
| 842 |
{ |
| 843 |
\xeCJK_if_last_node:nT { CJK-space } |
| 844 |
{ \xeCJK_remove_node: \xeCJK_space_or_xecglue: } |
| 845 |
} |
| 846 |
\cs_new_eq:NN \xeCJK_check_for_ecglue_normalsp: |
| 847 |
\__xeCJK_check_for_ecglue_normalsp: |
| 848 |
\xeCJK_inter_class_toks:nnn { NormalSpace } { Boundary } |
| 849 |
{ |
| 850 |
\int_gset_eq:NN \g__xeCJK_space_factor_int \tex_spacefactor:D |
| 851 |
\peek_meaning_remove:NTF \tex_italiccorrection:D |
| 852 |
{ |
| 853 |
\tex_italiccorrection:D |
| 854 |
{ \xeCJK_make_node:n { normalspace } } |
| 855 |
} |
| 856 |
{ |
| 857 |
\token_if_space:NTF \l_peek_token |
| 858 |
{ \xeCJK_make_space_node: } |
| 859 |
{ { \xeCJK_make_node:n { normalspace } } } |
| 860 |
} |
| 861 |
} |
| 862 |
\xeCJK_inter_class_toks:nnn { Boundary } { CJK } |
| 863 |
{ |
| 864 |
\xeCJK_check_for_glue: |
| 865 |
\xeCJK_class_group_begin: |
| 866 |
\xeCJK_clear_Boundary_and_CJK_toks: |
| 867 |
\xeCJK_select_font: |
| 868 |
\xeCJK_fallback_symbol:NN |
| 869 |
\CJKsymbol |
| 870 |
} |
| 871 |
\cs_new_protected:Npn \xeCJK_check_for_glue: |
| 872 |
{ |
| 873 |
\__xeCJK_if_last_kern:TF |
| 874 |
{ \__xeCJK_check_for_glue_auxi: } |
| 875 |
{ |
| 876 |
\__xeCJK_if_last_math:TF |
| 877 |
{ \xeCJK_remove_node: \CJKecglue } |
| 878 |
{ \__xeCJK_check_for_glue_auxii: } |
| 879 |
} |
| 880 |
} |
| 881 |
\cs_new_protected:Npn \__xeCJK_check_for_glue_auxi: |
| 882 |
{ |
| 883 |
\dim_case:nn { \tex_lastkern:D } |
| 884 |
{ |
| 885 |
{ \__xeCJK_node:n { CJK } } |
| 886 |
{ \xeCJK_remove_node: \CJKglue } |
| 887 |
{ \__xeCJK_node:n { CJK-space } } |
| 888 |
{ \xeCJK_remove_node: \__xeCJK_ccglue_or_space: } |
| 889 |
{ \__xeCJK_node:n { CJK-widow } } |
| 890 |
{ \xeCJK_remove_node: \xeCJK_widow_penalty: \CJKglue } |
| 891 |
{ \__xeCJK_node:n { default } } |
| 892 |
{ \xeCJK_remove_node: \CJKecglue } |
| 893 |
} |
| 894 |
} |
| 895 |
\cs_new_protected:Npn \__xeCJK_check_for_glue_auxii: |
| 896 |
{ |
| 897 |
\xeCJK_if_last_punct:TF |
| 898 |
{ \__xeCJK_check_for_glue_auxiii: } |
| 899 |
{ \xeCJK_check_for_xglue: } |
| 900 |
} |
| 901 |
\cs_new_protected:Npn \__xeCJK_check_for_glue_auxiii: |
| 902 |
{ |
| 903 |
\bool_if:NT \l__xeCJK_last_penalty_bool |
| 904 |
{ \tex_penalty:D \l__xeCJK_last_penalty_int } |
| 905 |
\skip_horizontal:N \l__xeCJK_last_skip |
| 906 |
\tl_if_eq:NNF \l__xeCJK_aligni_tl \c__xeCJK_left_tl { \CJKglue } |
| 907 |
} |
| 908 |
\cs_new_eq:NN \xeCJK_check_for_xglue: \prg_do_nothing: |
| 909 |
\cs_new_protected:Npn \__xeCJK_check_for_xglue: |
| 910 |
{ |
| 911 |
\__xeCJK_if_last_glue:TF |
| 912 |
{ |
| 913 |
\skip_set_eq:NN \l__xeCJK_last_skip \tex_lastskip:D |
| 914 |
\tex_unskip:D |
| 915 |
\xeCJK_if_last_node:nTF { CJK-space } |
| 916 |
{ \xeCJK_remove_node: \__xeCJK_ccglue_or_space: } |
| 917 |
{ |
| 918 |
\xeCJK_if_last_node:nTF { default-space } |
| 919 |
{ \xeCJK_remove_node: \CJKecglue } |
| 920 |
{ \__xeCJK_check_for_xglue_aux: } |
| 921 |
} |
| 922 |
} |
| 923 |
} |
| 924 |
\cs_new_protected:Npn \__xeCJK_check_for_xglue_aux: |
| 925 |
{ |
| 926 |
\skip_if_eq:nnTF |
| 927 |
{ \l__xeCJK_last_skip } |
| 928 |
{ \c_xeCJK_space_skip_tl } |
| 929 |
{ |
| 930 |
\xeCJK_if_last_node:nTF { CJK } |
| 931 |
{ \xeCJK_remove_node: \__xeCJK_ccglue_or_space: } |
| 932 |
{ |
| 933 |
\xeCJK_if_last_node:nTF { default } |
| 934 |
{ \xeCJK_remove_node: \CJKecglue } |
| 935 |
{ |
| 936 |
\__xeCJK_if_last_math:TF |
| 937 |
{ \CJKecglue } |
| 938 |
{ \skip_horizontal:N \l__xeCJK_last_skip } |
| 939 |
} |
| 940 |
} |
| 941 |
} |
| 942 |
{ \skip_horizontal:N \l__xeCJK_last_skip } |
| 943 |
} |
| 944 |
\cs_new_protected:Npn \__xeCJK_ccglue_or_space: |
| 945 |
{ \CJKglue } |
| 946 |
\group_begin: |
| 947 |
\cs_set:Npn \__xeCJK_tmp:nn #1 |
| 948 |
{ |
| 949 |
\exp_args:Ncc \__xeCJK_tmp_aux:NNn |
| 950 |
{ __xeCJK_if_last_ #1 : } |
| 951 |
{ c__xeCJK_ #1 _node } |
| 952 |
} |
| 953 |
\cs_set:Npn \__xeCJK_tmp_aux:NNn #1#2#3 |
| 954 |
{ |
| 955 |
\int_const:Nn #2 {#3} |
| 956 |
\prg_new_conditional:Npnn #1 { T , F , TF } |
| 957 |
{ |
| 958 |
\if_int_compare:w \tex_lastnodetype:D = #2 |
| 959 |
\prg_return_true: \else: \prg_return_false: \fi: |
| 960 |
} |
| 961 |
} |
| 962 |
\__xeCJK_tmp:nn { none } { -1 } |
| 963 |
\__xeCJK_tmp:nn { hlist } { 1 } |
| 964 |
\__xeCJK_tmp:nn { math } { 10 } |
| 965 |
\__xeCJK_tmp:nn { glue } { 11 } |
| 966 |
\__xeCJK_tmp:nn { kern } { 12 } |
| 967 |
\__xeCJK_tmp:nn { penalty } { 13 } |
| 968 |
\group_end: |
| 969 |
\prg_new_conditional:Npnn \xeCJK_if_last_node:n #1 { p , T , F , TF } |
| 970 |
{ |
| 971 |
\if_dim:w |
| 972 |
\cs_if_exist_use:cTF { c__xeCJK_#1_node_dim } |
| 973 |
{ = \tex_lastkern:D } |
| 974 |
{ \use:c { c__xeCJK_#1_node_skip } = \tex_lastskip:D } |
| 975 |
\prg_return_true: \else: \prg_return_false: \fi: |
| 976 |
} |
| 977 |
\cs_new_protected:Npn \xeCJK_declare_node:n #1 |
| 978 |
{ |
| 979 |
\int_gincr:N \g__xeCJK_node_int |
| 980 |
\dim_if_exist:cTF { c__xeCJK_#1_node_dim } |
| 981 |
{ \dim_gset:cn } { \dim_const:cn } |
| 982 |
{ c__xeCJK_#1_node_dim } { \g__xeCJK_node_int sp } |
| 983 |
} |
| 984 |
\cs_new_protected:Npn \xeCJK_declare_glue_node:n #1 |
| 985 |
{ |
| 986 |
\int_gincr:N \g__xeCJK_node_int |
| 987 |
\skip_if_exist:cTF { c__xeCJK_#1_node_skip } |
| 988 |
{ \skip_gset:cn } { \skip_const:cn } |
| 989 |
{ c__xeCJK_#1_node_skip } { \g__xeCJK_node_int sp } |
| 990 |
} |
| 991 |
\int_new:N \g__xeCJK_node_int |
| 992 |
\int_gset:Nn \g__xeCJK_node_int { 10 } |
| 993 |
\cs_new_protected:Npn \xeCJK_make_node:n #1 |
| 994 |
{ \exp_args:Nc \__xeCJK_make_node:N { c__xeCJK_#1_node_dim } } |
| 995 |
\cs_new:Npn \__xeCJK_node:n #1 |
| 996 |
{ \use:c { c__xeCJK_#1_node_dim } } |
| 997 |
\cs_new:Npn \__xeCJK_gule_node:n #1 |
| 998 |
{ \use:c { c__xeCJK_#1_node_skip } } |
| 999 |
\cs_new_protected:Npn \__xeCJK_make_node:N #1 |
| 1000 |
{ |
| 1001 |
\tex_kern:D - #1 |
| 1002 |
\tex_kern:D #1 |
| 1003 |
} |
| 1004 |
\cs_new_protected:Npn \xeCJK_remove_node: |
| 1005 |
{ |
| 1006 |
\__xeCJK_if_last_kern:TF |
| 1007 |
{ \tex_unkern:D \tex_unkern:D } |
| 1008 |
{ |
| 1009 |
\__xeCJK_if_last_glue:T |
| 1010 |
{ \tex_unskip:D \tex_unskip:D } |
| 1011 |
} |
| 1012 |
} |
| 1013 |
\xeCJK_declare_node:n { CJK } |
| 1014 |
\xeCJK_declare_node:n { CJK-space } |
| 1015 |
\xeCJK_declare_node:n { default } |
| 1016 |
\xeCJK_declare_node:n { CJK-widow } |
| 1017 |
\xeCJK_declare_node:n { normalspace } |
| 1018 |
\xeCJK_declare_glue_node:n { default-space } |
| 1019 |
\cs_new_eq:NN \xeCJK_make_space_node: \prg_do_nothing: |
| 1020 |
\cs_new_protected:Npx \__xeCJK_make_space_node: |
| 1021 |
{ |
| 1022 |
\tex_hskip:D - \__xeCJK_gule_node:n { default-space } |
| 1023 |
\tex_hskip:D \__xeCJK_gule_node:n { default-space } |
| 1024 |
} |
| 1025 |
\keys_define:nn { xeCJK / options } |
| 1026 |
{ |
| 1027 |
CJKglue .code:n = |
| 1028 |
{ |
| 1029 |
\cs_set_protected:Npn \CJKglue {#1} |
| 1030 |
\xeCJK_glue_to_skip:nN {#1} \l__xeCJK_ccglue_skip |
| 1031 |
} |
| 1032 |
} |
| 1033 |
\skip_new:N \l__xeCJK_ccglue_skip |
| 1034 |
\keys_define:nn { xeCJK / options } |
| 1035 |
{ |
| 1036 |
CJKecglue .code:n = |
| 1037 |
{ |
| 1038 |
\cs_set_protected:Npn \CJKecglue {#1} |
| 1039 |
\xeCJK_glue_to_skip:nN {#1} \l__xeCJK_ecglue_skip |
| 1040 |
} , |
| 1041 |
xCJKecglue .choice: , |
| 1042 |
xCJKecglue / true .code:n = |
| 1043 |
{ |
| 1044 |
\bool_set_true:N \l__xeCJK_xecglue_bool |
| 1045 |
\cs_set_eq:NN \xeCJK_space_or_xecglue: \CJKecglue |
| 1046 |
\cs_set_eq:NN \xeCJK_make_space_node: \__xeCJK_make_space_node: |
| 1047 |
\cs_set_eq:NN \xeCJK_check_for_xglue: \__xeCJK_check_for_xglue: |
| 1048 |
\cs_set_eq:NN \xeCJK_check_for_ecglue: \__xeCJK_check_for_xecglue: |
| 1049 |
\cs_set_eq:NN |
| 1050 |
\xeCJK_check_for_ecglue_normalsp: |
| 1051 |
\__xeCJK_check_for_xecglue_normalsp: |
| 1052 |
} , |
| 1053 |
xCJKecglue / false .code:n = |
| 1054 |
{ |
| 1055 |
\bool_set_false:N \l__xeCJK_xecglue_bool |
| 1056 |
\cs_set_eq:NN \xeCJK_space_or_xecglue: \xeCJK_space_glue: |
| 1057 |
\xeCJK_cs_clear:N \xeCJK_make_space_node: |
| 1058 |
\xeCJK_cs_clear:N \xeCJK_check_for_xglue: |
| 1059 |
\cs_set_eq:NN \xeCJK_check_for_ecglue: \__xeCJK_check_for_ecglue: |
| 1060 |
\cs_set_eq:NN |
| 1061 |
\xeCJK_check_for_ecglue_normalsp: |
| 1062 |
\__xeCJK_check_for_ecglue_normalsp: |
| 1063 |
} , |
| 1064 |
xCJKecglue / unknown .code:n = |
| 1065 |
{ |
| 1066 |
\bool_set_true:N \l__xeCJK_xecglue_bool |
| 1067 |
\cs_set_protected:Npn \CJKecglue {#1} |
| 1068 |
\xeCJK_glue_to_skip:nN {#1} \l__xeCJK_ecglue_skip |
| 1069 |
\cs_set_eq:NN \xeCJK_space_or_xecglue: \CJKecglue |
| 1070 |
\cs_set_eq:NN \xeCJK_make_space_node: \__xeCJK_make_space_node: |
| 1071 |
\cs_set_eq:NN \xeCJK_check_for_xglue: \__xeCJK_check_for_xglue: |
| 1072 |
\cs_set_eq:NN \xeCJK_check_for_ecglue: \__xeCJK_check_for_xecglue: |
| 1073 |
\cs_set_eq:NN |
| 1074 |
\xeCJK_check_for_ecglue_normalsp: |
| 1075 |
\__xeCJK_check_for_xecglue_normalsp: |
| 1076 |
} , |
| 1077 |
xCJKecglue .default:n = { true } |
| 1078 |
} |
| 1079 |
\cs_new_eq:NN \xeCJK_space_glue: \c_space_tl |
| 1080 |
\skip_new:N \l__xeCJK_ecglue_skip |
| 1081 |
\bool_new:N \l__xeCJK_xecglue_bool |
| 1082 |
\keys_define:nn { xeCJK / options } |
| 1083 |
{ |
| 1084 |
CJKspace .choice: , |
| 1085 |
CJKspace / true .code:n = |
| 1086 |
{ |
| 1087 |
\bool_set_true:N \l__xeCJK_reserve_space_bool |
| 1088 |
\cs_set_protected:Npn \__xeCJK_ccglue_or_space: |
| 1089 |
{ \xeCJK_space_glue: } |
| 1090 |
} , |
| 1091 |
CJKspace / false .code:n = |
| 1092 |
{ |
| 1093 |
\bool_set_false:N \l__xeCJK_reserve_space_bool |
| 1094 |
\cs_set_protected:Npn \__xeCJK_ccglue_or_space: |
| 1095 |
{ \CJKglue } |
| 1096 |
} , |
| 1097 |
CJKspace .default:n = { true } , |
| 1098 |
space .meta:n = { CJKspace = true } , |
| 1099 |
nospace .meta:n = { CJKspace = false } |
| 1100 |
} |
| 1101 |
\bool_new:N \l__xeCJK_reserve_space_bool |
| 1102 |
\xeCJK_inter_class_toks:nnn { CJK } { Boundary } { \xeCJK_CJK_and_Boundary:w } |
| 1103 |
\cs_new_protected:Npn \xeCJK_CJK_and_Boundary:w |
| 1104 |
{ |
| 1105 |
\xeCJK_peek_catcode_ignore_spaces:NTF \c_math_toggle_token |
| 1106 |
{ |
| 1107 |
\bool_if:NTF \l__xeCJK_peek_ignore_spaces_bool |
| 1108 |
{ \xeCJK_class_group_end: \xeCJK_space_or_xecglue: } |
| 1109 |
{ \xeCJK_class_group_end: \CJKecglue } |
| 1110 |
} |
| 1111 |
{ |
| 1112 |
\group_align_safe_begin: |
| 1113 |
\bool_if:NTF \l__xeCJK_peek_ignore_spaces_bool |
| 1114 |
{ |
| 1115 |
\token_if_macro:NTF \l_peek_token |
| 1116 |
{ \__xeCJK_boundary_reserve_space: } |
| 1117 |
{ \__xeCJK_boundary_group_end:n { CJK-space } } |
| 1118 |
} |
| 1119 |
{ |
| 1120 |
\token_if_eq_meaning:NNTF \l_peek_token \scan_stop: |
| 1121 |
{ \__xeCJK_CJK_and_Boundary_relax:N } |
| 1122 |
{ \__xeCJK_boundary_group_end:n { CJK } } |
| 1123 |
} |
| 1124 |
} |
| 1125 |
} |
| 1126 |
\cs_new_protected:Npn \__xeCJK_boundary_reserve_space: |
| 1127 |
{ |
| 1128 |
\__xeCJK_boundary_group_end:n { CJK-space } |
| 1129 |
\xeCJK_space_or_xecglue: |
| 1130 |
} |
| 1131 |
\cs_new_protected:Npn \__xeCJK_CJK_and_Boundary_relax:N #1 |
| 1132 |
{ |
| 1133 |
\__xeCJK_boundary_group_end:n { CJK } |
| 1134 |
\token_if_eq_meaning:NNTF #1 \scan_stop: |
| 1135 |
{#1} { \cs_set_eq:NN #1 \scan_stop: #1 } |
| 1136 |
} |
| 1137 |
\cs_new_protected:Npn \__xeCJK_boundary_group_end:n #1 |
| 1138 |
{ |
| 1139 |
\group_align_safe_end: |
| 1140 |
\xeCJK_class_group_end: |
| 1141 |
{ \xeCJK_make_node:n {#1} } |
| 1142 |
} |
| 1143 |
\cs_new_protected:Npn \xeCJK_ignore_spaces:w |
| 1144 |
{ |
| 1145 |
\xeCJK_peek_catcode_ignore_spaces:NTF \c_math_toggle_token |
| 1146 |
{ |
| 1147 |
\bool_if:NTF \l__xeCJK_peek_ignore_spaces_bool |
| 1148 |
{ \xeCJK_space_or_xecglue: } { \CJKecglue } |
| 1149 |
} |
| 1150 |
{ |
| 1151 |
\bool_if:NT \l__xeCJK_peek_ignore_spaces_bool |
| 1152 |
{ |
| 1153 |
\dim_case:nn { \tex_lastkern:D } |
| 1154 |
{ |
| 1155 |
{ \__xeCJK_node:n { CJK } } |
| 1156 |
{ \xeCJK_remove_node: \xeCJK_make_node:n { CJK-space } } |
| 1157 |
{ \__xeCJK_node:n { default } } |
| 1158 |
{ \xeCJK_remove_node: \xeCJK_make_space_node: } |
| 1159 |
} |
| 1160 |
\group_align_safe_begin: |
| 1161 |
\token_if_macro:NTF \l_peek_token |
| 1162 |
{ \__xeCJK_reserve_space_aux: } |
| 1163 |
{ \group_align_safe_end: } |
| 1164 |
} |
| 1165 |
} |
| 1166 |
} |
| 1167 |
\cs_new_protected:Npn \__xeCJK_reserve_space_aux: |
| 1168 |
{ |
| 1169 |
\group_align_safe_end: |
| 1170 |
\xeCJK_space_or_xecglue: |
| 1171 |
} |
| 1172 |
\xeCJK_inter_class_toks:nnn { CJK } { CJK } |
| 1173 |
{ \xeCJK_CJK_and_CJK:N } |
| 1174 |
\cs_new_protected:Npn \xeCJK_CJK_and_CJK:N |
| 1175 |
{ |
| 1176 |
\CJKglue |
| 1177 |
\xeCJK_fallback_symbol:NN |
| 1178 |
\CJKsymbol |
| 1179 |
} |
| 1180 |
\xeCJK_inter_class_toks:nnn { FullLeft } { CJK } |
| 1181 |
{ |
| 1182 |
\xeCJK_FullLeft_and_CJK: |
| 1183 |
\xeCJK_fallback_symbol:NN |
| 1184 |
\CJKsymbol |
| 1185 |
} |
| 1186 |
\xeCJK_inter_class_toks:nnn { FullRight } { CJK } |
| 1187 |
{ |
| 1188 |
\xeCJK_FullRight_and_CJK: |
| 1189 |
\xeCJK_fallback_symbol:NN |
| 1190 |
\CJKsymbol |
| 1191 |
} |
| 1192 |
\seq_map_inline:Nn \g__xeCJK_non_CJK_class_seq |
| 1193 |
{ |
| 1194 |
\clist_map_inline:nn { FullLeft , FullRight } |
| 1195 |
{ |
| 1196 |
\xeCJK_inter_class_toks:nne {#1} {##1} |
| 1197 |
{ \exp_not:c { xeCJK_Default_and_##1:nN } {#1} } |
| 1198 |
\xeCJK_inter_class_toks:nne {##1} {#1} |
| 1199 |
{ \exp_not:c { xeCJK_##1_and_Default: } } |
| 1200 |
} |
| 1201 |
} |
| 1202 |
\xeCJK_inter_class_toks:nnn { Boundary } { FullLeft } |
| 1203 |
{ \xeCJK_Boundary_and_FullLeft:N } |
| 1204 |
\xeCJK_inter_class_toks:nnn { Boundary } { FullRight } |
| 1205 |
{ \xeCJK_Boundary_and_FullRight:N } |
| 1206 |
\xeCJK_inter_class_toks:nnn { FullLeft } { Boundary } |
| 1207 |
{ \xeCJK_FullLeft_and_Boundary: } |
| 1208 |
\xeCJK_inter_class_toks:nnn { FullRight } { Boundary } |
| 1209 |
{ \xeCJK_FullRight_and_Boundary: } |
| 1210 |
\cs_new_protected:Npn \xeCJK_FullLeft_and_Boundary: |
| 1211 |
{ |
| 1212 |
\__xeCJK_punct_if_middle:NTF \g__xeCJK_last_punct_tl |
| 1213 |
{ |
| 1214 |
\__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1215 |
\xeCJK_class_group_end: |
| 1216 |
\exp_after:wN \xeCJK_punct_node:N \g__xeCJK_last_punct_tl |
| 1217 |
\xeCJK_no_break: |
| 1218 |
\__xeCJK_punct_glue:NN \c__xeCJK_left_tl \g__xeCJK_last_punct_tl |
| 1219 |
} |
| 1220 |
{ |
| 1221 |
\xeCJK_class_group_end: |
| 1222 |
\exp_after:wN \xeCJK_punct_node:N \g__xeCJK_last_punct_tl |
| 1223 |
\__xeCJK_nobreak_zero_glue: |
| 1224 |
} |
| 1225 |
\tex_ignorespaces:D |
| 1226 |
} |
| 1227 |
\cs_new_protected:Npn \xeCJK_FullRight_and_Boundary: |
| 1228 |
{ |
| 1229 |
\__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1230 |
\xeCJK_class_group_end: |
| 1231 |
\exp_after:wN \xeCJK_punct_node:N \g__xeCJK_last_punct_tl |
| 1232 |
\__xeCJK_punct_glue:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1233 |
\tex_ignorespaces:D |
| 1234 |
} |
| 1235 |
\cs_new_protected:Npn \xeCJK_punct_node:N #1 |
| 1236 |
{ |
| 1237 |
\__xeCJK_punct_bound_unitization:NN #1 \l__xeCJK_tmp_dim |
| 1238 |
\__xeCJK_make_node:N \l__xeCJK_tmp_dim |
| 1239 |
\dim_set:Nn \l__xeCJK_tmp_dim { `#1 sp } |
| 1240 |
\__xeCJK_make_node:N \l__xeCJK_tmp_dim |
| 1241 |
} |
| 1242 |
\cs_new_protected:Npn \__xeCJK_punct_bound_unitization:NN #1#2 |
| 1243 |
{ |
| 1244 |
\dim_set:Nn #2 |
| 1245 |
{ |
| 1246 |
\dim_max:nn |
| 1247 |
{ \c_zero_dim } |
| 1248 |
{ \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_right_tl #1 } |
| 1249 |
} |
| 1250 |
\dim_compare:nNnF {#2} < { 1pt } |
| 1251 |
{ \dim_set:Nn #2 { -1pt * \dim_ratio:nn {#2} { \c_max_dim } } } |
| 1252 |
} |
| 1253 |
\cs_new_protected:Npn \xeCJK_punct_bound_kern:N #1 |
| 1254 |
{ |
| 1255 |
\exp_after:wN \__xeCJK_punct_bound_kern:NN |
| 1256 |
\g__xeCJK_last_punct_tl #1 |
| 1257 |
} |
| 1258 |
\cs_new_protected:Npn \__xeCJK_punct_bound_kern:NN #1#2 |
| 1259 |
{ |
| 1260 |
\xeCJK_get_punct_bounds:NN \l__xeCJK_aligni_tl #1 |
| 1261 |
\xeCJK_get_punct_kerning:NN #1 #2 |
| 1262 |
\__xeCJK_punct_bound_unitization:NN #1 \l__xeCJK_tmp_dim |
| 1263 |
\skip_set:Nn \l__xeCJK_punct_kern_skip |
| 1264 |
{ \__xeCJK_use_dim_or_skip:nNN { bound_kern } #1 #2 } |
| 1265 |
\dim_compare:nNnF \l__xeCJK_tmp_dim = \l__xeCJK_last_bound_dim |
| 1266 |
{ \__xeCJK_punct_bound_kern_ratio:NN #1 #2 } |
| 1267 |
\bool_if:NTF \l__xeCJK_last_penalty_bool |
| 1268 |
{ |
| 1269 |
\tex_penalty:D \l__xeCJK_last_penalty_int |
| 1270 |
\skip_horizontal:N |
| 1271 |
} |
| 1272 |
{ \__xeCJK_punct_bound_kern_aux:NNN #1 #2 } |
| 1273 |
\l__xeCJK_punct_kern_skip |
| 1274 |
} |
| 1275 |
\skip_new:N \l__xeCJK_punct_kern_skip |
| 1276 |
\cs_new_protected:Npn \__xeCJK_punct_bound_kern_ratio:NN #1#2 |
| 1277 |
{ |
| 1278 |
\dim_set:Nn \l__xeCJK_bound_dim |
| 1279 |
{ \__xeCJK_use_punct_dim:nNN { bound_width } #1 #2 } |
| 1280 |
\dim_compare:nNnT \l__xeCJK_bound_dim > \c_zero_dim |
| 1281 |
{ |
| 1282 |
\dim_compare:nNnF \l__xeCJK_last_bound_dim > \c_zero_dim |
| 1283 |
{ |
| 1284 |
\dim_set:Nn \l__xeCJK_last_bound_dim |
| 1285 |
{ |
| 1286 |
- \l__xeCJK_last_bound_dim * |
| 1287 |
\dim_ratio:nn { \c_max_dim } { 1pt } |
| 1288 |
} |
| 1289 |
} |
| 1290 |
\__xeCJK_punct_bound_kern_ratio_aux:N #2 |
| 1291 |
} |
| 1292 |
} |
| 1293 |
\cs_new_protected:Npn \__xeCJK_punct_bound_kern_ratio_aux:N #1 |
| 1294 |
{ |
| 1295 |
\skip_set:Nn \l__xeCJK_punct_kern_skip |
| 1296 |
{ |
| 1297 |
\l__xeCJK_punct_kern_skip * |
| 1298 |
\dim_ratio:nn |
| 1299 |
{ |
| 1300 |
\l__xeCJK_last_bound_dim |
| 1301 |
+ \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_left_tl #1 |
| 1302 |
} |
| 1303 |
{ \l__xeCJK_bound_dim } |
| 1304 |
} |
| 1305 |
} |
| 1306 |
\cs_new_protected:Npn \__xeCJK_nobreak_hskip:N |
| 1307 |
{ \xeCJK_no_break: \skip_horizontal:N } |
| 1308 |
\cs_new_protected:Npn \__xeCJK_nobreak_hskip:n |
| 1309 |
{ \xeCJK_no_break: \skip_horizontal:n } |
| 1310 |
\cs_new_eq:NN \__xeCJK_punct_bound_kern:N \__xeCJK_nobreak_hskip:N |
| 1311 |
\cs_new_protected:Npn \__xeCJK_punct_bound_breakable_kern:N |
| 1312 |
{ |
| 1313 |
\tl_if_eq:NNTF \l__xeCJK_aligni_tl \c__xeCJK_right_tl |
| 1314 |
{ |
| 1315 |
\tl_if_eq:NNTF \l__xeCJK_alignii_tl \c__xeCJK_left_tl |
| 1316 |
{ \skip_horizontal:N } |
| 1317 |
{ \__xeCJK_nobreak_hskip:N } |
| 1318 |
} |
| 1319 |
{ \__xeCJK_nobreak_hskip:N } |
| 1320 |
} |
| 1321 |
\cs_new_protected:Npn \__xeCJK_punct_bound_kern_aux:NNN #1#2 |
| 1322 |
{ |
| 1323 |
\str_if_eq:nnTF {#1} {#2} |
| 1324 |
{ \__xeCJK_nobreak_hskip:N } |
| 1325 |
{ |
| 1326 |
\__xeCJK_punct_if_long:NTF #1 |
| 1327 |
{ \skip_horizontal:N } |
| 1328 |
{ |
| 1329 |
\__xeCJK_punct_if_long:NTF #2 |
| 1330 |
{ \skip_horizontal:N } |
| 1331 |
{ \__xeCJK_punct_bound_kern:N } |
| 1332 |
} |
| 1333 |
} |
| 1334 |
} |
| 1335 |
\clist_map_inline:nn { CJK , FullLeft , FullRight } |
| 1336 |
{ |
| 1337 |
\clist_map_inline:nn { FullLeft , FullRight } |
| 1338 |
{ |
| 1339 |
\xeCJK_inter_class_toks:nne {#1} {##1} |
| 1340 |
{ \exp_not:c { xeCJK_#1_and_##1:N } } |
| 1341 |
} |
| 1342 |
} |
| 1343 |
\cs_new_protected:Npn \__xeCJK_punct_bound_rule:NN #1#2 |
| 1344 |
{ |
| 1345 |
\tex_vrule:D |
| 1346 |
width - \__xeCJK_use_punct_dim:nNN { bound } #1 #2 ~ |
| 1347 |
depth \c_zero_dim |
| 1348 |
height \c_zero_dim \scan_stop: |
| 1349 |
} |
| 1350 |
\cs_new_protected:Npn \__xeCJK_punct_rule:NN #1#2 |
| 1351 |
{ |
| 1352 |
\tex_vrule:D |
| 1353 |
width \__xeCJK_use_punct_dim:nNN { rule } #1 #2 ~ |
| 1354 |
depth \c_zero_dim |
| 1355 |
height \c_zero_dim \scan_stop: |
| 1356 |
} |
| 1357 |
\cs_new_protected:Npn \__xeCJK_punct_glue:NN #1#2 |
| 1358 |
{ \__xeCJK_punct_hskip:n { \__xeCJK_use_dim_or_skip:nNN { glue } #1 #2 } } |
| 1359 |
\cs_new_eq:NN \__xeCJK_punct_hskip:n \skip_horizontal:n |
| 1360 |
\cs_new_protected:Npn \__xeCJK_punct_kern:NN #1#2 |
| 1361 |
{ |
| 1362 |
\str_if_eq:eeTF {#1} {#2} |
| 1363 |
{ \__xeCJK_punct_nobreak_kern:NN } |
| 1364 |
{ |
| 1365 |
\__xeCJK_punct_if_long:NTF #1 |
| 1366 |
{ \__xeCJK_punct_breakable_kern:NN } |
| 1367 |
{ |
| 1368 |
\__xeCJK_punct_if_long:NTF #2 |
| 1369 |
{ \__xeCJK_punct_breakable_kern:NN } |
| 1370 |
{ \__xeCJK_punct_nobreak_kern:NN } |
| 1371 |
} |
| 1372 |
} |
| 1373 |
#1 #2 |
| 1374 |
} |
| 1375 |
\cs_new_eq:NN \xeCJK_punct_kern:NN \__xeCJK_punct_kern:NN |
| 1376 |
\cs_new_protected:Npn \__xeCJK_punct_nobreak_kern:NN #1#2 |
| 1377 |
{ \__xeCJK_nobreak_hskip:n { \__xeCJK_use_dim_or_skip:nNN { kern } #1 #2 } } |
| 1378 |
\cs_new_protected:Npn \__xeCJK_punct_breakable_kern:NN #1#2 |
| 1379 |
{ |
| 1380 |
\exp_after:wN \__xeCJK_punct_if_right:NT #1 |
| 1381 |
{ \__xeCJK_punct_rule:NN \c__xeCJK_right_tl #1 } |
| 1382 |
\__xeCJK_punct_breakable_kern:n |
| 1383 |
{ \__xeCJK_use_dim_or_skip:nNN { bound_kern } #1 #2 } |
| 1384 |
\__xeCJK_punct_if_right:NF #2 |
| 1385 |
{ \__xeCJK_punct_rule:NN \c__xeCJK_left_tl #2 } |
| 1386 |
} |
| 1387 |
\cs_new_eq:NN \__xeCJK_punct_breakable_kern:n \skip_horizontal:n |
| 1388 |
\tl_new:N \g__xeCJK_last_punct_tl |
| 1389 |
\cs_new_protected:Npn \xeCJK_FullLeft_and_CJK: |
| 1390 |
{ |
| 1391 |
\__xeCJK_punct_if_middle:NTF \g__xeCJK_last_punct_tl |
| 1392 |
{ |
| 1393 |
\__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1394 |
\xeCJK_no_break: |
| 1395 |
\__xeCJK_punct_glue:NN \c__xeCJK_left_tl \g__xeCJK_last_punct_tl |
| 1396 |
} |
| 1397 |
{ } |
| 1398 |
\__xeCJK_select_font: |
| 1399 |
} |
| 1400 |
\cs_new_protected:Npn \xeCJK_FullLeft_and_Default: |
| 1401 |
{ |
| 1402 |
\__xeCJK_punct_if_middle:NTF \g__xeCJK_last_punct_tl |
| 1403 |
{ |
| 1404 |
\__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1405 |
\xeCJK_class_group_end: \xeCJK_no_break: |
| 1406 |
\__xeCJK_punct_glue:NN \c__xeCJK_left_tl \g__xeCJK_last_punct_tl |
| 1407 |
} |
| 1408 |
{ |
| 1409 |
\xeCJK_class_group_end: |
| 1410 |
\__xeCJK_nobreak_zero_glue: |
| 1411 |
} |
| 1412 |
} |
| 1413 |
\cs_new_protected:Npn \__xeCJK_nobreak_zero_glue: |
| 1414 |
{ |
| 1415 |
\tex_penalty:D \c__xeCJK_nobreak_penalty_int |
| 1416 |
\skip_horizontal:N \c_zero_skip |
| 1417 |
} |
| 1418 |
\cs_new_protected:Npn \__xeCJK_zero_glue: |
| 1419 |
{ \skip_horizontal:N \c_zero_skip } |
| 1420 |
\cs_new_protected:Npn \xeCJK_FullRight_and_CJK: |
| 1421 |
{ |
| 1422 |
\__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1423 |
\__xeCJK_punct_glue:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1424 |
\__xeCJK_select_font: |
| 1425 |
\CJKglue |
| 1426 |
} |
| 1427 |
\cs_new_protected:Npn \xeCJK_FullRight_and_Default: |
| 1428 |
{ |
| 1429 |
\__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1430 |
\xeCJK_class_group_end: |
| 1431 |
\__xeCJK_punct_glue:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1432 |
} |
| 1433 |
\cs_new_protected:Npn \xeCJK_Default_and_FullLeft:nN #1#2 |
| 1434 |
{ |
| 1435 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_left_tl #2 |
| 1436 |
\__xeCJK_Default_and_FullLeft_glue:N #2 |
| 1437 |
\xeCJK_class_group_begin: |
| 1438 |
\xeCJK_select_punct_font: |
| 1439 |
\xeCJK_clear_inter_class_toks:nn {#1} { FullLeft } |
| 1440 |
\xeCJK_clear_Boundary_and_CJK_toks: |
| 1441 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#2} |
| 1442 |
\__xeCJK_punct_rule:NN \c__xeCJK_left_tl #2 |
| 1443 |
\xeCJK_fallback_punct_symbol:NN |
| 1444 |
\CJKpunctsymbol #2 |
| 1445 |
} |
| 1446 |
\cs_new_protected:Npn \__xeCJK_Default_and_FullLeft_glue:N #1 |
| 1447 |
{ \__xeCJK_punct_glue:NN \c__xeCJK_left_tl #1 } |
| 1448 |
\cs_new_protected:Npn \xeCJK_CJK_and_FullLeft:N #1 |
| 1449 |
{ |
| 1450 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_left_tl #1 |
| 1451 |
\__xeCJK_CJK_and_FullLeft_glue:N #1 |
| 1452 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#1} |
| 1453 |
\__xeCJK_punct_rule:NN \c__xeCJK_left_tl #1 |
| 1454 |
\__xeCJK_select_punct_font: |
| 1455 |
\xeCJK_fallback_punct_symbol:NN |
| 1456 |
\CJKpunctsymbol #1 |
| 1457 |
} |
| 1458 |
\cs_new_protected:Npn \__xeCJK_CJK_and_FullLeft_glue:N #1 |
| 1459 |
{ |
| 1460 |
\CJKglue |
| 1461 |
\__xeCJK_punct_glue:NN \c__xeCJK_left_tl #1 |
| 1462 |
} |
| 1463 |
\cs_new_protected:Npn \xeCJK_Boundary_and_FullLeft:N #1 |
| 1464 |
{ |
| 1465 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_left_tl #1 |
| 1466 |
\__xeCJK_Boundary_and_FullLeft_glue:N #1 |
| 1467 |
\xeCJK_class_group_begin: |
| 1468 |
\xeCJK_select_punct_font: |
| 1469 |
\xeCJK_clear_Boundary_and_CJK_toks: |
| 1470 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#1} |
| 1471 |
\__xeCJK_punct_rule:NN \c__xeCJK_left_tl #1 |
| 1472 |
\xeCJK_fallback_punct_symbol:NN |
| 1473 |
\CJKpunctsymbol #1 |
| 1474 |
} |
| 1475 |
\cs_new_protected:Npn \__xeCJK_Boundary_and_FullLeft_glue:N #1 |
| 1476 |
{ |
| 1477 |
\tl_set_eq:NN \l__xeCJK_alignii_tl \c__xeCJK_left_tl |
| 1478 |
\group_begin: \exp_args:NNc \group_end: \cs_if_exist_use:NTF |
| 1479 |
{ __xeCJK_bound_type_ \int_use:N \tex_lastnodetype:D _glue:Nn } |
| 1480 |
{#1} |
| 1481 |
{ \use:n } |
| 1482 |
{ \__xeCJK_punct_glue:NN \c__xeCJK_left_tl #1 } |
| 1483 |
} |
| 1484 |
\tl_new:N \c__xeCJK_alignii_tl |
| 1485 |
\cs_new_protected:cpn { __xeCJK_bound_type_ -1 _glue:Nn } #1#2 |
| 1486 |
{ \__xeCJK_zero_glue: } |
| 1487 |
\cs_new_protected:cpn { __xeCJK_bound_type_ 1 _glue:Nn } #1 |
| 1488 |
{ |
| 1489 |
\int_do_while:nNnn \tex_lastnodetype:D = \c__xeCJK_hlist_node |
| 1490 |
{ \__xeCJK_bound_hbox_auxi: } |
| 1491 |
\__xeCJK_if_last_none:TF |
| 1492 |
{ |
| 1493 |
\dim_case:nnF { \box_wd:N \l__xeCJK_indent_box } |
| 1494 |
{ |
| 1495 |
{ \tex_parindent:D } { \__xeCJK_bound_hbox_auxii:nn } |
| 1496 |
{ \c_zero_dim } { \use_i:nn } |
| 1497 |
} |
| 1498 |
{ \use:nn } |
| 1499 |
} |
| 1500 |
{ \use:nn } |
| 1501 |
{ \hbox_unpack_drop:N \l__xeCJK_indent_box } |
| 1502 |
} |
| 1503 |
\cs_new_protected:Npn \__xeCJK_bound_hbox_auxi: |
| 1504 |
{ |
| 1505 |
\box_set_to_last:N \l__xeCJK_tmp_box |
| 1506 |
\hbox_set:Nn \l__xeCJK_indent_box |
| 1507 |
{ |
| 1508 |
\box_use:N \l__xeCJK_tmp_box |
| 1509 |
\hbox_unpack:N \l__xeCJK_indent_box |
| 1510 |
} |
| 1511 |
} |
| 1512 |
\cs_new_protected:Npn \__xeCJK_bound_hbox_auxii:nn |
| 1513 |
{ |
| 1514 |
\dim_compare:nNnTF |
| 1515 |
{ \box_ht:N \l__xeCJK_tmp_box } = \c_zero_dim |
| 1516 |
{ \use_i:nn } |
| 1517 |
{ \use:nn } |
| 1518 |
} |
| 1519 |
\box_new:N \l__xeCJK_indent_box |
| 1520 |
\cs_new_protected:cpn { __xeCJK_bound_type_ 11 _glue:Nn } #1#2 |
| 1521 |
{ |
| 1522 |
\skip_if_finite:nTF { \tex_lastskip:D } |
| 1523 |
{ \__xeCJK_bound_glue_auxi:Nn #1 {#2} } |
| 1524 |
{ \__xeCJK_zero_glue: } |
| 1525 |
} |
| 1526 |
\cs_new_protected:Npn \__xeCJK_bound_glue_auxi:Nn #1#2 |
| 1527 |
{ |
| 1528 |
\__xeCJK_if_last_punct_glue:TF |
| 1529 |
{ \xeCJK_punct_bound_kern:N #1 } |
| 1530 |
{ \__xeCJK_bound_glue_auxii:n {#2} } |
| 1531 |
} |
| 1532 |
\cs_new_protected:Npn \__xeCJK_bound_glue_auxii:n #1 |
| 1533 |
{ |
| 1534 |
\skip_set_eq:NN \l__xeCJK_last_skip \tex_lastskip:D |
| 1535 |
\skip_if_eq:nnTF { \l__xeCJK_last_skip } { 1sp } |
| 1536 |
{ \__xeCJK_zero_glue: } |
| 1537 |
{ |
| 1538 |
\skip_if_eq:nnTF { \l__xeCJK_last_skip } { \labelsep } |
| 1539 |
{ |
| 1540 |
\tex_unskip:D |
| 1541 |
\__xeCJK_if_last_penalty:TF |
| 1542 |
{ |
| 1543 |
\int_compare:nNnTF \tex_lastpenalty:D = \c_zero_int |
| 1544 |
{ \skip_horizontal:N \l__xeCJK_last_skip } |
| 1545 |
{ \skip_horizontal:N \l__xeCJK_last_skip #1 } |
| 1546 |
} |
| 1547 |
{ \skip_horizontal:N \l__xeCJK_last_skip #1 } |
| 1548 |
} |
| 1549 |
{#1} |
| 1550 |
} |
| 1551 |
} |
| 1552 |
\cs_new_protected:cpn { __xeCJK_bound_type_ 12 _glue:Nn } #1#2 |
| 1553 |
{ |
| 1554 |
\xeCJK_if_last_node:nF { CJK } |
| 1555 |
{ \xeCJK_if_last_node:nF { CJK-space } { \use_none:nn } } |
| 1556 |
\xeCJK_remove_node: \CJKglue |
| 1557 |
#2 |
| 1558 |
} |
| 1559 |
\cs_new_protected:cpn { __xeCJK_bound_type_ 13 _glue:Nn } #1#2 |
| 1560 |
{ |
| 1561 |
\__xeCJK_if_last_punct_penalty:TF |
| 1562 |
{ \xeCJK_punct_bound_kern:N #1 } |
| 1563 |
{ |
| 1564 |
\int_compare:nNnTF \tex_lastpenalty:D = \c_zero_int |
| 1565 |
{ |
| 1566 |
\tex_unpenalty:D |
| 1567 |
\__xeCJK_if_last_hlist:TF |
| 1568 |
{ \tex_penalty:D \c_zero_int } |
| 1569 |
{ \tex_penalty:D \c_zero_int #2 } |
| 1570 |
} |
| 1571 |
{#2} |
| 1572 |
} |
| 1573 |
} |
| 1574 |
\cs_new_protected:Npn \xeCJK_Default_and_FullRight:nN #1#2 |
| 1575 |
{ |
| 1576 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_right_tl #2 |
| 1577 |
\__xeCJK_Default_and_FullRight_glue:N #2 |
| 1578 |
\xeCJK_class_group_begin: |
| 1579 |
\xeCJK_select_punct_font: |
| 1580 |
\xeCJK_clear_inter_class_toks:nn {#1} { FullRight } |
| 1581 |
\xeCJK_clear_Boundary_and_CJK_toks: |
| 1582 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#2} |
| 1583 |
\xeCJK_FullRight_symbol:N #2 |
| 1584 |
} |
| 1585 |
\cs_new_protected:Npn \xeCJK_Boundary_and_FullRight:N #1 |
| 1586 |
{ |
| 1587 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_right_tl #1 |
| 1588 |
\xeCJK_if_last_punct:TF |
| 1589 |
{ |
| 1590 |
\tl_set_eq:NN \l__xeCJK_alignii_tl \c__xeCJK_right_tl |
| 1591 |
\xeCJK_punct_bound_kern:N |
| 1592 |
} |
| 1593 |
{ \__xeCJK_Default_and_FullRight_glue:N } |
| 1594 |
#1 |
| 1595 |
\xeCJK_class_group_begin: |
| 1596 |
\xeCJK_select_punct_font: |
| 1597 |
\xeCJK_clear_Boundary_and_CJK_toks: |
| 1598 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#1} |
| 1599 |
\xeCJK_FullRight_symbol:N #1 |
| 1600 |
} |
| 1601 |
\cs_new_protected:Npn \xeCJK_CJK_and_FullRight:N #1 |
| 1602 |
{ |
| 1603 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_right_tl #1 |
| 1604 |
\__xeCJK_CJK_and_FullRight_glue:N #1 |
| 1605 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#1} |
| 1606 |
\__xeCJK_select_punct_font: |
| 1607 |
\xeCJK_FullRight_symbol:N #1 |
| 1608 |
} |
| 1609 |
\cs_new_protected:Npn \xeCJK_if_last_punct:TF |
| 1610 |
{ |
| 1611 |
\bool_set_false:N \l__xeCJK_last_penalty_bool |
| 1612 |
\__xeCJK_if_last_glue:TF |
| 1613 |
{ \__xeCJK_if_last_punct_glue:TF } |
| 1614 |
{ |
| 1615 |
\__xeCJK_if_last_penalty:TF |
| 1616 |
{ \__xeCJK_if_last_punct_penalty:TF } |
| 1617 |
{ \use_ii:nn } |
| 1618 |
} |
| 1619 |
} |
| 1620 |
\cs_new_protected:Npn \__xeCJK_if_last_punct_glue:TF |
| 1621 |
{ |
| 1622 |
\prop_get:NoNTF \g__xeCJK_punct_skip_prop |
| 1623 |
{ \skip_use:N \tex_lastskip:D } \l__xeCJK_tmp_tl |
| 1624 |
{ \__xeCJK_if_last_punct_glue_auxi:TF } |
| 1625 |
{ \__xeCJK_if_last_punct_glue_auxii:TF } |
| 1626 |
} |
| 1627 |
\cs_new_protected:Npn \__xeCJK_if_last_punct_glue_auxi:TF |
| 1628 |
{ |
| 1629 |
\skip_set_eq:NN \l__xeCJK_last_skip \tex_lastskip:D |
| 1630 |
\tex_unskip:D |
| 1631 |
\int_compare:nNnTF \tex_lastpenalty:D = \c__xeCJK_nobreak_penalty_int |
| 1632 |
{ \__xeCJK_if_last_punct_auxi:TF { \use_i:nn } } |
| 1633 |
{ |
| 1634 |
\xeCJK_if_last_node:TF |
| 1635 |
{ \__xeCJK_if_last_punct_auxii:TF { \use_i:nn } } |
| 1636 |
{ \use:n } |
| 1637 |
} |
| 1638 |
{ \skip_horizontal:N \l__xeCJK_last_skip \use_ii:nn } |
| 1639 |
} |
| 1640 |
\cs_new_protected:Npn \__xeCJK_if_last_punct_glue_auxii:TF |
| 1641 |
{ |
| 1642 |
\group_begin: |
| 1643 |
\g__xeCJK_space_factor_int \tex_spacefactor:D |
| 1644 |
\skip_if_eq:nnTF { \tex_lastskip:D } { \c_xeCJK_space_skip_tl } |
| 1645 |
{ \group_end: \__xeCJK_if_last_punct_glue_auxiii:TF } |
| 1646 |
{ \group_end: \use_ii:nn } |
| 1647 |
} |
| 1648 |
\cs_new_protected:Npn \__xeCJK_if_last_punct_glue_auxiii:TF |
| 1649 |
{ |
| 1650 |
\skip_set_eq:NN \l__xeCJK_tmp_skip \tex_lastskip:D |
| 1651 |
\tex_unskip:D |
| 1652 |
\__xeCJK_if_last_glue:TF |
| 1653 |
{ |
| 1654 |
\prop_get:NoNTF \g__xeCJK_punct_skip_prop |
| 1655 |
{ \skip_use:N \tex_lastskip:D } \l__xeCJK_tmp_tl |
| 1656 |
{ \__xeCJK_if_last_punct_glue_auxi:TF { \use_i:nn } } |
| 1657 |
{ \use:n } |
| 1658 |
} |
| 1659 |
{ \use:n } |
| 1660 |
{ \skip_horizontal:N \l__xeCJK_tmp_skip \use_ii:nn } |
| 1661 |
} |
| 1662 |
\cs_new_protected:Npn \__xeCJK_if_last_punct_penalty:TF |
| 1663 |
{ |
| 1664 |
\int_set_eq:NN \l__xeCJK_last_penalty_int \tex_lastpenalty:D |
| 1665 |
\tex_unpenalty:D |
| 1666 |
\bool_set_true:N \l__xeCJK_last_penalty_bool |
| 1667 |
\__xeCJK_if_last_glue:TF |
| 1668 |
{ \__xeCJK_if_last_punct_glue:TF { \use_i:nn } } |
| 1669 |
{ \use:n } |
| 1670 |
{ \__xeCJK_last_punct_penalty_false:nn } |
| 1671 |
} |
| 1672 |
\cs_new_protected:Npn \__xeCJK_last_punct_penalty_false:nn #1#2 |
| 1673 |
{ |
| 1674 |
\bool_set_false:N \l__xeCJK_last_penalty_bool |
| 1675 |
\tex_penalty:D \l__xeCJK_last_penalty_int |
| 1676 |
#2 |
| 1677 |
} |
| 1678 |
\cs_new_protected:Npn \__xeCJK_if_last_punct_auxi:TF |
| 1679 |
{ |
| 1680 |
\tex_unpenalty:D |
| 1681 |
\bool_if:NF \l__xeCJK_last_penalty_bool |
| 1682 |
{ |
| 1683 |
\bool_set_true:N \l__xeCJK_last_penalty_bool |
| 1684 |
\int_set_eq:NN \l__xeCJK_last_penalty_int \c__xeCJK_nobreak_penalty_int |
| 1685 |
} |
| 1686 |
\xeCJK_if_last_node:TF |
| 1687 |
{ \__xeCJK_if_last_punct_auxii:TF { \use_i:nn } } |
| 1688 |
{ \use:n } |
| 1689 |
{ \xeCJK_no_break: \use_ii:nn } |
| 1690 |
} |
| 1691 |
\cs_new_protected:Npn \__xeCJK_if_last_punct_auxii:TF |
| 1692 |
{ |
| 1693 |
\dim_compare:nNnTF \l__xeCJK_last_kern_dim > \c_zero_dim |
| 1694 |
{ \__xeCJK_if_last_punct_auxiii:TF } |
| 1695 |
{ \__xeCJK_make_node:N \l__xeCJK_last_kern_dim \use_ii:nn } |
| 1696 |
} |
| 1697 |
\cs_new_protected:Npn \__xeCJK_if_last_punct_auxiii:TF |
| 1698 |
{ |
| 1699 |
\int_case:nnTF { \tex_XeTeXcharclass:D \l__xeCJK_last_kern_dim } |
| 1700 |
{ |
| 1701 |
{ \xeCJK_class_num:n { FullRight } } |
| 1702 |
{ \tl_set_eq:NN \l__xeCJK_aligni_tl \c__xeCJK_right_tl } |
| 1703 |
{ \xeCJK_class_num:n { FullLeft } } |
| 1704 |
{ \tl_set_eq:NN \l__xeCJK_aligni_tl \c__xeCJK_left_tl } |
| 1705 |
} |
| 1706 |
{ \__xeCJK_if_last_punct_auxiv:TF } |
| 1707 |
{ \use_ii:nn } |
| 1708 |
} |
| 1709 |
\cs_new_protected:Npn \__xeCJK_if_last_punct_auxiv:TF |
| 1710 |
{ |
| 1711 |
\dim_set_eq:NN \l__xeCJK_tmp_dim \l__xeCJK_last_kern_dim |
| 1712 |
\xeCJK_if_last_node:TF |
| 1713 |
{ |
| 1714 |
\tl_gset:Nx \g__xeCJK_last_punct_tl |
| 1715 |
{ \tex_Uchar:D \l__xeCJK_tmp_dim } |
| 1716 |
\dim_set_eq:NN \l__xeCJK_last_bound_dim \l__xeCJK_last_kern_dim |
| 1717 |
\use_i:nn |
| 1718 |
} |
| 1719 |
{ \__xeCJK_make_node:N \l__xeCJK_tmp_dim \use_ii:nn } |
| 1720 |
} |
| 1721 |
\tl_new:N \l__xeCJK_aligni_tl |
| 1722 |
\tl_new:N \l__xeCJK_alignii_tl |
| 1723 |
\int_new:N \l__xeCJK_last_penalty_int |
| 1724 |
\dim_new:N \l__xeCJK_last_bound_dim |
| 1725 |
\bool_new:N \l__xeCJK_last_penalty_bool |
| 1726 |
\cs_new_protected:Npn \xeCJK_if_last_node:TF #1#2 |
| 1727 |
{ |
| 1728 |
\__xeCJK_if_last_kern:TF |
| 1729 |
{ |
| 1730 |
\dim_set_eq:NN \l__xeCJK_last_kern_dim \tex_lastkern:D |
| 1731 |
\tex_unkern:D |
| 1732 |
\__xeCJK_if_last_kern:TF |
| 1733 |
{ |
| 1734 |
\dim_compare:nNnTF \tex_lastkern:D = { - \l__xeCJK_last_kern_dim } |
| 1735 |
{ \tex_unkern:D #1 } |
| 1736 |
{ \tex_kern:D \l__xeCJK_last_kern_dim #2 } |
| 1737 |
} |
| 1738 |
{ \tex_kern:D \l__xeCJK_last_kern_dim #2 } |
| 1739 |
} |
| 1740 |
{#2} |
| 1741 |
} |
| 1742 |
\dim_new:N \l__xeCJK_last_kern_dim |
| 1743 |
\cs_new_protected:Npn \__xeCJK_CJK_and_FullRight_glue:N #1 |
| 1744 |
{ |
| 1745 |
\__xeCJK_punct_if_long:NTF #1 |
| 1746 |
{ \xeCJK_allow_break: } |
| 1747 |
{ \xeCJK_no_break: } |
| 1748 |
\__xeCJK_punct_if_middle:NT #1 |
| 1749 |
{ |
| 1750 |
\CJKglue |
| 1751 |
\__xeCJK_punct_glue:NN \c__xeCJK_right_tl #1 |
| 1752 |
\__xeCJK_punct_rule:NN \c__xeCJK_left_tl #1 |
| 1753 |
} |
| 1754 |
} |
| 1755 |
\cs_new_protected:Npn \__xeCJK_Default_and_FullRight_glue:N #1 |
| 1756 |
{ |
| 1757 |
\__xeCJK_punct_if_long:NTF #1 |
| 1758 |
{ \xeCJK_allow_break: } |
| 1759 |
{ \xeCJK_no_break: } |
| 1760 |
\__xeCJK_punct_if_middle:NT #1 |
| 1761 |
{ |
| 1762 |
\__xeCJK_punct_glue:NN \c__xeCJK_right_tl #1 |
| 1763 |
\__xeCJK_punct_rule:NN \c__xeCJK_left_tl #1 |
| 1764 |
} |
| 1765 |
} |
| 1766 |
\cs_new_protected:Npn \xeCJK_FullLeft_and_FullLeft:N #1 |
| 1767 |
{ |
| 1768 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_left_tl #1 |
| 1769 |
\xeCJK_get_punct_kerning:oN \g__xeCJK_last_punct_tl #1 |
| 1770 |
\__xeCJK_punct_kern:NN \g__xeCJK_last_punct_tl #1 |
| 1771 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#1} |
| 1772 |
\xeCJK_fallback_punct_symbol:NN |
| 1773 |
\CJKpunctsymbol #1 |
| 1774 |
} |
| 1775 |
\cs_new_protected:Npn \xeCJK_FullLeft_and_FullRight:N #1 |
| 1776 |
{ |
| 1777 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_right_tl #1 |
| 1778 |
\xeCJK_get_punct_kerning:oN \g__xeCJK_last_punct_tl #1 |
| 1779 |
\__xeCJK_punct_kern:NN \g__xeCJK_last_punct_tl #1 |
| 1780 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#1} |
| 1781 |
\xeCJK_FullRight_symbol:N #1 |
| 1782 |
} |
| 1783 |
\cs_new_protected:Npn \xeCJK_FullRight_and_FullLeft:N #1 |
| 1784 |
{ |
| 1785 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_left_tl #1 |
| 1786 |
\xeCJK_get_punct_kerning:oN \g__xeCJK_last_punct_tl #1 |
| 1787 |
\xeCJK_punct_kern:NN \g__xeCJK_last_punct_tl #1 |
| 1788 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#1} |
| 1789 |
\xeCJK_fallback_punct_symbol:NN |
| 1790 |
\CJKpunctsymbol #1 |
| 1791 |
} |
| 1792 |
\cs_new_protected:Npn \xeCJK_FullRight_and_FullRight:N #1 |
| 1793 |
{ |
| 1794 |
\xeCJK_get_punct_bounds:NN \c__xeCJK_right_tl #1 |
| 1795 |
\xeCJK_get_punct_kerning:oN \g__xeCJK_last_punct_tl #1 |
| 1796 |
\__xeCJK_punct_kern:NN \g__xeCJK_last_punct_tl #1 |
| 1797 |
\tl_gset:Nn \g__xeCJK_last_punct_tl {#1} |
| 1798 |
\xeCJK_FullRight_symbol:N #1 |
| 1799 |
} |
| 1800 |
\keys_define:nn { xeCJK / options } |
| 1801 |
{ |
| 1802 |
CheckFullRight .choice: , |
| 1803 |
CheckFullRight / true .code:n = |
| 1804 |
{ |
| 1805 |
\cs_if_eq:NNF \xeCJK_FullRight_and_Boundary: \xeCJK_check_FullRight: |
| 1806 |
{ |
| 1807 |
\cs_set_eq:NN \__xeCJK_save_FullRight_check: |
| 1808 |
\xeCJK_FullRight_and_Boundary: |
| 1809 |
\cs_set_eq:NN \__xeCJK_save_FullRight_symbol:N |
| 1810 |
\xeCJK_FullRight_symbol:N |
| 1811 |
\cs_set_eq:NN \xeCJK_FullRight_and_Boundary: |
| 1812 |
\xeCJK_check_FullRight: |
| 1813 |
\cs_set_eq:NN \xeCJK_FullRight_symbol:N |
| 1814 |
\xeCJK_check_FullRight_symbol:Nw |
| 1815 |
} |
| 1816 |
} , |
| 1817 |
CheckFullRight / false .code:n = |
| 1818 |
{ |
| 1819 |
\cs_if_eq:NNT \xeCJK_FullRight_and_Boundary: \xeCJK_check_FullRight: |
| 1820 |
{ |
| 1821 |
\cs_set_eq:NN \xeCJK_FullRight_and_Boundary: |
| 1822 |
\__xeCJK_save_FullRight_check: |
| 1823 |
\cs_set_eq:NN \xeCJK_FullRight_symbol:N |
| 1824 |
\__xeCJK_save_FullRight_symbol:N |
| 1825 |
} |
| 1826 |
} , |
| 1827 |
CheckFullRight .default:n = { true } |
| 1828 |
} |
| 1829 |
\cs_new_protected:Npn \xeCJK_FullRight_symbol:N |
| 1830 |
{ |
| 1831 |
\xeCJK_fallback_punct_symbol:NN |
| 1832 |
\CJKpunctsymbol |
| 1833 |
} |
| 1834 |
\cs_new_protected:Npn \xeCJK_check_FullRight: |
| 1835 |
{ |
| 1836 |
\xeCJK_get_punct_bounds:No \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1837 |
\__xeCJK_punct_rule:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1838 |
\group_align_safe_begin: |
| 1839 |
\token_case_meaning:NoTF \l_peek_token |
| 1840 |
{ \l__xeCJK_no_break_cs_case_tl } |
| 1841 |
{ |
| 1842 |
\group_align_safe_end: |
| 1843 |
\xeCJK_no_break: |
| 1844 |
\group_insert_after:N \xeCJK_no_break: |
| 1845 |
} |
| 1846 |
{ \group_align_safe_end: } |
| 1847 |
\exp_after:wN \xeCJK_punct_node:N \g__xeCJK_last_punct_tl |
| 1848 |
\xeCJK_class_group_end: |
| 1849 |
\__xeCJK_punct_glue:NN \c__xeCJK_right_tl \g__xeCJK_last_punct_tl |
| 1850 |
} |
| 1851 |
\prg_generate_conditional_variant:Nnn \token_case_meaning:Nn { No } { TF , F } |
| 1852 |
\cs_new_protected:Npn \xeCJK_check_FullRight_symbol:Nw #1 |
| 1853 |
{ \peek_remove_spaces:n { \__xeCJK_save_FullRight_symbol:N #1 } } |
| 1854 |
\cs_new_protected:Npn \xeCJK_cs_case_keys_define:nNNnn #1#2#3#4#5 |
| 1855 |
{ |
| 1856 |
\tl_new:N #2 |
| 1857 |
\seq_new:N #3 |
| 1858 |
\keys_define:nn { xeCJK / options } |
| 1859 |
{ |
| 1860 |
#1 .code:n = |
| 1861 |
{ |
| 1862 |
\seq_set_split:Nnn #3 { } {##1} |
| 1863 |
\__xeCJK_update_cs_case_tl:NNnn #2#3 {#4} {#5} |
| 1864 |
} , |
| 1865 |
#1+ .code:n = |
| 1866 |
{ |
| 1867 |
\tl_map_inline:nn {##1} |
| 1868 |
{ \seq_if_in:NnF #3 {####1} { \seq_put_right:Nn #3 {####1} } } |
| 1869 |
\__xeCJK_update_cs_case_tl:NNnn #2#3 {#4} {#5} |
| 1870 |
} , |
| 1871 |
#1- .code:n = |
| 1872 |
{ |
| 1873 |
\tl_map_inline:nn {##1} { \seq_remove_all:Nn #3 {####1} } |
| 1874 |
\__xeCJK_update_cs_case_tl:NNnn #2#3 {#4} {#5} |
| 1875 |
} |
| 1876 |
} |
| 1877 |
} |
| 1878 |
\cs_new_protected:Npn \__xeCJK_update_cs_case_tl:NNnn #1#2#3#4 |
| 1879 |
{ |
| 1880 |
\tl_clear:N #1 |
| 1881 |
\seq_map_inline:Nn #2 { \tl_put_right:Nn #1 { {##1} {#3} } } |
| 1882 |
#4 |
| 1883 |
} |
| 1884 |
\xeCJK_cs_case_keys_define:nNNnn { NoBreakCS } |
| 1885 |
\l__xeCJK_no_break_cs_case_tl \l__xeCJK_no_break_cs_seq { } { } |
| 1886 |
\NewDocumentCommand \xeCJKnobreak { } |
| 1887 |
{ |
| 1888 |
\bool_set_true:N \l__xeCJK_tmp_bool |
| 1889 |
\int_while_do:nNnn \tex_lastnodetype:D = \c__xeCJK_glue_node |
| 1890 |
{ |
| 1891 |
\bool_if:NTF \l__xeCJK_tmp_bool |
| 1892 |
{ |
| 1893 |
\bool_set_false:N \l__xeCJK_tmp_bool |
| 1894 |
\skip_set_eq:NN \l__xeCJK_last_skip \tex_lastskip:D |
| 1895 |
} |
| 1896 |
{ \skip_add:Nn \l__xeCJK_last_skip \tex_lastskip:D } |
| 1897 |
\tex_unskip:D |
| 1898 |
} |
| 1899 |
\xeCJK_if_last_node:TF |
| 1900 |
{ |
| 1901 |
\dim_set_eq:NN \l__xeCJK_tmp_dim \l__xeCJK_last_kern_dim |
| 1902 |
\xeCJK_if_last_node:TF |
| 1903 |
{ |
| 1904 |
\__xeCJK_if_last_glue:TF |
| 1905 |
{ |
| 1906 |
\exp_args:NNNo \tex_unskip:D \xeCJK_no_break: |
| 1907 |
\skip_horizontal:n { \skip_use:N \tex_lastskip:D } |
| 1908 |
} |
| 1909 |
\__xeCJK_make_node:N \l__xeCJK_last_kern_dim |
| 1910 |
} |
| 1911 |
{ } |
| 1912 |
\__xeCJK_make_node:N \l__xeCJK_tmp_dim |
| 1913 |
} |
| 1914 |
{ } |
| 1915 |
\xeCJK_no_break: |
| 1916 |
\bool_if:NF \l__xeCJK_tmp_bool |
| 1917 |
{ \skip_horizontal:N \l__xeCJK_last_skip } |
| 1918 |
} |
| 1919 |
\keys_define:nn { xeCJK / options } |
| 1920 |
{ |
| 1921 |
CheckSingle .choice: , |
| 1922 |
CheckSingle / true .code:n = |
| 1923 |
{ |
| 1924 |
\cs_if_eq:NNF \xeCJK_CJK_and_CJK:N \xeCJK_check_single:Nw |
| 1925 |
{ |
| 1926 |
\cs_set_eq:NN \__xeCJK_check_single_save:N \xeCJK_CJK_and_CJK:N |
| 1927 |
\cs_set_eq:NN \xeCJK_CJK_and_CJK:N \xeCJK_check_single:Nw |
| 1928 |
} |
| 1929 |
} , |
| 1930 |
CheckSingle / false .code:n = |
| 1931 |
{ |
| 1932 |
\cs_if_eq:NNT \xeCJK_CJK_and_CJK:N \xeCJK_check_single:Nw |
| 1933 |
{ \cs_set_eq:NN \xeCJK_CJK_and_CJK:N \__xeCJK_check_single_save:N } |
| 1934 |
} , |
| 1935 |
CheckSingle .default:n = { true } , |
| 1936 |
CJKchecksingle .meta:n = { CheckSingle = true } |
| 1937 |
} |
| 1938 |
\keys_define:nn { xeCJK / options } |
| 1939 |
{ |
| 1940 |
WidowPenalty .int_set:N = \l__xeCJK_widow_penalty_int , |
| 1941 |
WidowPenalty .default:n = { 10 000 } |
| 1942 |
} |
| 1943 |
\cs_new_protected:Npn \xeCJK_widow_penalty: |
| 1944 |
{ \tex_penalty:D \l__xeCJK_widow_penalty_int } |
| 1945 |
\cs_new_protected:Npn \xeCJK_check_single:Nw #1 |
| 1946 |
{ |
| 1947 |
\group_align_safe_begin: |
| 1948 |
\peek_catcode:NTF \c_catcode_letter_token |
| 1949 |
{ \xeCJK_check_single:NNw #1 } |
| 1950 |
{ |
| 1951 |
\token_if_other:NTF \l_peek_token |
| 1952 |
{ \xeCJK_check_single:NNw } |
| 1953 |
{ \__xeCJK_check_single_end:N } |
| 1954 |
#1 |
| 1955 |
} |
| 1956 |
} |
| 1957 |
\cs_new_protected:Npn \__xeCJK_check_single_end:N |
| 1958 |
{ |
| 1959 |
\group_align_safe_end: |
| 1960 |
\__xeCJK_check_single_save:N |
| 1961 |
} |
| 1962 |
\cs_new_protected:Npn \xeCJK_check_single:NNw #1#2 |
| 1963 |
{ |
| 1964 |
\xeCJK_peek_catcode_ignore_spaces:NTF \c_catcode_letter_token |
| 1965 |
{ |
| 1966 |
\bool_if:NTF \l__xeCJK_peek_ignore_spaces_bool |
| 1967 |
{ |
| 1968 |
\bool_if:NTF \l__xeCJK_reserve_space_bool |
| 1969 |
{ \__xeCJK_check_single_end:N #1 #2 ~ } |
| 1970 |
{ \__xeCJK_check_single_space:NN #1#2 } |
| 1971 |
} |
| 1972 |
{ \__xeCJK_check_single_end:N #1 #2 } |
| 1973 |
} |
| 1974 |
{ |
| 1975 |
\token_if_other:NTF \l_peek_token |
| 1976 |
{ |
| 1977 |
\bool_if:NTF \l__xeCJK_peek_ignore_spaces_bool |
| 1978 |
{ \__xeCJK_check_single_space:NN } |
| 1979 |
{ \__xeCJK_check_single_end:N } |
| 1980 |
} |
| 1981 |
{ |
| 1982 |
\bool_if:NTF \l__xeCJK_peek_ignore_spaces_bool |
| 1983 |
{ \__xeCJK_check_single_aux:nNNw { ~ } } |
| 1984 |
{ \__xeCJK_check_single_aux:nNNw { } } |
| 1985 |
} |
| 1986 |
#1 #2 |
| 1987 |
} |
| 1988 |
} |
| 1989 |
\cs_new_protected:Npn \__xeCJK_check_single_aux:nNNw #1#2#3 |
| 1990 |
{ |
| 1991 |
\token_if_cs:NTF \l_peek_token |
| 1992 |
{ \xeCJK_check_single_cs:NNn } |
| 1993 |
{ \xeCJK_check_single_end:NNnw } |
| 1994 |
#2 #3 {#1} |
| 1995 |
} |
| 1996 |
\cs_new_protected:Npn \__xeCJK_check_single_end_aux:NNn #1#2#3 |
| 1997 |
{ \__xeCJK_check_single_end:N #1 #2 #3 } |
| 1998 |
\cs_new_eq:NN \xeCJK_check_single_end:NNnw \__xeCJK_check_single_end_aux:NNn |
| 1999 |
\cs_new_protected:Npn \__xeCJK_check_single_end_equation:NNnw |
| 2000 |
{ |
| 2001 |
\token_if_math_toggle:NTF \l_peek_token |
| 2002 |
{ \xeCJK_check_single_equation:NNnNw } |
| 2003 |
{ \__xeCJK_check_single_end_aux:NNn } |
| 2004 |
} |
| 2005 |
\keys_define:nn { xeCJK / options } |
| 2006 |
{ |
| 2007 |
PlainEquation .choice: , |
| 2008 |
PlainEquation / true .code:n = |
| 2009 |
{ |
| 2010 |
\cs_set_eq:NN \xeCJK_check_single_end:NNnw |
| 2011 |
\__xeCJK_check_single_end_equation:NNnw |
| 2012 |
} , |
| 2013 |
PlainEquation / false .code:n = |
| 2014 |
{ |
| 2015 |
\cs_set_eq:NN \xeCJK_check_single_end:NNnw |
| 2016 |
\__xeCJK_check_single_end_aux:NNn |
| 2017 |
} , |
| 2018 |
PlainEquation .default:n = { true } , |
| 2019 |
} |
| 2020 |
\cs_new_protected:Npn \__xeCJK_check_single_space:NN #1#2 |
| 2021 |
{ |
| 2022 |
\xeCJK_if_CJK_class:NTF #2 |
| 2023 |
{ |
| 2024 |
\xeCJK_if_CJK_class:NTF \l_peek_token |
| 2025 |
{ \__xeCJK_check_single_end:N #1 #2 } |
| 2026 |
{ \__xeCJK_check_single_end:N #1 #2 ~ } |
| 2027 |
} |
| 2028 |
{ \__xeCJK_check_single_end:N #1 #2 ~ } |
| 2029 |
} |
| 2030 |
\cs_new_protected:Npn \xeCJK_check_single_equation:NNnNw #1#2#3#4 |
| 2031 |
{ |
| 2032 |
\peek_catcode:NTF \c_math_toggle_token |
| 2033 |
{ |
| 2034 |
\xeCJK_widow_penalty: \__xeCJK_check_single_end:N #1 |
| 2035 |
\xeCJK_make_node:n { CJK-widow } #2 #4 |
| 2036 |
} |
| 2037 |
{ \__xeCJK_check_single_end:N #1 #2#3#4 } |
| 2038 |
} |
| 2039 |
\cs_new_protected:Npn \xeCJK_check_single_cs:NNn #1#2#3 |
| 2040 |
{ |
| 2041 |
\token_case_meaning:NoF \l_peek_token |
| 2042 |
{ \l__xeCJK_check_single_cs_case_tl } |
| 2043 |
{ \use_iii:nnn } |
| 2044 |
{ \xeCJK_check_single_env:nnNn } |
| 2045 |
{ |
| 2046 |
\xeCJK_widow_penalty: |
| 2047 |
\__xeCJK_check_single_end:N #1 |
| 2048 |
\xeCJK_make_node:n { CJK-widow } #2#3 |
| 2049 |
} |
| 2050 |
{ \__xeCJK_check_single_end:N #1 #2#3 } |
| 2051 |
} |
| 2052 |
\tl_new:N \l__xeCJK_check_single_cs_case_tl |
| 2053 |
\cs_new_protected:Npn \xeCJK_check_single_env:nnNn #1#2#3#4 |
| 2054 |
{ |
| 2055 |
\str_case_e:noTF {#4} |
| 2056 |
{ \l__xeCJK_inline_env_case_tl } |
| 2057 |
{#2} |
| 2058 |
{#1} |
| 2059 |
#3 {#4} |
| 2060 |
} |
| 2061 |
\prg_generate_conditional_variant:Nnn \str_case_e:nn { no } { TF } |
| 2062 |
\xeCJK_cs_case_keys_define:nNNnn { NewLineCS } |
| 2063 |
\l__xeCJK_new_line_cs_case_tl \l__xeCJK_new_line_cs_seq |
| 2064 |
{ \use_ii:nnn } |
| 2065 |
{ |
| 2066 |
\tl_concat:NNN \l__xeCJK_check_single_cs_case_tl |
| 2067 |
\l__xeCJK_new_line_cs_case_tl \l__xeCJK_env_cs_case_tl |
| 2068 |
} |
| 2069 |
\xeCJK_cs_case_keys_define:nNNnn { EnvCS } |
| 2070 |
\l__xeCJK_env_cs_case_tl \l__xeCJK_env_cs_seq |
| 2071 |
{ \use:n } |
| 2072 |
{ |
| 2073 |
\tl_concat:NNN \l__xeCJK_check_single_cs_case_tl |
| 2074 |
\l__xeCJK_new_line_cs_case_tl \l__xeCJK_env_cs_case_tl |
| 2075 |
} |
| 2076 |
\keys_define:nn { xeCJK / options } |
| 2077 |
{ |
| 2078 |
InlineEnv .code:n = |
| 2079 |
{ |
| 2080 |
\seq_set_from_clist:Nn \l__xeCJK_inline_env_seq {#1} |
| 2081 |
\__xeCJK_update_inline_env_case_tl: |
| 2082 |
} , |
| 2083 |
InlineEnv+ .code:n = |
| 2084 |
{ |
| 2085 |
\clist_map_inline:nn {#1} |
| 2086 |
{ |
| 2087 |
\seq_if_in:NnF \l__xeCJK_inline_env_seq {##1} |
| 2088 |
{ \seq_put_right:Nn \l__xeCJK_inline_env_seq {##1} } |
| 2089 |
} |
| 2090 |
\__xeCJK_update_inline_env_case_tl: |
| 2091 |
} , |
| 2092 |
InlineEnv- .code:n = |
| 2093 |
{ |
| 2094 |
\clist_map_inline:nn {#1} |
| 2095 |
{ \seq_remove_all:Nn \l__xeCJK_inline_env_seq {##1} } |
| 2096 |
\__xeCJK_update_inline_env_case_tl: |
| 2097 |
} |
| 2098 |
} |
| 2099 |
\seq_new:N \l__xeCJK_inline_env_seq |
| 2100 |
\cs_new_protected:Npn \__xeCJK_update_inline_env_case_tl: |
| 2101 |
{ |
| 2102 |
\tl_clear:N \l__xeCJK_inline_env_case_tl |
| 2103 |
\seq_map_inline:Nn \l__xeCJK_inline_env_seq |
| 2104 |
{ \tl_put_right:Nn \l__xeCJK_inline_env_case_tl { {##1} { } } } |
| 2105 |
} |
| 2106 |
\tl_new:N \l__xeCJK_inline_env_case_tl |
| 2107 |
\seq_new:N \g__xeCJK_CJK_sub_class_seq |
| 2108 |
\NewDocumentCommand \xeCJKDeclareSubCJKBlock |
| 2109 |
{ s > { \TrimSpaces } m m } |
| 2110 |
{ |
| 2111 |
\xeCJK_declare_sub_char_class:nen { CJK } {#2} {#3} |
| 2112 |
\IfBooleanT {#1} { \xeCJKResetPunctClass } |
| 2113 |
} |
| 2114 |
\@onlypreamble \xeCJKDeclareSubCJKBlock |
| 2115 |
\bool_new:N \l__xeCJK_sub_cancel_bool |
| 2116 |
\NewDocumentCommand \xeCJKCancelSubCJKBlock { s m } |
| 2117 |
{ |
| 2118 |
\bool_if:NF \l__xeCJK_sub_cancel_bool |
| 2119 |
{ |
| 2120 |
\bool_set_true:N \l__xeCJK_sub_cancel_bool |
| 2121 |
\__xeCJK_sub_restore_or_cancel:e {#2} |
| 2122 |
\IfBooleanT {#1} { \xeCJKResetPunctClass } |
| 2123 |
} |
| 2124 |
} |
| 2125 |
\NewDocumentCommand \xeCJKRestoreSubCJKBlock { s m } |
| 2126 |
{ |
| 2127 |
\bool_if:NT \l__xeCJK_sub_cancel_bool |
| 2128 |
{ |
| 2129 |
\bool_set_false:N \l__xeCJK_sub_cancel_bool |
| 2130 |
\__xeCJK_sub_restore_or_cancel:e {#2} |
| 2131 |
\IfBooleanT {#1} { \xeCJKResetPunctClass } |
| 2132 |
} |
| 2133 |
} |
| 2134 |
\cs_new_protected:Npn \__xeCJK_sub_restore_or_cancel:n #1 |
| 2135 |
{ |
| 2136 |
\clist_map_inline:nn {#1} |
| 2137 |
{ |
| 2138 |
\int_if_exist:cTF { \__xeCJK_class_csname:n { CJK/##1 } } |
| 2139 |
{ |
| 2140 |
\xeCJK_declare_char_class:nn |
| 2141 |
{ CJK \bool_if:NF \l__xeCJK_sub_cancel_bool { /##1 } } |
| 2142 |
{ \use:c { g__xeCJK_CJK/##1_range_clist } } |
| 2143 |
} |
| 2144 |
{ \__xeCJK_error:nx { SubBlock-undefined } {##1} } |
| 2145 |
} |
| 2146 |
} |
| 2147 |
\cs_generate_variant:Nn \__xeCJK_sub_restore_or_cancel:n { e } |
| 2148 |
\__xeCJK_msg_new:nn { SubBlock-undefined } |
| 2149 |
{ |
| 2150 |
The~CJK~sub~block~`#1'~is~undefined.\\\\ |
| 2151 |
Try~to~use~\token_to_str:N \xeCJKDeclareSubCJKBlock \ |
| 2152 |
to~declare~it. |
| 2153 |
} |
| 2154 |
\cs_new_protected:Npn \xeCJK_declare_sub_char_class:nnn #1#2#3 |
| 2155 |
{ |
| 2156 |
\int_if_exist:cF { \__xeCJK_class_csname:n { #1/#2 } } |
| 2157 |
{ |
| 2158 |
\xeCJK_new_class:n { #1/#2 } |
| 2159 |
\__xeCJK_set_sub_class_toks:nn {#1} {#2} |
| 2160 |
\xeCJK_new_sub_key:n {#2} |
| 2161 |
} |
| 2162 |
\xeCJK_declare_char_class:nn { #1/#2 } {#3} |
| 2163 |
} |
| 2164 |
\cs_generate_variant:Nn \xeCJK_declare_sub_char_class:nnn { ne } |
| 2165 |
\cs_new_protected:Npn \__xeCJK_set_sub_class_toks:nn #1#2 |
| 2166 |
{ |
| 2167 |
\seq_map_inline:Nn \g__xeCJK_base_class_seq |
| 2168 |
{ |
| 2169 |
\xeCJK_copy_inter_class_toks:nnnn { #1/#2 } {##1} {#1} {##1} |
| 2170 |
\xeCJK_copy_inter_class_toks:nnnn {##1} { #1/#2 } {##1} {#1} |
| 2171 |
\str_if_eq:nnTF {##1} { CJK } |
| 2172 |
{ |
| 2173 |
\xeCJK_pre_inter_class_toks:nnn {##1} { #1/#2 } |
| 2174 |
{ \__xeCJK_switch_font:nn {#1} {#2} } |
| 2175 |
} |
| 2176 |
{ |
| 2177 |
\xeCJK_replace_inter_class_toks:nnnn {##1} { #1/#2 } |
| 2178 |
{ \xeCJK_fallback_symbol:NN } |
| 2179 |
{ |
| 2180 |
\__xeCJK_switch_font:nn {#1} {#2} |
| 2181 |
\xeCJK_fallback_symbol:NN |
| 2182 |
} |
| 2183 |
} |
| 2184 |
} |
| 2185 |
\xeCJK_copy_inter_class_toks:nnnn { #1/#2 } { #1/#2 } {#1} {#1} |
| 2186 |
\seq_map_inline:Nn \g__xeCJK_CJK_sub_class_seq |
| 2187 |
{ |
| 2188 |
\xeCJK_copy_inter_class_toks:nnnn { #1/#2 } { #1/##1 } {#1} {#1} |
| 2189 |
\xeCJK_copy_inter_class_toks:nnnn { #1/##1 } { #1/#2 } {#1} {#1} |
| 2190 |
\xeCJK_pre_inter_class_toks:nnn { #1/#2 } { #1/##1 } |
| 2191 |
{ \__xeCJK_switch_font:nn {#2} {##1} } |
| 2192 |
\xeCJK_pre_inter_class_toks:nnn { #1/##1 } { #1/#2 } |
| 2193 |
{ \__xeCJK_switch_font:nn {##1} {#2} } |
| 2194 |
} |
| 2195 |
\seq_gput_right:Nn \g__xeCJK_CJK_sub_class_seq {#2} |
| 2196 |
\__xeCJK_save_CJK_class:n { #1/#2 } |
| 2197 |
\clist_map_inline:nn { CJK , FullLeft , FullRight , HangulJamo } |
| 2198 |
{ |
| 2199 |
\xeCJK_pre_inter_class_toks:nnn { #1/#2 } {##1} |
| 2200 |
{ \__xeCJK_switch_font:nn {#2} {#1} } |
| 2201 |
} |
| 2202 |
} |
| 2203 |
\cs_if_exist:NF \tex_XeTeXglyphbounds:D |
| 2204 |
{ |
| 2205 |
\__xeCJK_msg_new:nn { XeTeX-too-old } |
| 2206 |
{ |
| 2207 |
\token_to_str:N \tex_XeTeXglyphbounds:D \ is~not~defined.\\ |
| 2208 |
CJK~punctuation~kerning~will~not~be~available.\\\\ |
| 2209 |
You~have~to~update~XeTeX~to~the~version~0.9995.0~or~later. |
| 2210 |
} |
| 2211 |
\__xeCJK_error:n { XeTeX-too-old } |
| 2212 |
\AtEndOfPackage |
| 2213 |
{ |
| 2214 |
\keys_define:nn { xeCJK / options } |
| 2215 |
{ |
| 2216 |
PunctStyle .code:n = |
| 2217 |
{ \__xeCJK_error:nx { punct-style-unknown } {#1} } |
| 2218 |
} |
| 2219 |
\seq_gclear:N \g__xeCJK_punct_style_seq |
| 2220 |
\__xeCJK_set_punct_style:n { plain } |
| 2221 |
} |
| 2222 |
} |
| 2223 |
\NewDocumentCommand \xeCJKsetwidth { s m m } |
| 2224 |
{ |
| 2225 |
\IfBooleanTF {#1} |
| 2226 |
{ |
| 2227 |
\tl_map_inline:en {#2} |
| 2228 |
{ \tl_gset:cn { g__xeCJK_punct_bound_width/##1/tl } {#3} } |
| 2229 |
} |
| 2230 |
{ |
| 2231 |
\tl_map_inline:en {#2} |
| 2232 |
{ \tl_gset:cn { g__xeCJK_punct_width/##1/tl } {#3} } |
| 2233 |
} |
| 2234 |
} |
| 2235 |
\@onlypreamble \xeCJKsetwidth |
| 2236 |
\cs_generate_variant:Nn \tl_map_inline:nn { e } |
| 2237 |
\NewDocumentCommand \xeCJKsetkern { m m m } |
| 2238 |
{ \tl_gset:cn { g__xeCJK_punct/kern/#1/#2/tl } {#3} } |
| 2239 |
\@onlypreamble \xeCJKsetkern |
| 2240 |
\tl_const:Nn \c__xeCJK_left_tl { left } |
| 2241 |
\tl_const:Nn \c__xeCJK_right_tl { right } |
| 2242 |
\keys_define:nn { xeCJK / options } |
| 2243 |
{ |
| 2244 |
AllowBreakBetweenPuncts .choice: , |
| 2245 |
AllowBreakBetweenPuncts / true .code:n = |
| 2246 |
{ |
| 2247 |
\bool_set_true:N \l__xeCJK_punct_breakable_bool |
| 2248 |
\cs_set_eq:NN \xeCJK_punct_kern:NN \__xeCJK_punct_breakable_kern:NN |
| 2249 |
\cs_set_eq:NN \__xeCJK_punct_bound_kern:N |
| 2250 |
\__xeCJK_punct_bound_breakable_kern:N |
| 2251 |
} , |
| 2252 |
AllowBreakBetweenPuncts / false .code:n = |
| 2253 |
{ |
| 2254 |
\bool_set_false:N \l__xeCJK_punct_breakable_bool |
| 2255 |
\cs_set_eq:NN \xeCJK_punct_kern:NN \__xeCJK_punct_kern:NN |
| 2256 |
\cs_set_eq:NN \__xeCJK_punct_bound_kern:N |
| 2257 |
\__xeCJK_nobreak_hskip:N |
| 2258 |
} , |
| 2259 |
AllowBreakBetweenPuncts .default:n = { true } , |
| 2260 |
KaiMingPunct .code:n = { \__xeCJK_set_special_punct:nn { mixed_width } {#1} } , |
| 2261 |
KaiMingPunct+ .code:n = { \__xeCJK_add_special_punct:nn { mixed_width } {#1} } , |
| 2262 |
KaiMingPunct- .code:n = { \__xeCJK_sub_special_punct:nn { mixed_width } {#1} } , |
| 2263 |
LongPunct .code:n = { \__xeCJK_set_special_punct:nn { long } {#1} } , |
| 2264 |
LongPunct+ .code:n = { \__xeCJK_add_special_punct:nn { long } {#1} } , |
| 2265 |
LongPunct- .code:n = { \__xeCJK_sub_special_punct:nn { long } {#1} } , |
| 2266 |
MiddlePunct .code:n = { \__xeCJK_set_special_punct:nn { middle } {#1} } , |
| 2267 |
MiddlePunct+ .code:n = { \__xeCJK_add_special_punct:nn { middle } {#1} } , |
| 2268 |
MiddlePunct- .code:n = { \__xeCJK_sub_special_punct:nn { middle } {#1} } , |
| 2269 |
PunctWidth .tl_gset:N = \g__xeCJK_punct_width_tl , |
| 2270 |
PunctBoundWidth .tl_gset:N = \g__xeCJK_punct_bound_width_tl , |
| 2271 |
PunctWidth .value_required:n = true , |
| 2272 |
PunctBoundWidth .value_required:n = true , |
| 2273 |
RubberPunctSkip .choice: , |
| 2274 |
RubberPunctSkip .default:n = { true } , |
| 2275 |
RubberPunctSkip / true .code:n = |
| 2276 |
{ \cs_set_eq:NN \__xeCJK_use_dim_or_skip:nNN \__xeCJK_use_punct_skip:nNN } , |
| 2277 |
RubberPunctSkip / plus .code:n = |
| 2278 |
{ \cs_set_eq:NN \__xeCJK_use_dim_or_skip:nNN \__xeCJK_use_punct_skip_plus:nNN } , |
| 2279 |
RubberPunctSkip / minus .code:n = |
| 2280 |
{ \cs_set_eq:NN \__xeCJK_use_dim_or_skip:nNN \__xeCJK_use_punct_skip_minus:nNN } , |
| 2281 |
RubberPunctSkip / false .code:n = |
| 2282 |
{ \cs_set_eq:NN \__xeCJK_use_dim_or_skip:nNN \__xeCJK_use_punct_dim:nNN } |
| 2283 |
} |
| 2284 |
\bool_new:N \l__xeCJK_punct_breakable_bool |
| 2285 |
\clist_new:N \g__xeCJK_special_punct_clist |
| 2286 |
\clist_gset:Nn \g__xeCJK_special_punct_clist { mixed_width , long , middle } |
| 2287 |
\cs_new:Npn \__xeCJK_special_punct_seq:n #1 { g__xeCJK_special_punct_#1_seq } |
| 2288 |
\cs_new:Npn \__xeCJK_special_punct_tl:nN #1#2 { g__xeCJK_special_punct_#1_#2_tl } |
| 2289 |
\clist_map_inline:Nn \g__xeCJK_special_punct_clist |
| 2290 |
{ \seq_new:c { \__xeCJK_special_punct_seq:n {#1} } } |
| 2291 |
\cs_new_protected:Npn \__xeCJK_set_special_punct:nn #1#2 |
| 2292 |
{ |
| 2293 |
\seq_map_inline:cn { \__xeCJK_special_punct_seq:n {#1} } |
| 2294 |
{ \cs_undefine:c { \__xeCJK_special_punct_tl:nN {#1} {##1} } } |
| 2295 |
\seq_gclear:c { \__xeCJK_special_punct_seq:n {#1} } |
| 2296 |
\tl_map_inline:en {#2} |
| 2297 |
{ |
| 2298 |
\tl_new:c { \__xeCJK_special_punct_tl:nN {#1} {##1} } |
| 2299 |
\seq_gput_right:cn { \__xeCJK_special_punct_seq:n {#1} } {##1} |
| 2300 |
} |
| 2301 |
} |
| 2302 |
\cs_new_protected:Npn \__xeCJK_add_special_punct:nn #1#2 |
| 2303 |
{ |
| 2304 |
\tl_map_inline:en {#2} |
| 2305 |
{ |
| 2306 |
\seq_if_in:cnF { \__xeCJK_special_punct_seq:n {#1} } {##1} |
| 2307 |
{ |
| 2308 |
\tl_new:c { \__xeCJK_special_punct_tl:nN {#1} {##1} } |
| 2309 |
\seq_gput_right:cn { \__xeCJK_special_punct_seq:n {#1} } {##1} |
| 2310 |
} |
| 2311 |
} |
| 2312 |
} |
| 2313 |
\cs_new_protected:Npn \__xeCJK_sub_special_punct:nn #1#2 |
| 2314 |
{ |
| 2315 |
\tl_map_inline:en {#2} |
| 2316 |
{ |
| 2317 |
\cs_undefine:c { \__xeCJK_special_punct_tl:nN {#1} {##1} } |
| 2318 |
\seq_gremove_all:cn { \__xeCJK_special_punct_seq:n {#1} } {##1} |
| 2319 |
} |
| 2320 |
} |
| 2321 |
\prg_new_conditional:Npnn \__xeCJK_punct_if_right:N #1 { p , T , F , TF } |
| 2322 |
{ |
| 2323 |
\if_int_compare:w \xeCJK_token_value_class:N #1 = |
| 2324 |
\xeCJK_class_num:n { FullRight } |
| 2325 |
\prg_return_true: \else: \prg_return_false: \fi: |
| 2326 |
} |
| 2327 |
\clist_map_inline:Nn \g__xeCJK_special_punct_clist |
| 2328 |
{ |
| 2329 |
\exp_args:Nc |
| 2330 |
\prg_new_conditional:Npnn { __xeCJK_punct_if_#1:N } ##1 { p , T , F , TF } |
| 2331 |
{ |
| 2332 |
\if_cs_exist:w \__xeCJK_special_punct_tl:nN {#1} {##1} \cs_end: |
| 2333 |
\prg_return_true: \else: \prg_return_false: \fi: |
| 2334 |
} |
| 2335 |
} |
| 2336 |
\cs_new:Npn \__xeCJK_punct_csname:n #1 |
| 2337 |
{ c__xeCJK_\l_xeCJK_current_punct_font_tl/\l_xeCJK_punct_style_tl/#1/tl } |
| 2338 |
\cs_new:Npn \__xeCJK_use_punct_dim:nN #1#2 |
| 2339 |
{ \use:c { \__xeCJK_punct_csname:n { dim/#1/#2 } } } |
| 2340 |
\cs_new:Npn \__xeCJK_use_punct_dim:nNN #1#2#3 |
| 2341 |
{ \use:c { \__xeCJK_punct_csname:n { dim/#1/#2/#3 } } } |
| 2342 |
\cs_new:Npn \__xeCJK_use_punct_skip:nNN #1#2#3 |
| 2343 |
{ \use:c { \__xeCJK_punct_csname:n { skip/#1/#2/#3 } } } |
| 2344 |
\cs_new:Npn \__xeCJK_use_punct_skip_plus:nNN #1#2#3 |
| 2345 |
{ \use:c { \__xeCJK_punct_csname:n { skip/plus/#1/#2/#3 } } } |
| 2346 |
\cs_new:Npn \__xeCJK_use_punct_skip_minus:nNN #1#2#3 |
| 2347 |
{ \use:c { \__xeCJK_punct_csname:n { skip/minus/#1/#2/#3 } } } |
| 2348 |
\cs_new_protected:Npn \__xeCJK_save_punct_dim:nNn #1#2 |
| 2349 |
{ \__xeCJK_save_punct_width_aux:nnnn { dim } {#1} { #1/#2 } } |
| 2350 |
\cs_new_protected:Npn \__xeCJK_save_punct_dim:nNNn #1#2#3 |
| 2351 |
{ \__xeCJK_save_punct_width_aux:nnnn { dim } {#1} { #1/#2/#3 } } |
| 2352 |
\cs_new_protected:Npn \__xeCJK_save_punct_skip:nNNn #1#2#3#4 |
| 2353 |
{ |
| 2354 |
\__xeCJK_save_punct_width_aux:nnnn { skip } {#1} { #1/#2/#3 } {#4} |
| 2355 |
\__xeCJK_save_punct_width_aux:nnnn { skip } {#1} { plus/#1/#2/#3 } {#4} |
| 2356 |
\__xeCJK_save_punct_width_aux:nnnn { skip } {#1} { minus/#1/#2/#3 } {#4} |
| 2357 |
} |
| 2358 |
\cs_new_protected:Npn \__xeCJK_save_punct_skip:nNNnnn #1#2#3#4#5#6 |
| 2359 |
{ |
| 2360 |
\exp_last_unbraced:Ne |
| 2361 |
\__xeCJK_save_punct_skip_aux:nnnnn |
| 2362 |
{ |
| 2363 |
{#1} |
| 2364 |
{ #1/#2/#3 } |
| 2365 |
{ \dim_eval:n {#4} } |
| 2366 |
{ \dim_max:nn { \c_zero_dim } {#5} } |
| 2367 |
{ \dim_max:nn { \c_zero_dim } {#6} } |
| 2368 |
} |
| 2369 |
} |
| 2370 |
\cs_new_protected:Npn \__xeCJK_save_punct_skip_aux:nnnnn #1#2#3#4#5 |
| 2371 |
{ |
| 2372 |
\__xeCJK_save_punct_width_aux:nnnn { skip } {#1} |
| 2373 |
{#2} { #3 ~ plus ~ #4 ~ minus ~ #5 ~ } |
| 2374 |
\__xeCJK_save_punct_width_aux:nnnn { skip } {#1} |
| 2375 |
{ plus/#2 } { #3 ~ plus ~ #4 ~ } |
| 2376 |
\__xeCJK_save_punct_width_aux:nnnn { skip } {#1} |
| 2377 |
{ minus/#2 } { #3 ~ minus ~ #5 ~ } |
| 2378 |
} |
| 2379 |
\cs_new_protected:Npn \__xeCJK_save_punct_width_aux:nnnn #1#2#3#4 |
| 2380 |
{ |
| 2381 |
\__xeCJK_save_punct_width_aux:cen |
| 2382 |
{ \__xeCJK_punct_csname:n { #1/#3 } } |
| 2383 |
{ \use:c { #1_eval:n } {#4} } |
| 2384 |
{#2} |
| 2385 |
} |
| 2386 |
\cs_new_protected:Npn \__xeCJK_save_punct_width_aux:Nnn #1#2#3 |
| 2387 |
{ |
| 2388 |
\tl_const:Nn #1 {#2} |
| 2389 |
\str_if_eq:nnT {#3} { glue } |
| 2390 |
{ \prop_gput:Nnn \g__xeCJK_punct_skip_prop {#2} { } } |
| 2391 |
} |
| 2392 |
\prop_new:N \g__xeCJK_punct_skip_prop |
| 2393 |
\prop_gput:Non \g__xeCJK_punct_skip_prop { \skip_use:N \c_zero_skip } { } |
| 2394 |
\cs_generate_variant:Nn \__xeCJK_save_punct_width_aux:Nnn { ce } |
| 2395 |
\cs_new_eq:NN \__xeCJK_use_dim_or_skip:nNN \__xeCJK_use_punct_skip:nNN |
| 2396 |
\DeclareObjectType { xeCJK / punctuation } { 0 } |
| 2397 |
\DeclareTemplateInterface { xeCJK / punctuation } { basic } { 0 } |
| 2398 |
{ |
| 2399 |
enabled-global-setting : boolean = true , |
| 2400 |
fixed-punct-width : length = \c_max_dim , |
| 2401 |
fixed-punct-ratio : real = \c_one_fp , |
| 2402 |
mixed-punct-width : length = \KeyValue { fixed-punct-width } , |
| 2403 |
mixed-punct-ratio : real = \KeyValue { fixed-punct-ratio } , |
| 2404 |
middle-punct-width : length = \KeyValue { fixed-punct-width } , |
| 2405 |
middle-punct-ratio : real = \KeyValue { fixed-punct-ratio } , |
| 2406 |
fixed-margin-width : length = \c_max_dim , |
| 2407 |
fixed-margin-ratio : real = \c_one_fp , |
| 2408 |
mixed-margin-width : length = \KeyValue { fixed-margin-width } , |
| 2409 |
mixed-margin-ratio : real = \KeyValue { fixed-margin-ratio } , |
| 2410 |
middle-margin-width : length = \KeyValue { fixed-margin-width } , |
| 2411 |
middle-margin-ratio : real = \KeyValue { fixed-margin-ratio } , |
| 2412 |
bound-punct-width : length = \c_max_dim , |
| 2413 |
bound-punct-ratio : real = \c_nan_fp , |
| 2414 |
bound-margin-width : length = \c_max_dim , |
| 2415 |
bound-margin-ratio : real = \c_zero_fp , |
| 2416 |
enabled-hanging : boolean = false , |
| 2417 |
add-min-bound-to-margin : boolean = false , |
| 2418 |
optimize-margin : boolean = false , |
| 2419 |
margin-minimum : length = \c_zero_dim , |
| 2420 |
enabled-kerning : boolean = true , |
| 2421 |
min-bound-to-kerning : boolean = false , |
| 2422 |
kerning-total-width : length = \c_max_dim , |
| 2423 |
kerning-total-ratio : real = 0.75 , |
| 2424 |
optimize-kerning : boolean = false , |
| 2425 |
same-align-margin : length = \c_max_dim , |
| 2426 |
same-align-ratio : real = \c_nan_fp , |
| 2427 |
different-align-margin : length = \c_max_dim , |
| 2428 |
different-align-ratio : real = \c_nan_fp , |
| 2429 |
kerning-margin-width : length = \c_max_dim , |
| 2430 |
kerning-margin-ratio : real = \c_one_fp , |
| 2431 |
kerning-margin-minimum : length = \c_zero_dim |
| 2432 |
} |
| 2433 |
\DeclareTemplateCode { xeCJK / punctuation } { basic } { 0 } |
| 2434 |
{ |
| 2435 |
enabled-global-setting = \l__xeCJK_enabled_global_setting_bool , |
| 2436 |
fixed-punct-width = \l__xeCJK_fixed_punct_width_dim , |
| 2437 |
fixed-punct-ratio = \l__xeCJK_fixed_punct_ratio_fp , |
| 2438 |
mixed-punct-width = \l__xeCJK_mixed_punct_width_dim , |
| 2439 |
mixed-punct-ratio = \l__xeCJK_mixed_punct_ratio_fp , |
| 2440 |
middle-punct-width = \l__xeCJK_middle_punct_width_dim , |
| 2441 |
middle-punct-ratio = \l__xeCJK_middle_punct_ratio_fp , |
| 2442 |
fixed-margin-width = \l__xeCJK_fixed_margin_width_dim , |
| 2443 |
fixed-margin-ratio = \l__xeCJK_fixed_margin_ratio_fp , |
| 2444 |
mixed-margin-width = \l__xeCJK_mixed_margin_width_dim , |
| 2445 |
mixed-margin-ratio = \l__xeCJK_mixed_margin_ratio_fp , |
| 2446 |
middle-margin-width = \l__xeCJK_middle_margin_width_dim , |
| 2447 |
middle-margin-ratio = \l__xeCJK_middle_margin_ratio_fp , |
| 2448 |
bound-punct-width = \l__xeCJK_bound_punct_width_dim , |
| 2449 |
bound-punct-ratio = \l__xeCJK_bound_punct_ratio_fp , |
| 2450 |
bound-margin-width = \l__xeCJK_bound_margin_width_dim , |
| 2451 |
bound-margin-ratio = \l__xeCJK_bound_margin_ratio_fp , |
| 2452 |
enabled-hanging = \l__xeCJK_enabled_hanging_bool , |
| 2453 |
add-min-bound-to-margin = \l__xeCJK_add_min_bound_to_margin_bool , |
| 2454 |
optimize-margin = \l__xeCJK_optimize_margin_bool , |
| 2455 |
margin-minimum = \l__xeCJK_margin_minimum_dim , |
| 2456 |
enabled-kerning = \l__xeCJK_enabled_kerning_bool , |
| 2457 |
min-bound-to-kerning = \l__xeCJK_min_bound_to_kerning_bool , |
| 2458 |
kerning-total-width = \l__xeCJK_kerning_total_width_dim , |
| 2459 |
kerning-total-ratio = \l__xeCJK_kerning_total_ratio_fp , |
| 2460 |
optimize-kerning = \l__xeCJK_optimize_kerning_bool , |
| 2461 |
same-align-margin = \l__xeCJK_same_align_margin_dim , |
| 2462 |
same-align-ratio = \l__xeCJK_same_align_ratio_fp , |
| 2463 |
different-align-margin = \l__xeCJK_different_align_margin_dim , |
| 2464 |
different-align-ratio = \l__xeCJK_different_align_ratio_fp , |
| 2465 |
kerning-margin-width = \l__xeCJK_kerning_margin_width_dim , |
| 2466 |
kerning-margin-ratio = \l__xeCJK_kerning_margin_ratio_fp , |
| 2467 |
kerning-margin-minimum = \l__xeCJK_kerning_margin_minimum_dim |
| 2468 |
} |
| 2469 |
{ \AssignTemplateKeys } |
| 2470 |
\cs_new_protected:Npn \xeCJK_get_punct_bounds:NN #1#2 |
| 2471 |
{ |
| 2472 |
\tl_if_exist:cF { \__xeCJK_punct_csname:n { dim/glue/#1/#2 } } |
| 2473 |
{ \__xeCJK_get_punct_bounds_aux:NN #1 #2 } |
| 2474 |
} |
| 2475 |
\cs_new_protected:Npn \__xeCJK_get_punct_bounds_aux:NN |
| 2476 |
{ |
| 2477 |
\tl_if_eq:NNTF \l_xeCJK_punct_style_tl \c__xeCJK_punct_style_plain_tl |
| 2478 |
{ \__xeCJK_save_punct_margin_plain:NN } |
| 2479 |
{ \__xeCJK_save_punct_margin:NN } |
| 2480 |
} |
| 2481 |
\cs_new_protected:Npn \xeCJK_get_punct_bounds:No |
| 2482 |
{ \exp_last_unbraced:NNo \xeCJK_get_punct_bounds:NN } |
| 2483 |
\cs_new_protected:Npn \__xeCJK_save_punct_margin_plain:NN #1#2 |
| 2484 |
{ |
| 2485 |
\__xeCJK_save_punct_dim:nNNn { glue } #1 #2 { \c_zero_dim } |
| 2486 |
\__xeCJK_save_punct_dim:nNNn { offset } #1 #2 { \c_zero_dim } |
| 2487 |
\__xeCJK_save_punct_dim:nNNn { margin } #1 #2 { \c_zero_dim } |
| 2488 |
\__xeCJK_save_punct_dim:nNNn { rule } \c__xeCJK_left_tl {#2} { \c_zero_dim } |
| 2489 |
\__xeCJK_save_punct_dim:nNNn { rule } \c__xeCJK_right_tl {#2} { \c_zero_dim } |
| 2490 |
\__xeCJK_save_punct_dim:nNNn { bound } \c__xeCJK_left_tl {#2} { \c_zero_dim } |
| 2491 |
\__xeCJK_save_punct_dim:nNNn { bound } \c__xeCJK_right_tl {#2} { \c_zero_dim } |
| 2492 |
\__xeCJK_save_punct_skip:nNNn { glue } #1 #2 { \c_zero_skip } |
| 2493 |
} |
| 2494 |
\cs_new_protected:Npn \__xeCJK_save_punct_margin:NN #1#2 |
| 2495 |
{ |
| 2496 |
\group_begin: |
| 2497 |
\xeCJK_select_punct_font: |
| 2498 |
\xeCJK_fallback_punct_symbol:NN |
| 2499 |
\xeCJK_calc_punct_dimen:N #2 |
| 2500 |
\group_end: |
| 2501 |
\dim_set:Nn \l__xeCJK_bound_dim |
| 2502 |
{ \__xeCJK_use_punct_dim:nNN { bound } #1 #2 } |
| 2503 |
\tl_if_eq:NNTF #1 \c__xeCJK_right_tl |
| 2504 |
{ \tl_set_eq:NN \l__xeCJK_reverse_tl \c__xeCJK_left_tl } |
| 2505 |
{ \tl_set_eq:NN \l__xeCJK_reverse_tl \c__xeCJK_right_tl } |
| 2506 |
\dim_set:Nn \l__xeCJK_reverse_bound_dim |
| 2507 |
{ \__xeCJK_use_punct_dim:nNN { bound } \l__xeCJK_reverse_tl #2 } |
| 2508 |
\UseInstance { xeCJK / punctuation } { \l_xeCJK_punct_style_tl } |
| 2509 |
\xeCJK_punct_margin_process:NN #1 #2 |
| 2510 |
\xeCJK_punct_offset_process:NN #1 #2 |
| 2511 |
\__xeCJK_punct_if_long:NT #2 |
| 2512 |
{ \__xeCJK_long_punct_kerning:N #2 } |
| 2513 |
} |
| 2514 |
\tl_new:N \l__xeCJK_reverse_tl |
| 2515 |
\dim_new:N \l__xeCJK_bound_dim |
| 2516 |
\dim_new:N \l__xeCJK_reverse_bound_dim |
| 2517 |
\cs_new_protected:Npn \__xeCJK_long_punct_kerning:N #1 |
| 2518 |
{ |
| 2519 |
\dim_set:Nn \l__xeCJK_tmp_dim |
| 2520 |
{ |
| 2521 |
\dim_max:nn |
| 2522 |
{ \l__xeCJK_bound_dim + \l__xeCJK_reverse_bound_dim } |
| 2523 |
{ \c_zero_dim } |
| 2524 |
} |
| 2525 |
\__xeCJK_save_punct_dim:nNNn { bound_width } #1 #1 { \l__xeCJK_tmp_dim } |
| 2526 |
\dim_set:Nn \l__xeCJK_tmp_dim |
| 2527 |
{ |
| 2528 |
\str_case:nnTF {#1} |
| 2529 |
{ { ^^^^2025 } { } { ^^^^2026 } { } } |
| 2530 |
{ \c_zero_dim } |
| 2531 |
{ -\l__xeCJK_tmp_dim } |
| 2532 |
} |
| 2533 |
\__xeCJK_save_punct_dim:nNNn { kern } #1 #1 { \l__xeCJK_tmp_dim } |
| 2534 |
\__xeCJK_save_punct_skip:nNNn { kern } #1 #1 { \l__xeCJK_tmp_dim } |
| 2535 |
\dim_add:Nn \l__xeCJK_tmp_dim |
| 2536 |
{ \dim_max:nn { \l__xeCJK_bound_dim } { \c_zero_dim } } |
| 2537 |
\__xeCJK_save_punct_dim:nNNn { bound_kern } #1 #1 { \l__xeCJK_tmp_dim } |
| 2538 |
\__xeCJK_save_punct_skip:nNNn { bound_kern } #1 #1 { \l__xeCJK_tmp_dim } |
| 2539 |
} |
| 2540 |
\cs_new_protected:Npn \xeCJK_get_punct_kerning:NN #1#2 |
| 2541 |
{ |
| 2542 |
\tl_if_exist:cF { \__xeCJK_punct_csname:n { dim/kern/#1/#2 } } |
| 2543 |
{ |
| 2544 |
\tl_if_eq:NNTF \l_xeCJK_punct_style_tl \c__xeCJK_punct_style_plain_tl |
| 2545 |
{ \__xeCJK_save_punct_kerning_plain:NN } |
| 2546 |
{ \__xeCJK_save_punct_kerning:NN } |
| 2547 |
#1 #2 |
| 2548 |
} |
| 2549 |
} |
| 2550 |
\cs_new_protected:Npn \xeCJK_get_punct_kerning:oN |
| 2551 |
{ \exp_after:wN \xeCJK_get_punct_kerning:NN } |
| 2552 |
\cs_new_protected:Npn \__xeCJK_save_punct_kerning_plain:NN #1#2 |
| 2553 |
{ |
| 2554 |
\__xeCJK_save_punct_dim:nNNn { kern } #1 #2 { \c_zero_dim } |
| 2555 |
\__xeCJK_save_punct_dim:nNNn { bound_kern } #1 #2 { \c_zero_dim } |
| 2556 |
\__xeCJK_save_punct_dim:nNNn { bound_width } #1 #2 { \c_zero_dim } |
| 2557 |
\__xeCJK_save_punct_skip:nNNn { kern } #1 #2 { \c_zero_skip } |
| 2558 |
\__xeCJK_save_punct_skip:nNNn { bound_kern } #1 #2 { \c_zero_skip } |
| 2559 |
} |
| 2560 |
\cs_new_protected:Npn \__xeCJK_save_punct_kerning:NN |
| 2561 |
{ |
| 2562 |
\UseInstance { xeCJK / punctuation } { \l_xeCJK_punct_style_tl } |
| 2563 |
\xeCJK_punct_kerning_process:NN |
| 2564 |
} |
| 2565 |
\cs_new_protected:Npn \xeCJK_punct_margin_process:NN #1#2 |
| 2566 |
{ |
| 2567 |
\dim_set:Nn \l__xeCJK_tmp_dim |
| 2568 |
{ |
| 2569 |
\bool_if:NTF \l__xeCJK_enabled_global_setting_bool |
| 2570 |
{ |
| 2571 |
\cs_if_exist_use:cF { g__xeCJK_punct_width/#2/tl } |
| 2572 |
{ |
| 2573 |
\tl_if_empty:NTF \g__xeCJK_punct_width_tl |
| 2574 |
{ \__xeCJK_calc_punct_width:N #2 } |
| 2575 |
{ \g__xeCJK_punct_width_tl } |
| 2576 |
} |
| 2577 |
} |
| 2578 |
{ \__xeCJK_calc_punct_width:N #2 } |
| 2579 |
} |
| 2580 |
\dim_set:Nn \l__xeCJK_margin_dim |
| 2581 |
{ |
| 2582 |
\dim_max:nn |
| 2583 |
{ \l__xeCJK_margin_minimum_dim } |
| 2584 |
{ |
| 2585 |
\dim_compare:nNnTF \l__xeCJK_tmp_dim < \c_max_dim |
| 2586 |
{ |
| 2587 |
\__xeCJK_punct_if_middle:NTF #2 |
| 2588 |
{ |
| 2589 |
( \l__xeCJK_tmp_dim |
| 2590 |
- ( \__xeCJK_use_punct_dim:nN { dimen } #2 ) |
| 2591 |
) / 2 |
| 2592 |
} |
| 2593 |
{ |
| 2594 |
\bool_if:NTF \l__xeCJK_optimize_margin_bool |
| 2595 |
{ |
| 2596 |
\dim_max:nn |
| 2597 |
{ |
| 2598 |
\dim_min:nn |
| 2599 |
{ \l__xeCJK_bound_dim } |
| 2600 |
{ \l__xeCJK_reverse_bound_dim } |
| 2601 |
} |
| 2602 |
} |
| 2603 |
{ \use:n } |
| 2604 |
{ |
| 2605 |
\l__xeCJK_tmp_dim |
| 2606 |
- \l__xeCJK_reverse_bound_dim |
| 2607 |
- ( \__xeCJK_use_punct_dim:nN { dimen } #2 ) |
| 2608 |
} |
| 2609 |
} |
| 2610 |
} |
| 2611 |
{ |
| 2612 |
\bool_if:NTF \l__xeCJK_optimize_margin_bool |
| 2613 |
{ \dim_min:nn { \l__xeCJK_bound_dim } } |
| 2614 |
{ \use:n } |
| 2615 |
{ \__xeCJK_calc_margin_width:N #2 } |
| 2616 |
} |
| 2617 |
} |
| 2618 |
} |
| 2619 |
\__xeCJK_save_punct_dim:nNNn { margin } #1 #2 { \l__xeCJK_margin_dim } |
| 2620 |
} |
| 2621 |
\dim_new:N \l__xeCJK_margin_dim |
| 2622 |
\cs_new:Npn \__xeCJK_calc_punct_width:N #1 |
| 2623 |
{ |
| 2624 |
\__xeCJK_punct_if_middle:NTF #1 |
| 2625 |
{ \__xeCJK_punct_width_or_ratio:nN { middle } } |
| 2626 |
{ |
| 2627 |
\__xeCJK_punct_if_mixed_width:NTF #1 |
| 2628 |
{ \__xeCJK_punct_width_or_ratio:nN { mixed } } |
| 2629 |
{ \__xeCJK_punct_width_or_ratio:nN { fixed } } |
| 2630 |
} |
| 2631 |
#1 |
| 2632 |
} |
| 2633 |
\cs_new:Npn \__xeCJK_calc_margin_width:N #1 |
| 2634 |
{ |
| 2635 |
\__xeCJK_punct_if_middle:NTF #1 |
| 2636 |
{ |
| 2637 |
\dim_compare:nNnTF \l__xeCJK_middle_margin_width_dim < \c_max_dim |
| 2638 |
{ \l__xeCJK_middle_margin_width_dim } |
| 2639 |
{ |
| 2640 |
\__xeCJK_dim_ratio:Nn \l__xeCJK_middle_margin_ratio_fp |
| 2641 |
{ ( \l__xeCJK_bound_dim + \l__xeCJK_reverse_bound_dim ) / 2 } |
| 2642 |
} |
| 2643 |
} |
| 2644 |
{ |
| 2645 |
\__xeCJK_punct_if_mixed_width:NTF #1 |
| 2646 |
{ \__xeCJK_margin_width_or_ratio:n { mixed } } |
| 2647 |
{ \__xeCJK_margin_width_or_ratio:n { fixed } } |
| 2648 |
} |
| 2649 |
} |
| 2650 |
\cs_new:Npn \__xeCJK_dim_ratio:Nn #1#2 |
| 2651 |
{ \fp_to_dim:n { #1 \dim_to_fp:n {#2} } } |
| 2652 |
\cs_generate_variant:Nn \__xeCJK_dim_ratio:Nn { c } |
| 2653 |
\cs_new_protected:Npn \xeCJK_punct_offset_process:NN #1#2 |
| 2654 |
{ |
| 2655 |
\dim_set:Nn \l__xeCJK_tmp_dim |
| 2656 |
{ |
| 2657 |
\bool_if:NTF \l__xeCJK_enabled_global_setting_bool |
| 2658 |
{ |
| 2659 |
\cs_if_exist_use:cF { g__xeCJK_punct_bound_width/#2/tl } |
| 2660 |
{ |
| 2661 |
\tl_if_empty:NTF \g__xeCJK_punct_bound_width_tl |
| 2662 |
{ \__xeCJK_punct_width_or_ratio:nN { bound } #2 } |
| 2663 |
{ \g__xeCJK_punct_bound_width_tl } |
| 2664 |
} |
| 2665 |
} |
| 2666 |
{ \__xeCJK_punct_width_or_ratio:nN { bound } #2 } |
| 2667 |
} |
| 2668 |
\dim_set:Nn \l__xeCJK_tmp_dim |
| 2669 |
{ |
| 2670 |
\bool_if:NTF \l__xeCJK_enabled_hanging_bool |
| 2671 |
{ \use:n } |
| 2672 |
{ \dim_max:nn { \l__xeCJK_margin_minimum_dim } } |
| 2673 |
{ |
| 2674 |
\dim_compare:nNnTF \l__xeCJK_tmp_dim < \c_max_dim |
| 2675 |
{ |
| 2676 |
\__xeCJK_punct_if_middle:NTF #2 |
| 2677 |
{ |
| 2678 |
\l__xeCJK_tmp_dim |
| 2679 |
- \l__xeCJK_margin_dim |
| 2680 |
- ( \__xeCJK_use_punct_dim:nN { dimen } #2 ) |
| 2681 |
} |
| 2682 |
{ |
| 2683 |
\l__xeCJK_tmp_dim |
| 2684 |
- \l__xeCJK_reverse_bound_dim |
| 2685 |
- ( \__xeCJK_use_punct_dim:nN { dimen } #2 ) |
| 2686 |
} |
| 2687 |
} |
| 2688 |
{ |
| 2689 |
\bool_if:NTF \l__xeCJK_optimize_margin_bool |
| 2690 |
{ \dim_min:nn { \l__xeCJK_bound_dim } } |
| 2691 |
{ \use:n } |
| 2692 |
{ \__xeCJK_margin_width_or_ratio:n { bound } } |
| 2693 |
} |
| 2694 |
} |
| 2695 |
} |
| 2696 |
\__xeCJK_save_punct_dim:nNNn { offset } #1 #2 |
| 2697 |
{ \l__xeCJK_tmp_dim } |
| 2698 |
\__xeCJK_save_punct_dim:nNNn { rule } #1 #2 |
| 2699 |
{ \l__xeCJK_tmp_dim - \l__xeCJK_bound_dim } |
| 2700 |
\__xeCJK_save_punct_dim:nNNn { rule } \l__xeCJK_reverse_tl #2 |
| 2701 |
{ \l__xeCJK_tmp_dim - \l__xeCJK_reverse_bound_dim } |
| 2702 |
\__xeCJK_save_punct_dim:nNNn { glue } #1 #2 |
| 2703 |
{ \l__xeCJK_margin_dim - \l__xeCJK_tmp_dim } |
| 2704 |
\__xeCJK_save_punct_skip:nNNnnn { glue } #1 #2 |
| 2705 |
{ \l__xeCJK_margin_dim - \l__xeCJK_tmp_dim } |
| 2706 |
{ |
| 2707 |
\__xeCJK_punct_if_middle:NTF #2 |
| 2708 |
{ |
| 2709 |
( \__xeCJK_use_punct_dim:nN { width } #2 - |
| 2710 |
\__xeCJK_use_punct_dim:nN { dimen } #2 ) / 2 |
| 2711 |
- \l__xeCJK_margin_dim |
| 2712 |
} |
| 2713 |
{ \l__xeCJK_bound_dim - \l__xeCJK_margin_dim } |
| 2714 |
} |
| 2715 |
{ |
| 2716 |
\__xeCJK_punct_if_middle:NTF #2 |
| 2717 |
{ \l__xeCJK_margin_dim / 2 } |
| 2718 |
{ \l__xeCJK_margin_dim - \l__xeCJK_reverse_bound_dim } |
| 2719 |
} |
| 2720 |
} |
| 2721 |
\cs_new:Npn \__xeCJK_punct_width_or_ratio:nN #1#2 |
| 2722 |
{ |
| 2723 |
\dim_compare:nNnTF { \use:c { l__xeCJK_#1_punct_width_dim } } < \c_max_dim |
| 2724 |
{ \use:c { l__xeCJK_#1_punct_width_dim } } |
| 2725 |
{ |
| 2726 |
\fp_if_nan:nTF { \use:c { l__xeCJK_#1_punct_ratio_fp } } |
| 2727 |
{ \c_max_dim } |
| 2728 |
{ |
| 2729 |
\__xeCJK_dim_ratio:cn |
| 2730 |
{ l__xeCJK_#1_punct_ratio_fp } |
| 2731 |
{ \__xeCJK_use_punct_dim:nN { width } #2 } |
| 2732 |
} |
| 2733 |
} |
| 2734 |
} |
| 2735 |
\cs_new:Npn \__xeCJK_margin_width_or_ratio:n #1 |
| 2736 |
{ |
| 2737 |
\dim_compare:nNnTF { \use:c { l__xeCJK_#1_margin_width_dim } } < \c_max_dim |
| 2738 |
{ \use:c { l__xeCJK_#1_margin_width_dim } } |
| 2739 |
{ |
| 2740 |
\__xeCJK_dim_ratio:cn |
| 2741 |
{ l__xeCJK_#1_margin_ratio_fp } |
| 2742 |
{ \l__xeCJK_bound_dim } |
| 2743 |
} |
| 2744 |
\bool_if:NT \l__xeCJK_add_min_bound_to_margin_bool |
| 2745 |
{ + \dim_min:nn \l__xeCJK_bound_dim \l__xeCJK_reverse_bound_dim } |
| 2746 |
} |
| 2747 |
\cs_new_protected:Npn \xeCJK_punct_kerning_process:NN #1#2 |
| 2748 |
{ |
| 2749 |
\dim_set:Nn \l__xeCJK_margin_dim |
| 2750 |
{ \__xeCJK_original_kerning_margin:NN #1 #2 } |
| 2751 |
\dim_set:Nn \l__xeCJK_minimum_bound_dim |
| 2752 |
{ \__xeCJK_punct_min_bound:NN #1 #2 } |
| 2753 |
\__xeCJK_punct_if_long:NTF #1 |
| 2754 |
{ \bool_set_false:N \l__xeCJK_enabled_kerning_bool } |
| 2755 |
{ |
| 2756 |
\__xeCJK_punct_if_long:NT #2 |
| 2757 |
{ \bool_set_false:N \l__xeCJK_enabled_kerning_bool } |
| 2758 |
} |
| 2759 |
\dim_set:Nn \l__xeCJK_kerning_margin_dim |
| 2760 |
{ |
| 2761 |
\bool_if:NTF \l__xeCJK_enabled_global_setting_bool |
| 2762 |
{ |
| 2763 |
\cs_if_exist_use:cF { g__xeCJK_punct/kern/#1/#2/tl } |
| 2764 |
{ \__xeCJK_punct_kerning_process_aux:NN #1 #2 } |
| 2765 |
} |
| 2766 |
{ \__xeCJK_punct_kerning_process_aux:NN #1 #2 } |
| 2767 |
} |
| 2768 |
\__xeCJK_save_kerning:nnNN { kern } { bound } #1 #2 |
| 2769 |
\__xeCJK_save_punct_dim:nNNn { bound_width } #1 #2 |
| 2770 |
{ \l__xeCJK_kerning_margin_dim - \l__xeCJK_tmp_dim } |
| 2771 |
\__xeCJK_punct_if_right:NTF #1 |
| 2772 |
{ |
| 2773 |
\__xeCJK_punct_if_right:NTF #2 |
| 2774 |
{ \__xeCJK_save_kerning:nnnNN { bound_kern } { offset } { bound } } |
| 2775 |
{ \__xeCJK_save_kerning:nnNN { bound_kern } { offset } } |
| 2776 |
} |
| 2777 |
{ |
| 2778 |
\__xeCJK_punct_if_right:NTF #2 |
| 2779 |
{ \__xeCJK_save_kerning:nnNN { bound_kern } { bound } } |
| 2780 |
{ \__xeCJK_save_kerning:nnnNN { bound_kern } { bound } { offset } } |
| 2781 |
} |
| 2782 |
#1 #2 |
| 2783 |
} |
| 2784 |
\cs_new:Npn \__xeCJK_punct_kerning_process_aux:NN #1#2 |
| 2785 |
{ |
| 2786 |
\bool_if:NTF \l__xeCJK_enabled_kerning_bool |
| 2787 |
{ \__xeCJK_calc_kerning_margin:NN #1 #2 } |
| 2788 |
{ \l__xeCJK_margin_dim } |
| 2789 |
} |
| 2790 |
\dim_new:N \l__xeCJK_minimum_bound_dim |
| 2791 |
\dim_new:N \l__xeCJK_kerning_margin_dim |
| 2792 |
\cs_new_protected:Npn \__xeCJK_save_kerning:nnNN #1#2 |
| 2793 |
{ \__xeCJK_save_kerning:nnnNN {#1} {#2} {#2} } |
| 2794 |
\cs_new_protected:Npn \__xeCJK_save_kerning:nnnNN #1#2#3#4#5 |
| 2795 |
{ |
| 2796 |
\dim_set:Nn \l__xeCJK_tmp_dim |
| 2797 |
{ |
| 2798 |
\l__xeCJK_kerning_margin_dim |
| 2799 |
- ( \__xeCJK_use_punct_dim:nNN {#2} \c__xeCJK_right_tl #4 ) |
| 2800 |
- ( \__xeCJK_use_punct_dim:nNN {#3} \c__xeCJK_left_tl #5 ) |
| 2801 |
} |
| 2802 |
\__xeCJK_save_punct_dim:nNNn {#1} #4 #5 { \l__xeCJK_tmp_dim } |
| 2803 |
\__xeCJK_save_punct_skip:nNNnnn {#1} #4 #5 |
| 2804 |
{ \l__xeCJK_tmp_dim } |
| 2805 |
{ \l__xeCJK_margin_dim - \l__xeCJK_kerning_margin_dim } |
| 2806 |
{ \l__xeCJK_kerning_margin_dim - \l__xeCJK_minimum_bound_dim } |
| 2807 |
} |
| 2808 |
\cs_new:Npn \__xeCJK_original_kerning_margin:NN #1#2 |
| 2809 |
{ |
| 2810 |
\dim_eval:n |
| 2811 |
{ |
| 2812 |
\__xeCJK_use_punct_dim:nNN |
| 2813 |
{ \__xeCJK_punct_if_right:NTF #1 { margin } { bound } } \c__xeCJK_right_tl #1 |
| 2814 |
+ |
| 2815 |
\__xeCJK_use_punct_dim:nNN |
| 2816 |
{ \__xeCJK_punct_if_right:NTF #2 { bound } { margin } } \c__xeCJK_left_tl #2 |
| 2817 |
} |
| 2818 |
} |
| 2819 |
\cs_new:Npn \__xeCJK_calc_kerning_margin:NN #1#2 |
| 2820 |
{ |
| 2821 |
\dim_max:nn |
| 2822 |
{ \l__xeCJK_kerning_margin_minimum_dim } |
| 2823 |
{ |
| 2824 |
\bool_if:NTF \l__xeCJK_min_bound_to_kerning_bool |
| 2825 |
{ \l__xeCJK_minimum_bound_dim } |
| 2826 |
{ |
| 2827 |
\bool_if:NTF \l__xeCJK_optimize_kerning_bool |
| 2828 |
{ \dim_max:nn { \l__xeCJK_minimum_bound_dim } } |
| 2829 |
{ \use:n } |
| 2830 |
{ \__xeCJK_calc_kerning_margin_aux:NN #1 #2 } |
| 2831 |
} |
| 2832 |
} |
| 2833 |
} |
| 2834 |
\cs_new:Npn \__xeCJK_calc_kerning_margin_aux:NN #1#2 |
| 2835 |
{ |
| 2836 |
\dim_compare:nNnTF \l__xeCJK_kerning_total_width_dim < \c_max_dim |
| 2837 |
{ \__xeCJK_calc_kerning_margin:nNN \l__xeCJK_kerning_total_width_dim } |
| 2838 |
{ |
| 2839 |
\fp_if_nan:nTF { \l__xeCJK_kerning_total_ratio_fp } |
| 2840 |
{ |
| 2841 |
\xeCJK_if_same_class:NNTF #1 #2 |
| 2842 |
{ \__xeCJK_kerning_width_or_ratio:nNN { same } } |
| 2843 |
{ \__xeCJK_kerning_width_or_ratio:nNN { different } } |
| 2844 |
} |
| 2845 |
{ |
| 2846 |
\__xeCJK_calc_kerning_margin:nNN |
| 2847 |
{ |
| 2848 |
\__xeCJK_dim_ratio:Nn \l__xeCJK_kerning_total_ratio_fp |
| 2849 |
{ |
| 2850 |
\__xeCJK_use_punct_dim:nN { width } #1 + |
| 2851 |
\__xeCJK_use_punct_dim:nN { width } #2 |
| 2852 |
} |
| 2853 |
} |
| 2854 |
} |
| 2855 |
} |
| 2856 |
#1 #2 |
| 2857 |
} |
| 2858 |
\cs_new:Npn \__xeCJK_kerning_width_or_ratio:nNN #1#2#3 |
| 2859 |
{ |
| 2860 |
\dim_compare:nNnTF { \use:c { l__xeCJK_#1_align_margin_dim } } < \c_max_dim |
| 2861 |
{ \use:c { l__xeCJK_#1_align_margin_dim } } |
| 2862 |
{ |
| 2863 |
\fp_if_nan:nTF { \use:c { l__xeCJK_#1_align_ratio_fp } } |
| 2864 |
{ |
| 2865 |
\dim_compare:nNnTF \l__xeCJK_kerning_margin_width_dim < \c_max_dim |
| 2866 |
{ \l__xeCJK_kerning_margin_width_dim \use_none:n } |
| 2867 |
{ \__xeCJK_dim_ratio:Nn \l__xeCJK_kerning_margin_ratio_fp } |
| 2868 |
} |
| 2869 |
{ \__xeCJK_dim_ratio:cn { l__xeCJK_#1_align_ratio_fp } } |
| 2870 |
{ \l__xeCJK_margin_dim } |
| 2871 |
} |
| 2872 |
} |
| 2873 |
\cs_new:Npn \__xeCJK_punct_min_bound:NN #1#2 |
| 2874 |
{ |
| 2875 |
\dim_max:nn |
| 2876 |
{ |
| 2877 |
\dim_min:nn |
| 2878 |
{ \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_left_tl #1 } |
| 2879 |
{ \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_right_tl #1 } |
| 2880 |
} |
| 2881 |
{ |
| 2882 |
\dim_min:nn |
| 2883 |
{ \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_left_tl #2 } |
| 2884 |
{ \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_right_tl #2 } |
| 2885 |
} |
| 2886 |
} |
| 2887 |
\cs_new:Npn \__xeCJK_calc_kerning_margin:nNN #1#2#3 |
| 2888 |
{ |
| 2889 |
\dim_eval:n |
| 2890 |
{ |
| 2891 |
(#1) |
| 2892 |
- ( \__xeCJK_use_punct_dim:nNN |
| 2893 |
{ \__xeCJK_punct_if_right:NTF #2 { bound } { margin } } |
| 2894 |
\c__xeCJK_left_tl #2 ) |
| 2895 |
- ( \__xeCJK_use_punct_dim:nNN |
| 2896 |
{ \__xeCJK_punct_if_right:NTF #3 { margin } { bound } } |
| 2897 |
\c__xeCJK_right_tl #3 ) |
| 2898 |
- ( \__xeCJK_use_punct_dim:nN { dimen } #2 ) |
| 2899 |
- ( \__xeCJK_use_punct_dim:nN { dimen } #3 ) |
| 2900 |
} |
| 2901 |
} |
| 2902 |
\cs_new_protected:Npn \xeCJK_calc_punct_dimen:N #1 |
| 2903 |
{ |
| 2904 |
\__xeCJK_save_punct_dim:nNNn { bound } \c__xeCJK_left_tl #1 |
| 2905 |
{ \xeCJK_glyph_bounds:NN 1 #1 } |
| 2906 |
\__xeCJK_save_punct_dim:nNNn { bound } \c__xeCJK_right_tl #1 |
| 2907 |
{ \xeCJK_glyph_bounds:NN 3 #1 } |
| 2908 |
\__xeCJK_save_punct_dim:nNn { width } #1 |
| 2909 |
{ \tex_fontcharwd:D \tex_font:D `#1 } |
| 2910 |
\__xeCJK_save_punct_dim:nNn { dimen } #1 |
| 2911 |
{ |
| 2912 |
( \__xeCJK_use_punct_dim:nN { width } #1 ) - |
| 2913 |
( \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_left_tl #1 ) - |
| 2914 |
( \__xeCJK_use_punct_dim:nNN { bound } \c__xeCJK_right_tl #1 ) |
| 2915 |
} |
| 2916 |
} |
| 2917 |
\cs_new:Npn \xeCJK_glyph_bounds:NN #1#2 |
| 2918 |
{ \tex_XeTeXglyphbounds:D #1 ~ \tex_XeTeXcharglyph:D `#2 \exp_stop_f: } |
| 2919 |
\keys_define:nn { xeCJK / options } |
| 2920 |
{ PunctStyle .code:n = \exp_args:Nx \__xeCJK_set_punct_style:n {#1} } |
| 2921 |
\cs_new_protected:Npn \__xeCJK_set_punct_style:n #1 |
| 2922 |
{ |
| 2923 |
\IfInstanceExistTF { xeCJK / punctuation } {#1} |
| 2924 |
{ \tl_set:Nn \l_xeCJK_punct_style_tl {#1} } |
| 2925 |
{ |
| 2926 |
\prop_get:NnNF \c__xeCJK_punct_style_alias_prop |
| 2927 |
{#1} \l_xeCJK_punct_style_tl |
| 2928 |
{ \__xeCJK_error:nx { punct-style-unknown } {#1} } |
| 2929 |
} |
| 2930 |
} |
| 2931 |
\prop_const_from_keyval:Nn \c__xeCJK_punct_style_alias_prop |
| 2932 |
{ |
| 2933 |
halfwidth = banjiao , |
| 2934 |
fullwidth = quanjiao , |
| 2935 |
mixedwidth = kaiming , |
| 2936 |
marginkerning = hangmobanjiao , |
| 2937 |
plain = plain |
| 2938 |
} |
| 2939 |
\tl_new:N \l_xeCJK_punct_style_tl |
| 2940 |
\tl_const:Nn \c__xeCJK_punct_style_plain_tl { plain } |
| 2941 |
\__xeCJK_msg_new:nn { punct-style-unknown } |
| 2942 |
{ |
| 2943 |
Punctuation~style~"#1"~is~unknown. \\\\ |
| 2944 |
The~available~styles~are~listed~as~follow.\\\\ |
| 2945 |
"plain,~\seq_use:Nnnn \g__xeCJK_punct_style_seq |
| 2946 |
{ ~and~ } { ,~ } { ,~and~ }".\\ |
| 2947 |
} |
| 2948 |
\cs_new_protected:Npn \__xeCJK_trim_spaces:n #1 |
| 2949 |
{ |
| 2950 |
\tl_set:Nx \ProcessedArgument |
| 2951 |
{ \exp_args:Ne \tl_trim_spaces:n {#1} } |
| 2952 |
} |
| 2953 |
\NewDocumentCommand \xeCJKDeclarePunctStyle |
| 2954 |
{ > { \__xeCJK_trim_spaces:n } m m } |
| 2955 |
{ |
| 2956 |
\IfInstanceExistTF { xeCJK / punctuation } {#1} |
| 2957 |
{ \__xeCJK_warning:nx { punct-style-already-defined } {#1} } |
| 2958 |
{ \seq_gput_right:Nn \g__xeCJK_punct_style_seq {#1} } |
| 2959 |
\DeclareInstance { xeCJK / punctuation } {#1} { basic } {#2} |
| 2960 |
} |
| 2961 |
\seq_new:N \g__xeCJK_punct_style_seq |
| 2962 |
\__xeCJK_msg_new:nn { punct-style-already-defined } |
| 2963 |
{ |
| 2964 |
Punctuation~style~"#1"~is~already~defined!. \\\\ |
| 2965 |
The~existing~style~of~"#1"~will~be~overwritten.\\ |
| 2966 |
} |
| 2967 |
\@onlypreamble \xeCJKDeclarePunctStyle |
| 2968 |
\NewDocumentCommand \xeCJKEditPunctStyle |
| 2969 |
{ > { \__xeCJK_trim_spaces:n } m m } |
| 2970 |
{ |
| 2971 |
\IfInstanceExistTF { xeCJK / punctuation } {#1} |
| 2972 |
{ \EditInstance { xeCJK / punctuation } {#1} {#2} } |
| 2973 |
{ \__xeCJK_error:nx { punct-style-unknown } {#1} } |
| 2974 |
} |
| 2975 |
\@onlypreamble \xeCJKEditPunctStyle |
| 2976 |
\xeCJKDeclarePunctStyle { quanjiao } { } |
| 2977 |
\xeCJKDeclarePunctStyle { hangmobanjiao } { enabled-kerning = false } |
| 2978 |
\xeCJKDeclarePunctStyle { banjiao } |
| 2979 |
{ |
| 2980 |
fixed-punct-ratio = 0.5 , |
| 2981 |
optimize-margin = true , |
| 2982 |
kerning-total-ratio = 0.5 , |
| 2983 |
optimize-kerning = true |
| 2984 |
} |
| 2985 |
\xeCJKDeclarePunctStyle { kaiming } |
| 2986 |
{ |
| 2987 |
fixed-punct-ratio = 0.5 , |
| 2988 |
mixed-punct-ratio = 0.8 , |
| 2989 |
optimize-margin = true , |
| 2990 |
kerning-total-ratio = 0.5 , |
| 2991 |
optimize-kerning = true |
| 2992 |
} |
| 2993 |
\xeCJKDeclarePunctStyle { CCT } |
| 2994 |
{ |
| 2995 |
fixed-punct-ratio = 0.7 , |
| 2996 |
optimize-margin = true , |
| 2997 |
kerning-total-ratio = 0.6 , |
| 2998 |
optimize-kerning = true |
| 2999 |
} |
| 3000 |
\keys_define:nn { xeCJK / options } |
| 3001 |
{ |
| 3002 |
AutoFallBack .choice: , |
| 3003 |
AutoFallBack / true .code:n = |
| 3004 |
{ |
| 3005 |
\cs_set_eq:NN \xeCJK_fallback_symbol:NN |
| 3006 |
\__xeCJK_fallback_symbol:NN |
| 3007 |
\cs_set_eq:NN \xeCJK_fallback_punct_symbol:NN |
| 3008 |
\__xeCJK_fallback_punct_symbol:NN |
| 3009 |
\cs_set_eq:NN \xeCJK_clear_fallback_font: |
| 3010 |
\__xeCJK_clear_fallback_font: |
| 3011 |
} , |
| 3012 |
AutoFallBack / false .code:n = |
| 3013 |
{ |
| 3014 |
\xeCJK_cs_clear:N \xeCJK_fallback_symbol:NN |
| 3015 |
\xeCJK_cs_clear:N \xeCJK_fallback_punct_symbol:NN |
| 3016 |
\xeCJK_cs_clear:N \xeCJK_clear_fallback_font: |
| 3017 |
} , |
| 3018 |
AutoFallBack .default:n = { true } , |
| 3019 |
fallback .meta:n = { AutoFallBack = true } |
| 3020 |
} |
| 3021 |
\cs_new_protected:Npn \__xeCJK_fallback_symbol:NN #1#2 |
| 3022 |
{ |
| 3023 |
\xeCJK_reset_fallback_font: |
| 3024 |
\xeCJK_glyph_if_exist:NF #2 |
| 3025 |
{ \__xeCJK_fallback_symbol_aux:NN } |
| 3026 |
#1#2 |
| 3027 |
} |
| 3028 |
\cs_new_protected:Npn \__xeCJK_fallback_punct_symbol:NN #1#2 |
| 3029 |
{ |
| 3030 |
\xeCJK_reset_fallback_font: |
| 3031 |
\xeCJK_glyph_if_exist:NF #2 |
| 3032 |
{ \__xeCJK_fallback_punct_symbol_aux:NN } |
| 3033 |
#1#2 |
| 3034 |
} |
| 3035 |
\cs_new_eq:NN \xeCJK_fallback_symbol:NN \prg_do_nothing: |
| 3036 |
\cs_new_eq:NN \xeCJK_fallback_punct_symbol:NN \prg_do_nothing: |
| 3037 |
\cs_new_protected:Npn \__xeCJK_fallback_symbol_aux:NN |
| 3038 |
{ |
| 3039 |
\__xeCJK_fallback_symbol_aux:nnNN |
| 3040 |
{ \CJK@family } |
| 3041 |
{ \l_xeCJK_family_tl } |
| 3042 |
} |
| 3043 |
\cs_new_protected:Npn \__xeCJK_fallback_punct_symbol_aux:NN |
| 3044 |
{ |
| 3045 |
\__xeCJK_fallback_symbol_aux:nnNN |
| 3046 |
{ \CJK@punctfamily } |
| 3047 |
{ \l_xeCJK_punct_family_tl } |
| 3048 |
} |
| 3049 |
\cs_new_protected:Npn \__xeCJK_fallback_symbol_aux:nnNN |
| 3050 |
{ |
| 3051 |
\cs_set_protected:Npx \xeCJK_reset_fallback_font: |
| 3052 |
{ |
| 3053 |
\tex_the:D \tex_font:D |
| 3054 |
\xeCJK_clear_fallback_font: |
| 3055 |
} |
| 3056 |
\exp_args:Nee \__xeCJK_fallback_loop:nnNN |
| 3057 |
} |
| 3058 |
\cs_new_protected:Npn \__xeCJK_clear_fallback_font: |
| 3059 |
{ \cs_set_eq:NN \xeCJK_reset_fallback_font: \prg_do_nothing: } |
| 3060 |
\cs_new_eq:NN \xeCJK_reset_fallback_font: \prg_do_nothing: |
| 3061 |
\cs_new_eq:NN \xeCJK_clear_fallback_font: \prg_do_nothing: |
| 3062 |
\cs_new_protected:Npn \__xeCJK_fallback_loop:nnNN |
| 3063 |
{ |
| 3064 |
\cs_set_eq:NN \__xeCJK_fallback_loop:TF \use_i:nn |
| 3065 |
\__xeCJK_fallback_loop:nnnNN { FallBack } |
| 3066 |
} |
| 3067 |
\cs_new_protected:Npn \__xeCJK_fallback_loop:nnnNN #1#2#3 |
| 3068 |
{ |
| 3069 |
\xeCJK_select_fallback_font:nnn {#1} {#2} {#3} |
| 3070 |
\__xeCJK_fallback_loop:TF |
| 3071 |
{ \__xeCJK_fallback_loop_aux:nnnNN } |
| 3072 |
{ \__xeCJK_fallback_missing_glyph:nnnNN } |
| 3073 |
{#1} {#2} {#3} |
| 3074 |
} |
| 3075 |
\cs_new_protected:Npn \__xeCJK_fallback_loop_aux:nnnNN #1#2#3#4#5 |
| 3076 |
{ |
| 3077 |
\xeCJK_glyph_if_exist:NF #5 |
| 3078 |
{ \__xeCJK_fallback_loop:nnnNN { #1/FallBack } {#2} {#3} } |
| 3079 |
#4#5 |
| 3080 |
} |
| 3081 |
\cs_new_protected:Npn \__xeCJK_fallback_missing_glyph:nnnNN #1#2#3#4#5 |
| 3082 |
{ |
| 3083 |
\__xeCJK_warning:nxxx { missing-glyph } {#1} {#2} {#5} |
| 3084 |
#4#5 |
| 3085 |
} |
| 3086 |
\cs_new_protected:Npn \xeCJK_select_fallback_font:nnn #1#2 |
| 3087 |
{ |
| 3088 |
\__xeCJK_select_fallback_font:cnnn |
| 3089 |
{ \__xeCJK_font_csname:n { #2/#1 } } {#1} {#2} |
| 3090 |
} |
| 3091 |
\cs_new_protected:Npn \__xeCJK_select_fallback_font:Nnnn #1 |
| 3092 |
{ |
| 3093 |
\cs_if_exist:NF #1 |
| 3094 |
{ \__xeCJK_fallback_font_initial:NNnnn } |
| 3095 |
#1 \use_none:nnn |
| 3096 |
} |
| 3097 |
\cs_generate_variant:Nn \__xeCJK_select_fallback_font:Nnnn { c } |
| 3098 |
\cs_new_protected:Npn \__xeCJK_fallback_font_initial:NNnnn #1#2#3#4#5 |
| 3099 |
{ |
| 3100 |
\xeCJK_family_if_exist:nTF { #5/#3 } |
| 3101 |
{ \__xeCJK_font_initial:Nn #1 { #5/#3 } } |
| 3102 |
{ \__xeCJK_fallback_font_initial_auxi:Nnnn #1 {#5} {#3} {#4} } |
| 3103 |
#1 |
| 3104 |
} |
| 3105 |
\cs_new_protected:Npn \__xeCJK_fallback_font_initial_auxi:Nnnn #1 |
| 3106 |
{ |
| 3107 |
\exp_args:NNe \__xeCJK_fallback_font_initial_auxii:Nnnnn |
| 3108 |
#1 { \CJKfamilydefault } |
| 3109 |
} |
| 3110 |
\cs_new_protected:Npn \__xeCJK_fallback_font_initial_auxii:Nnnnn #1#2#3 |
| 3111 |
{ |
| 3112 |
\str_if_eq:nnTF {#2} {#3} |
| 3113 |
{ \__xeCJK_fallback_loop_end:Nnnn } |
| 3114 |
{ \__xeCJK_fallback_font_initial_auxiii:Nnnn } |
| 3115 |
#1 {#2} |
| 3116 |
} |
| 3117 |
\cs_new_protected:Npn \__xeCJK_fallback_font_initial_auxiii:Nnnn #1#2 |
| 3118 |
{ |
| 3119 |
\xeCJK_family_if_exist:nTF {#2} |
| 3120 |
{ \__xeCJK_fallback_font_initial_auxiv:Nnnn } |
| 3121 |
{ \__xeCJK_fallback_loop_end:Nnnn } |
| 3122 |
#1 {#2} |
| 3123 |
} |
| 3124 |
\cs_new_protected:Npn \__xeCJK_fallback_font_initial_auxiv:Nnnn #1#2#3#4 |
| 3125 |
{ |
| 3126 |
\__xeCJK_font_initial:Nn #1 {#2} |
| 3127 |
\exp_args:Nc \__xeCJK_fallback_font_initial_auxiii:Nnnn |
| 3128 |
{ \__xeCJK_font_csname:n { #4/#3/FallBack } } |
| 3129 |
{ #2/FallBack } { #3/FallBack } {#4} |
| 3130 |
} |
| 3131 |
\cs_new_eq:NN \__xeCJK_fallback_loop:TF \use_i:nn |
| 3132 |
\cs_new_protected:Npn \__xeCJK_fallback_loop_end:Nnnn #1#2#3#4 |
| 3133 |
{ \cs_gset_eq:NN #1 \__xeCJK_fallback_loop_end: } |
| 3134 |
\cs_new_protected:Npn \__xeCJK_fallback_loop_end: |
| 3135 |
{ \cs_set_eq:NN \__xeCJK_fallback_loop:TF \use_ii:nn } |
| 3136 |
\__xeCJK_msg_new:nn { missing-glyph } |
| 3137 |
{ |
| 3138 |
CJKfamily~`\__xeCJK_msg_family_map:n {#2}'~(#1)~ |
| 3139 |
does~not~contain~glyph~`#3'~ |
| 3140 |
( U + \int_to_Hex:n { `#3 } )~\msg_line_context:. |
| 3141 |
} |
| 3142 |
\NewDocumentCommand \setCJKfallbackfamilyfont { m o m } |
| 3143 |
{ |
| 3144 |
\__xeCJK_pass_args:nnnn |
| 3145 |
{ \xeCJK_set_family_fallback:nnn {#1} } {#2} {#3} |
| 3146 |
{ } |
| 3147 |
} |
| 3148 |
\cs_new_protected:Npn \xeCJK_set_family_fallback:nnn #1#2#3 |
| 3149 |
{ |
| 3150 |
\group_begin: |
| 3151 |
\tl_set:Nn \l__xeCJK_fallback_family_tl {#1} |
| 3152 |
\prop_get:NoNF \g__xeCJK_family_font_name_prop |
| 3153 |
\l__xeCJK_fallback_family_tl \l__xeCJK_font_name_tl |
| 3154 |
{ \tl_clear:N \l__xeCJK_font_name_tl } |
| 3155 |
\clist_set:Nn \l__xeCJK_public_options_clist {#2} |
| 3156 |
\clist_map_function:nN {#3} \__xeCJK_set_family_fallback:n |
| 3157 |
\group_end: |
| 3158 |
} |
| 3159 |
\cs_new_protected:Npn \__xeCJK_set_family_fallback:n #1 |
| 3160 |
{ |
| 3161 |
\tl_put_right:Nn \l__xeCJK_fallback_family_tl { /FallBack } |
| 3162 |
\__xeCJK_get_sub_features:on \l__xeCJK_fallback_family_tl {#1} |
| 3163 |
\clist_concat:NNN \l__xeCJK_sub_font_options_clist |
| 3164 |
\l__xeCJK_public_options_clist |
| 3165 |
\l__xeCJK_sub_font_options_clist |
| 3166 |
\exp_args:Nooo \xeCJK_set_family:nnn |
| 3167 |
\l__xeCJK_fallback_family_tl |
| 3168 |
\l__xeCJK_sub_font_options_clist |
| 3169 |
\l__xeCJK_sub_font_name_tl |
| 3170 |
} |
| 3171 |
\tl_new:N \l__xeCJK_fallback_family_tl |
| 3172 |
\clist_new:N \l__xeCJK_public_options_clist |
| 3173 |
\bool_new:N \g__xeCJK_auto_fake_bold_bool |
| 3174 |
\bool_new:N \g__xeCJK_auto_fake_slant_bool |
| 3175 |
\fp_new:N \g__xeCJK_embolden_factor_fp |
| 3176 |
\fp_new:N \g__xeCJK_slant_factor_fp |
| 3177 |
\keys_define:nn { xeCJK / options } |
| 3178 |
{ |
| 3179 |
AutoFakeBold .choices:nn = { true , false } |
| 3180 |
{ \use:c { bool_gset_ \l_keys_choice_tl :N } \g__xeCJK_auto_fake_bold_bool } , |
| 3181 |
AutoFakeBold / unknown .code:n = |
| 3182 |
{ |
| 3183 |
\bool_gset_true:N \g__xeCJK_auto_fake_bold_bool |
| 3184 |
\fp_gset:Nn \g__xeCJK_embolden_factor_fp { \l_keys_value_tl } |
| 3185 |
} , |
| 3186 |
AutoFakeBold .default:n = { true } , |
| 3187 |
AutoFakeSlant .choices:nn = { true , false } |
| 3188 |
{ \use:c { bool_gset_ \l_keys_choice_tl :N } \g__xeCJK_auto_fake_slant_bool } , |
| 3189 |
AutoFakeSlant / unknown .code:n = |
| 3190 |
{ |
| 3191 |
\bool_gset_true:N \g__xeCJK_auto_fake_slant_bool |
| 3192 |
\fp_gset:Nn \g__xeCJK_slant_factor_fp { \l_keys_value_tl } |
| 3193 |
} , |
| 3194 |
AutoFakeSlant .default:n = { true } , |
| 3195 |
EmboldenFactor .fp_gset:N = \g__xeCJK_embolden_factor_fp , |
| 3196 |
SlantFactor .fp_gset:N = \g__xeCJK_slant_factor_fp , |
| 3197 |
BoldFont .meta:n = { AutoFakeBold = true } , |
| 3198 |
boldfont .meta:n = { AutoFakeBold = true } , |
| 3199 |
SlantFont .meta:n = { AutoFakeSlant = true } , |
| 3200 |
slantfont .meta:n = { AutoFakeSlant = true } |
| 3201 |
} |
| 3202 |
\seq_new:N \g__xeCJK_sub_key_seq |
| 3203 |
\cs_new_protected:Npn \xeCJK_new_sub_key:n #1 |
| 3204 |
{ |
| 3205 |
\seq_gput_right:Nn \g__xeCJK_sub_key_seq {#1} |
| 3206 |
\keys_define:nn { xeCJK / features } |
| 3207 |
{ |
| 3208 |
#1 .code:n = |
| 3209 |
{ |
| 3210 |
\tl_if_blank:nTF {##1} |
| 3211 |
{ |
| 3212 |
\prop_clear:N \l__xeCJK_sub_key_prop |
| 3213 |
\tl_set:Nx \l__xeCJK_sub_family_name_tl |
| 3214 |
{ \l__xeCJK_family_name_tl /#1 } |
| 3215 |
\clist_remove_all:Nn \l__xeCJK_font_options_clist {#1} |
| 3216 |
} |
| 3217 |
{ |
| 3218 |
\tl_clear:N \l__xeCJK_sub_family_name_tl |
| 3219 |
\str_if_eq:nnTF {##1} { * } |
| 3220 |
{ \prop_put:Nnn \l__xeCJK_sub_key_prop {#1} { \q_no_value } } |
| 3221 |
{ \__xeCJK_get_sub_features:nn {#1} {##1} } |
| 3222 |
} |
| 3223 |
} , |
| 3224 |
#1 .default:n = { } |
| 3225 |
} |
| 3226 |
} |
| 3227 |
\cs_new_protected:Npn \__xeCJK_get_sub_features:nn #1#2 |
| 3228 |
{ |
| 3229 |
\tl_set:Nx \l__xeCJK_tmp_tl { \xeCJK_tl_remove_outer_braces:n {#2} } |
| 3230 |
\clist_clear:N \l__xeCJK_sub_font_options_clist |
| 3231 |
\exp_after:wN \__xeCJK_get_sub_features:w \l__xeCJK_tmp_tl |
| 3232 |
\q_mark [ \q_nil ] \q_mark \q_stop |
| 3233 |
\tl_if_empty:NTF \l__xeCJK_sub_font_name_tl |
| 3234 |
{ \tl_set_eq:NN \l__xeCJK_sub_font_name_tl \l__xeCJK_font_name_tl } |
| 3235 |
{ \tl_replace_all:Nno \l__xeCJK_sub_font_name_tl { * } \l__xeCJK_font_name_tl } |
| 3236 |
\prop_put:Nne \l__xeCJK_sub_key_prop {#1} |
| 3237 |
{ |
| 3238 |
{ \exp_not:o \l__xeCJK_sub_font_options_clist } |
| 3239 |
{ \exp_not:o \l__xeCJK_sub_font_name_tl } |
| 3240 |
} |
| 3241 |
} |
| 3242 |
\cs_new_protected:Npn \__xeCJK_get_sub_features:w #1 [#2] #3 \q_mark #4 \q_stop |
| 3243 |
{ |
| 3244 |
\quark_if_nil:nTF {#2} |
| 3245 |
{ \tl_set_eq:NN \l__xeCJK_sub_font_name_tl \l__xeCJK_tmp_tl } |
| 3246 |
{ |
| 3247 |
\tl_set:Nx \l__xeCJK_sub_font_name_tl |
| 3248 |
{ \xeCJK_tl_remove_outer_braces:n {#3} } |
| 3249 |
\tl_if_empty:NTF \l__xeCJK_sub_font_name_tl |
| 3250 |
{ \tl_set_eq:NN \l__xeCJK_sub_font_name_tl \l__xeCJK_tmp_tl } |
| 3251 |
{ \clist_set:Nn \l__xeCJK_sub_font_options_clist {#2} } |
| 3252 |
} |
| 3253 |
} |
| 3254 |
\tl_new:N \l__xeCJK_sub_family_name_tl |
| 3255 |
\tl_new:N \l__xeCJK_sub_font_name_tl |
| 3256 |
\clist_new:N \l__xeCJK_sub_font_options_clist |
| 3257 |
\cs_generate_variant:Nn \__xeCJK_get_sub_features:nn { o } |
| 3258 |
\cs_generate_variant:Nn \tl_replace_all:Nnn { Nno } |
| 3259 |
\xeCJK_new_sub_key:n { FallBack } |
| 3260 |
\keys_define:nn { xeCJK / features } |
| 3261 |
{ |
| 3262 |
BoldFont .tl_set:N = \l__xeCJK_font_name_bf_tl , |
| 3263 |
ItalicFont .tl_set:N = \l__xeCJK_font_name_it_tl |
| 3264 |
} |
| 3265 |
\keys_define:nn { xeCJK / features } |
| 3266 |
{ |
| 3267 |
AutoFakeBold .choice: , |
| 3268 |
AutoFakeBold / true .code:n = |
| 3269 |
{ |
| 3270 |
\bool_set_true:N \l__xeCJK_auto_fake_bold_bool |
| 3271 |
\fp_set_eq:NN \l__xeCJK_embolden_factor_fp \g__xeCJK_embolden_factor_fp |
| 3272 |
} , |
| 3273 |
AutoFakeBold / false .code:n = |
| 3274 |
{ \bool_set_false:N \l__xeCJK_auto_fake_bold_bool } , |
| 3275 |
AutoFakeBold / unknown .code:n = |
| 3276 |
{ |
| 3277 |
\bool_set_true:N \l__xeCJK_auto_fake_bold_bool |
| 3278 |
\fp_set:Nn \l__xeCJK_embolden_factor_fp { \l_keys_value_tl } |
| 3279 |
} , |
| 3280 |
AutoFakeBold .default:n = { true } , |
| 3281 |
AutoFakeSlant .choice: , |
| 3282 |
AutoFakeSlant / true .code:n = |
| 3283 |
{ |
| 3284 |
\bool_set_true:N \l__xeCJK_auto_fake_slant_bool |
| 3285 |
\fp_set_eq:NN \l__xeCJK_slant_factor_fp \g__xeCJK_slant_factor_fp |
| 3286 |
} , |
| 3287 |
AutoFakeSlant / false .code:n = |
| 3288 |
{ \bool_set_false:N \l__xeCJK_auto_fake_slant_bool } , |
| 3289 |
AutoFakeSlant / unknown .code:n = |
| 3290 |
{ |
| 3291 |
\bool_set_true:N \l__xeCJK_auto_fake_slant_bool |
| 3292 |
\fp_set:Nn \l__xeCJK_slant_factor_fp { \l_keys_value_tl } |
| 3293 |
} , |
| 3294 |
AutoFakeSlant .default:n = { true } |
| 3295 |
} |
| 3296 |
\cs_new_protected:Npn \__xeCJK_set_family_initial: |
| 3297 |
{ |
| 3298 |
\int_gincr:N \g__xeCJK_family_int |
| 3299 |
\prop_clear:N \l__xeCJK_sub_key_prop |
| 3300 |
\tl_clear:N \l__xeCJK_font_name_bf_tl |
| 3301 |
\tl_clear:N \l__xeCJK_font_name_it_tl |
| 3302 |
\tl_clear:N \l__xeCJK_sub_family_name_tl |
| 3303 |
\clist_clear:N \l__xeCJK_fontspec_options_clist |
| 3304 |
\bool_set_eq:NN \l__xeCJK_auto_fake_bold_bool \g__xeCJK_auto_fake_bold_bool |
| 3305 |
\bool_set_eq:NN \l__xeCJK_auto_fake_slant_bool \g__xeCJK_auto_fake_slant_bool |
| 3306 |
\fp_set_eq:NN \l__xeCJK_embolden_factor_fp \g__xeCJK_embolden_factor_fp |
| 3307 |
\fp_set_eq:NN \l__xeCJK_slant_factor_fp \g__xeCJK_slant_factor_fp |
| 3308 |
} |
| 3309 |
\int_new:N \g__xeCJK_family_int |
| 3310 |
\prop_new:N \l__xeCJK_sub_key_prop |
| 3311 |
\clist_new:N \l__xeCJK_fontspec_options_clist |
| 3312 |
\bool_new:N \l__xeCJK_auto_fake_bold_bool |
| 3313 |
\bool_new:N \l__xeCJK_auto_fake_slant_bool |
| 3314 |
\fp_new:N \l__xeCJK_embolden_factor_fp |
| 3315 |
\fp_new:N \l__xeCJK_slant_factor_fp |
| 3316 |
\cs_new_protected:Npn \xeCJK_set_family:nnn #1#2#3 |
| 3317 |
{ |
| 3318 |
\group_begin: |
| 3319 |
\__xeCJK_set_family_initial: |
| 3320 |
\tl_set:Nn \l__xeCJK_family_name_tl {#1} |
| 3321 |
\clist_set:Nn \l__xeCJK_font_options_clist {#2} |
| 3322 |
\tl_set:Nn \l__xeCJK_font_name_tl {#3} |
| 3323 |
\clist_concat:NNN \l__xeCJK_font_options_clist |
| 3324 |
\g__xeCJK_default_features_clist \l__xeCJK_font_options_clist |
| 3325 |
\keys_set_known:noN { xeCJK / features } |
| 3326 |
\l__xeCJK_font_options_clist \l__xeCJK_fontspec_options_clist |
| 3327 |
\__xeCJK_binding_sub_family: |
| 3328 |
\__xeCJK_parse_font_shape: |
| 3329 |
\__xeCJK_check_family:o \l__xeCJK_family_name_tl |
| 3330 |
\__xeCJK_gset_family_cs:n { \l__xeCJK_family_name_tl } |
| 3331 |
\__xeCJK_save_family_info: |
| 3332 |
\__xeCJK_set_sub_block_family: |
| 3333 |
\group_end: |
| 3334 |
} |
| 3335 |
\tl_new:N \l__xeCJK_family_name_tl |
| 3336 |
\tl_new:N \l__xeCJK_font_name_tl |
| 3337 |
\clist_new:N \l__xeCJK_font_options_clist |
| 3338 |
\cs_generate_variant:Nn \xeCJK_set_family:nnn { e , o } |
| 3339 |
\cs_new_protected:Npn \__xeCJK_binding_sub_family: |
| 3340 |
{ |
| 3341 |
\tl_if_empty:NF \l__xeCJK_sub_family_name_tl |
| 3342 |
{ \tl_set_eq:NN \l__xeCJK_family_name_tl \l__xeCJK_sub_family_name_tl } |
| 3343 |
} |
| 3344 |
\cs_new_protected:Npn \__xeCJK_gset_family_cs:n #1 |
| 3345 |
{ |
| 3346 |
\cs_gset_protected:cpx { \__xeCJK_family_csname:n {#1} } |
| 3347 |
{ |
| 3348 |
\group_begin: |
| 3349 |
\exp_not:n { \cs_set_eq:NN \xeCJK@fontfamily \use_none:n } |
| 3350 |
\exp_not:n { \fontspec_gset_family:Nnn \g__xeCJK_fontspec_family_tl } |
| 3351 |
{ \exp_not:o \l__xeCJK_fontspec_options_clist } |
| 3352 |
{ \exp_not:o \l__xeCJK_font_name_tl } |
| 3353 |
\__xeCJK_gset_family_nfss_cs:no |
| 3354 |
{#1} { \exp_not:N \g__xeCJK_fontspec_family_tl } |
| 3355 |
\group_end: |
| 3356 |
\tl_set_eq:NN \exp_not:N \l__xeCJK_fontspec_family_tl |
| 3357 |
\exp_not:N \g__xeCJK_fontspec_family_tl |
| 3358 |
} |
| 3359 |
} |
| 3360 |
\tl_new:N \g__xeCJK_fontspec_family_tl |
| 3361 |
\tl_new:N \l__xeCJK_fontspec_family_tl |
| 3362 |
\cs_new_protected:Npn \__xeCJK_check_family:n #1 |
| 3363 |
{ |
| 3364 |
\prop_gpop:NnNT \g__xeCJK_family_font_name_prop {#1} \l__xeCJK_tmp_tl |
| 3365 |
{ |
| 3366 |
\prop_gpop:NnNT \g__xeCJK_family_name_prop {#1} \l__xeCJK_tmp_tl |
| 3367 |
{ |
| 3368 |
\cs_undefine:c { \__xeCJK_family_csname:n {#1} } |
| 3369 |
\cs_undefine:c { \__xeCJK_family_nfss_csname:n {#1} } |
| 3370 |
} |
| 3371 |
\__xeCJK_warning:nxx { CJKfamily-redef } {#1} { \l__xeCJK_tmp_tl } |
| 3372 |
} |
| 3373 |
} |
| 3374 |
\cs_generate_variant:Nn \__xeCJK_check_family:n { o } |
| 3375 |
\__xeCJK_msg_new:nn { CJKfamily-redef } |
| 3376 |
{ Redefining~CJKfamily~`\__xeCJK_msg_family_map:n {#1}'~(#2). } |
| 3377 |
\cs_new_protected:Npn \__xeCJK_parse_font_shape: |
| 3378 |
{ |
| 3379 |
\tl_if_blank:oTF \l__xeCJK_font_name_bf_tl |
| 3380 |
{ |
| 3381 |
\bool_if:NT \l__xeCJK_auto_fake_bold_bool |
| 3382 |
{ |
| 3383 |
\clist_put_right:Nx \l__xeCJK_fontspec_options_clist |
| 3384 |
{ AutoFakeBold = { \fp_use:N \l__xeCJK_embolden_factor_fp } } |
| 3385 |
} |
| 3386 |
} |
| 3387 |
{ |
| 3388 |
\clist_put_right:Nx \l__xeCJK_fontspec_options_clist |
| 3389 |
{ BoldFont = { \exp_not:o \l__xeCJK_font_name_bf_tl } } |
| 3390 |
} |
| 3391 |
\tl_if_blank:oTF \l__xeCJK_font_name_it_tl |
| 3392 |
{ |
| 3393 |
\bool_if:NT \l__xeCJK_auto_fake_slant_bool |
| 3394 |
{ |
| 3395 |
\clist_put_right:Nx \l__xeCJK_fontspec_options_clist |
| 3396 |
{ AutoFakeSlant = { \fp_use:N \l__xeCJK_slant_factor_fp } } |
| 3397 |
} |
| 3398 |
} |
| 3399 |
{ |
| 3400 |
\clist_put_right:Nx \l__xeCJK_fontspec_options_clist |
| 3401 |
{ ItalicFont = { \exp_not:o \l__xeCJK_font_name_it_tl } } |
| 3402 |
} |
| 3403 |
} |
| 3404 |
\prop_new:N \g__xeCJK_family_name_prop |
| 3405 |
\prop_new:N \g__xeCJK_family_font_name_prop |
| 3406 |
\prop_new:N \g__xeCJK_family_font_options_prop |
| 3407 |
\cs_new_protected:Npn \__xeCJK_save_family_info: |
| 3408 |
{ |
| 3409 |
\exp_args:Nooo \__xeCJK_save_family_info:nnn |
| 3410 |
\l__xeCJK_family_name_tl |
| 3411 |
\l__xeCJK_font_name_tl |
| 3412 |
\l__xeCJK_font_options_clist |
| 3413 |
} |
| 3414 |
\cs_new_protected:Npn \__xeCJK_save_family_info:nnn #1#2#3 |
| 3415 |
{ |
| 3416 |
\prop_gput:Nnn \g__xeCJK_family_font_name_prop {#1} {#2} |
| 3417 |
\prop_gput:Nnn \g__xeCJK_family_font_options_prop {#1} {#3} |
| 3418 |
} |
| 3419 |
\cs_new_protected:Npn \__xeCJK_set_sub_block_family: |
| 3420 |
{ |
| 3421 |
\prop_if_empty:NF \l__xeCJK_sub_key_prop |
| 3422 |
{ |
| 3423 |
\prop_map_function:NN |
| 3424 |
\l__xeCJK_sub_key_prop |
| 3425 |
\__xeCJK_set_sub_block_family:nn |
| 3426 |
} |
| 3427 |
} |
| 3428 |
\cs_new_protected:Npn \__xeCJK_set_sub_block_family:nn #1#2 |
| 3429 |
{ |
| 3430 |
\tl_set:Nx \l__xeCJK_sub_family_name_tl { \l__xeCJK_family_name_tl/#1 } |
| 3431 |
\quark_if_no_value:nTF {#2} |
| 3432 |
{ \__xeCJK_copy_sub_family:n {#1} } |
| 3433 |
{ \xeCJK_set_family:onn \l__xeCJK_sub_family_name_tl #2 } |
| 3434 |
} |
| 3435 |
\cs_new_protected:Npn \__xeCJK_copy_sub_family:n #1 |
| 3436 |
{ |
| 3437 |
\__xeCJK_check_family:o \l__xeCJK_sub_family_name_tl |
| 3438 |
\prop_get:NoNT \g__xeCJK_family_font_name_prop |
| 3439 |
\l__xeCJK_family_name_tl \l__xeCJK_sub_font_name_tl |
| 3440 |
{ |
| 3441 |
\prop_gput:Noo \g__xeCJK_family_font_name_prop |
| 3442 |
\l__xeCJK_sub_family_name_tl \l__xeCJK_sub_font_name_tl |
| 3443 |
} |
| 3444 |
\prop_get:NoNT \g__xeCJK_family_font_options_prop |
| 3445 |
\l__xeCJK_family_name_tl \l__xeCJK_sub_font_options_clist |
| 3446 |
{ |
| 3447 |
\clist_remove_all:Nn \l__xeCJK_sub_font_options_clist { #1 = * } |
| 3448 |
\prop_gput:Noo \g__xeCJK_family_font_options_prop |
| 3449 |
\l__xeCJK_sub_family_name_tl \l__xeCJK_sub_font_options_clist |
| 3450 |
} |
| 3451 |
\cs_gset_protected:cpx |
| 3452 |
{ \__xeCJK_family_csname:n { \l__xeCJK_sub_family_name_tl } } |
| 3453 |
{ |
| 3454 |
\xeCJK_family_if_exist:eT { \l__xeCJK_family_name_tl } |
| 3455 |
{ |
| 3456 |
\__xeCJK_gset_family_nfss_cs:no |
| 3457 |
{ \l__xeCJK_sub_family_name_tl } |
| 3458 |
{ \exp_not:N \l__xeCJK_fontspec_family_tl } |
| 3459 |
} |
| 3460 |
} |
| 3461 |
} |
| 3462 |
\cs_new_protected:Npn \__xeCJK_copy_family:nn #1#2 |
| 3463 |
{ |
| 3464 |
\xeCJK_family_if_exist:nT {#2} |
| 3465 |
{ |
| 3466 |
\prop_gput:Nno \g__xeCJK_family_name_prop |
| 3467 |
{#1} \l__xeCJK_fontspec_family_tl |
| 3468 |
\tl_map_inline:nn |
| 3469 |
{ |
| 3470 |
\g__xeCJK_family_font_name_prop |
| 3471 |
\g__xeCJK_family_font_options_prop |
| 3472 |
} |
| 3473 |
{ |
| 3474 |
\prop_get:NnNT ##1 {#2} \l__xeCJK_tmp_tl |
| 3475 |
{ \prop_gput:Nno ##1 {#1} \l__xeCJK_tmp_tl } |
| 3476 |
} |
| 3477 |
\cs_gset_eq:cc |
| 3478 |
{ \__xeCJK_family_nfss_csname:n {#1} } |
| 3479 |
{ \__xeCJK_family_nfss_csname:n {#2} } |
| 3480 |
} |
| 3481 |
} |
| 3482 |
\cs_generate_variant:Nn \__xeCJK_copy_family:nn { ee } |
| 3483 |
\cs_new:Npn \__xeCJK_font_csname:n #1 |
| 3484 |
{ xeCJK/#1/\f@series/\f@shape/\f@size } |
| 3485 |
\tl_new:N \l_xeCJK_current_font_tl |
| 3486 |
\tl_set:No \l_xeCJK_current_font_tl |
| 3487 |
{ \__xeCJK_font_csname:n { \CJK@family } } |
| 3488 |
\cs_new_protected:Npn \xeCJK_select_font: |
| 3489 |
{ |
| 3490 |
\__xeCJK_select_font:cn |
| 3491 |
{ \l_xeCJK_current_font_tl } |
| 3492 |
{ \l_xeCJK_family_tl } |
| 3493 |
} |
| 3494 |
\cs_new_protected:Npn \__xeCJK_select_font:Nn #1#2 |
| 3495 |
{ |
| 3496 |
\xeCJK_clear_fallback_font: |
| 3497 |
\cs_if_exist:NF #1 { \__xeCJK_font_initial:Nn #1 {#2} } |
| 3498 |
#1 |
| 3499 |
} |
| 3500 |
\cs_generate_variant:Nn \__xeCJK_select_font:Nn { c } |
| 3501 |
\tl_new:N \l__xeCJK_current_coor_tl |
| 3502 |
\cs_new_eq:NN \xeCJK@setfont \xeCJK_select_font: |
| 3503 |
\cs_new_protected:Npn \__xeCJK_font_initial:Nn #1#2 |
| 3504 |
{ |
| 3505 |
\group_begin: |
| 3506 |
\__xeCJK_font_initial_hook: |
| 3507 |
\__xeCJK_family_use:n {#2} |
| 3508 |
\xeCJK_font_gset_to_current:N #1 |
| 3509 |
\group_end: |
| 3510 |
} |
| 3511 |
\cs_new_protected:Npn \__xeCJK_font_initial_hook: |
| 3512 |
{ \tl_use:N \g__xeCJK_font_initial_hook_tl } |
| 3513 |
\cs_new_protected:Npn \__xeCJK_gadd_font_initial_hook:n |
| 3514 |
{ \tl_gput_right:Nn \g__xeCJK_font_initial_hook_tl } |
| 3515 |
\tl_new:N \g__xeCJK_font_initial_hook_tl |
| 3516 |
\cs_new_eq:NN \xeCJK_select_punct_font: \xeCJK_select_font: |
| 3517 |
\cs_new_protected:Npn \__xeCJK_select_punct_font_aux: |
| 3518 |
{ |
| 3519 |
\__xeCJK_select_font:cn |
| 3520 |
{ \l_xeCJK_current_punct_font_tl } |
| 3521 |
{ \l_xeCJK_punct_family_tl } |
| 3522 |
} |
| 3523 |
\tl_new:N \CJK@punctfamily |
| 3524 |
\tl_new:N \l_xeCJK_punct_family_tl |
| 3525 |
\tl_new:N \l_xeCJK_current_punct_font_tl |
| 3526 |
\tl_set:Nn \CJK@punctfamily { \CJK@family } |
| 3527 |
\tl_set:Nn \l_xeCJK_punct_family_tl { \l_xeCJK_family_tl } |
| 3528 |
\tl_set:No \l_xeCJK_current_punct_font_tl |
| 3529 |
{ \__xeCJK_font_csname:n { \CJK@punctfamily } } |
| 3530 |
\cs_new_eq:NN \__xeCJK_select_font: \prg_do_nothing: |
| 3531 |
\cs_new_eq:NN \__xeCJK_select_punct_font: \prg_do_nothing: |
| 3532 |
\cs_new_protected:Npn \__xeCJK_switch_font:nn #1#2 |
| 3533 |
{ |
| 3534 |
\str_if_eq:nnF {#1} {#2} |
| 3535 |
{ |
| 3536 |
\__xeCJK_info:nxx { CJK-block } {#1} {#2} |
| 3537 |
\str_if_eq:nnTF {#2} { CJK } |
| 3538 |
{ \xeCJK_select_font: } |
| 3539 |
{ \xeCJK_select_font:n {#2} } |
| 3540 |
} |
| 3541 |
} |
| 3542 |
\__xeCJK_msg_new:nn { CJK-block } { Switch~from~block~`#1'~to~`#2'. } |
| 3543 |
\cs_new_protected:Npn \xeCJK_select_font:n #1 |
| 3544 |
{ |
| 3545 |
\__xeCJK_select_font:cnn |
| 3546 |
{ \__xeCJK_font_csname:n { \CJK@family/#1 } } |
| 3547 |
{ \l_xeCJK_family_tl } |
| 3548 |
{#1} |
| 3549 |
} |
| 3550 |
\cs_new_protected:Npn \__xeCJK_select_font:Nnn #1#2#3 |
| 3551 |
{ |
| 3552 |
\xeCJK_clear_fallback_font: |
| 3553 |
\cs_if_exist:NF #1 |
| 3554 |
{ \__xeCJK_block_font_initial:Nnn #1 {#2} {#3} } |
| 3555 |
#1 |
| 3556 |
} |
| 3557 |
\cs_generate_variant:Nn \__xeCJK_select_font:Nnn { c } |
| 3558 |
\cs_new_protected:Npn \__xeCJK_block_font_initial:Nnn #1#2#3 |
| 3559 |
{ |
| 3560 |
\xeCJK_block_family:nn {#2} {#3} |
| 3561 |
\__xeCJK_font_initial:Nn #1 { #2/#3 } |
| 3562 |
} |
| 3563 |
\cs_new_protected:Npn \xeCJK_block_family:nn #1#2 |
| 3564 |
{ |
| 3565 |
\xeCJK_family_if_exist:eF { #1/#2 } |
| 3566 |
{ |
| 3567 |
\__xeCJK_copy_family:ee { #1/#2 } |
| 3568 |
{ |
| 3569 |
\cs_if_exist:cTF |
| 3570 |
{ \__xeCJK_family_csname:n { \CJKfamilydefault/#2 } } |
| 3571 |
{ \CJKfamilydefault/#2 } {#1} |
| 3572 |
} |
| 3573 |
} |
| 3574 |
} |
| 3575 |
\cs_new:Npn \__xeCJK_family_csname:n #1 |
| 3576 |
{ xeCJK/family/#1 } |
| 3577 |
\cs_new:Npn \__xeCJK_family_nfss_csname:n #1 |
| 3578 |
{ xeCJK/family/nfss/#1 } |
| 3579 |
\cs_new_protected:Npn \__xeCJK_family_use:n #1 |
| 3580 |
{ \use:c { \__xeCJK_family_nfss_csname:n {#1} } } |
| 3581 |
\cs_new_protected:Npn \__xeCJK_gset_family_nfss_cs:nn #1#2 |
| 3582 |
{ |
| 3583 |
\prop_gput:Nnn \g__xeCJK_family_name_prop {#1} {#2} |
| 3584 |
\cs_gset_protected:cpx |
| 3585 |
{ \__xeCJK_family_nfss_csname:n {#1} } |
| 3586 |
{ \__xeCJK_nfss_family:nn { \c__xeCJK_encoding_tl } {#2} } |
| 3587 |
} |
| 3588 |
\cs_generate_variant:Nn \__xeCJK_gset_family_nfss_cs:nn { no } |
| 3589 |
\cs_if_exist:NTF \fontseriesforce |
| 3590 |
{ |
| 3591 |
\cs_new_protected:Npn \__xeCJK_nfss_family:nn #1#2 |
| 3592 |
{ |
| 3593 |
\fontencoding {#1} |
| 3594 |
\str_if_eq:eeF { \f@series } { \bfdefault } |
| 3595 |
{ |
| 3596 |
\str_case_e:nn { \f@family } |
| 3597 |
{ |
| 3598 |
{ \rmdefault } { \__xeCJK_nfss_series:n { rm } } |
| 3599 |
{ \sfdefault } { \__xeCJK_nfss_series:n { sf } } |
| 3600 |
{ \ttdefault } { \__xeCJK_nfss_series:n { tt } } |
| 3601 |
} |
| 3602 |
} |
| 3603 |
\fontfamily {#2} |
| 3604 |
\selectfont |
| 3605 |
} |
| 3606 |
\cs_new_protected:Npn \__xeCJK_nfss_series:n #1 |
| 3607 |
{ |
| 3608 |
\str_if_eq:eeT { \f@series } { \use:c { bfseries@#1 } } |
| 3609 |
{ \fontseriesforce { \bfdefault } } |
| 3610 |
} |
| 3611 |
} |
| 3612 |
{ |
| 3613 |
\cs_new_protected:Npn \__xeCJK_nfss_family:nn #1#2 |
| 3614 |
{ |
| 3615 |
\fontencoding {#1} |
| 3616 |
\tl_set:Nn \f@family {#2} |
| 3617 |
\selectfont |
| 3618 |
} |
| 3619 |
} |
| 3620 |
\prg_new_protected_conditional:Npnn \xeCJK_family_if_exist:n #1 { T , F , TF } |
| 3621 |
{ |
| 3622 |
\prop_get:NnNTF \g__xeCJK_family_name_prop |
| 3623 |
{#1} \l__xeCJK_fontspec_family_tl |
| 3624 |
{ \prg_return_true: } |
| 3625 |
{ |
| 3626 |
\exp_args:Ne \cs_if_exist_use:cTF |
| 3627 |
{ \__xeCJK_family_csname:n {#1} } |
| 3628 |
{ \prg_return_true: } |
| 3629 |
{ \prg_return_false: } |
| 3630 |
} |
| 3631 |
} |
| 3632 |
\prg_generate_conditional_variant:Nnn \xeCJK_family_if_exist:n { e } { T , F , TF } |
| 3633 |
\NewDocumentCommand \CJKfamily { t+ t- m } |
| 3634 |
{ |
| 3635 |
\xeCJK_family:NNe #1 #2 {#3} |
| 3636 |
\tex_ignorespaces:D |
| 3637 |
} |
| 3638 |
\cs_new_protected:Npn \xeCJK_family:NNn #1#2#3 |
| 3639 |
{ |
| 3640 |
\tl_if_blank:nTF {#3} |
| 3641 |
{ |
| 3642 |
\bool_if:NF #1 { \bool_if:NF #2 { \use_none:nn } } |
| 3643 |
\xeCJK_family_if_exist_use:e { \l_xeCJK_family_tl } |
| 3644 |
} |
| 3645 |
{ |
| 3646 |
\bool_if:NTF #2 |
| 3647 |
{ \xeCJK_family_if_exist_use:n {#3} } |
| 3648 |
{ |
| 3649 |
\xeCJK_family_if_exist:nTF {#3} |
| 3650 |
{ |
| 3651 |
\tl_set:Nn \l_xeCJK_family_tl {#3} |
| 3652 |
\tl_set_eq:NN \CJK@family \l__xeCJK_fontspec_family_tl |
| 3653 |
\bool_if:NT #1 { \__xeCJK_family_use:n {#3} } |
| 3654 |
} |
| 3655 |
{ \__xeCJK_family_unknown_warning:n {#3} } |
| 3656 |
} |
| 3657 |
} |
| 3658 |
} |
| 3659 |
\cs_generate_variant:Nn \xeCJK_family:NNn { NNe } |
| 3660 |
\cs_new_protected:Npn \xeCJK_switch_family:n #1 |
| 3661 |
{ |
| 3662 |
\xeCJK_family_if_exist:nTF {#1} |
| 3663 |
{ |
| 3664 |
\tl_set:Nn \l_xeCJK_family_tl {#1} |
| 3665 |
\tl_set_eq:NN \CJK@family \l__xeCJK_fontspec_family_tl |
| 3666 |
} |
| 3667 |
{ \__xeCJK_family_unknown_warning:n {#1} } |
| 3668 |
} |
| 3669 |
\cs_generate_variant:Nn \xeCJK_switch_family:n { e , o } |
| 3670 |
\keys_define:nn { xeCJK / options } |
| 3671 |
{ |
| 3672 |
PunctFamily .choice: , |
| 3673 |
PunctFamily .value_required:n = { true } , |
| 3674 |
PunctFamily / false .code:n = |
| 3675 |
{ |
| 3676 |
\tl_set:Nn \CJK@punctfamily { \CJK@family } |
| 3677 |
\tl_set:Nn \l_xeCJK_punct_family_tl { \l_xeCJK_family_tl } |
| 3678 |
\xeCJK_cs_clear:N \__xeCJK_select_font: |
| 3679 |
\xeCJK_cs_clear:N \__xeCJK_select_punct_font: |
| 3680 |
\cs_set_eq:NN \xeCJK_select_punct_font: \xeCJK_select_font: |
| 3681 |
} , |
| 3682 |
PunctFamily / unknown .code:n = |
| 3683 |
{ \xeCJK_punct_family:e {#1} } , |
| 3684 |
} |
| 3685 |
\cs_new_protected:Npn \xeCJK_punct_family:n #1 |
| 3686 |
{ |
| 3687 |
\xeCJK_family_if_exist:nTF {#1} |
| 3688 |
{ |
| 3689 |
\tl_set:Nn \l_xeCJK_punct_family_tl {#1} |
| 3690 |
\tl_set_eq:NN \CJK@punctfamily \l__xeCJK_fontspec_family_tl |
| 3691 |
\cs_set_eq:NN \__xeCJK_select_font: \xeCJK_select_font: |
| 3692 |
\cs_set_eq:NN \__xeCJK_select_punct_font: \__xeCJK_select_punct_font_aux: |
| 3693 |
\cs_set_eq:NN \xeCJK_select_punct_font: \__xeCJK_select_punct_font: |
| 3694 |
} |
| 3695 |
{ \__xeCJK_family_unknown_warning:n {#1} } |
| 3696 |
} |
| 3697 |
\cs_generate_variant:Nn \xeCJK_punct_family:n { e } |
| 3698 |
\tl_new:N \l_xeCJK_family_tl |
| 3699 |
\tl_new:N \CJK@family |
| 3700 |
\cs_new_protected:Npn \__xeCJK_gobble_CJKfamily: |
| 3701 |
{ \cs_set_eq:NN \CJKfamily \__xeCJK_gobble_CJKfamily:wn } |
| 3702 |
\NewExpandableDocumentCommand \__xeCJK_gobble_CJKfamily:wn { t+ t- m } { } |
| 3703 |
\cs_new_protected:Npn \xeCJK_family_if_exist_use:n #1 |
| 3704 |
{ |
| 3705 |
\xeCJK_family_if_exist:nTF {#1} |
| 3706 |
{ \__xeCJK_family_use:n {#1} } |
| 3707 |
{ \__xeCJK_family_unknown_warning:n {#1} } |
| 3708 |
} |
| 3709 |
\cs_generate_variant:Nn \xeCJK_family_if_exist_use:n { e } |
| 3710 |
\cs_new_protected:Npn \__xeCJK_family_unknown_warning:n #1 |
| 3711 |
{ |
| 3712 |
\prop_if_empty:NF \g__xeCJK_family_font_name_prop |
| 3713 |
{ |
| 3714 |
\seq_if_in:NnF \g__xeCJK_unknown_family_seq {#1} |
| 3715 |
{ |
| 3716 |
\seq_gput_right:Nn \g__xeCJK_unknown_family_seq {#1} |
| 3717 |
\__xeCJK_warning:nx { CJKfamily-Unknown } {#1} |
| 3718 |
} |
| 3719 |
} |
| 3720 |
} |
| 3721 |
\seq_new:N \g__xeCJK_unknown_family_seq |
| 3722 |
\__xeCJK_msg_new:nn { CJKfamily-Unknown } |
| 3723 |
{ |
| 3724 |
Unknown~CJK~family~`\__xeCJK_msg_family_map:n {#1}'~is~being~ignored.\\\\ |
| 3725 |
Try~to~use~`\__xeCJK_msg_def_family_map:n {#1}'~to~define~it. |
| 3726 |
} |
| 3727 |
\cs_new:Npn \__xeCJK_msg_def_family_map:n #1 |
| 3728 |
{ |
| 3729 |
\str_case_e:nnF {#1} |
| 3730 |
{ |
| 3731 |
\CJKrmdefault { \token_to_str:N \setCJKmainfont } |
| 3732 |
\CJKsfdefault { \token_to_str:N \setCJKsansfont } |
| 3733 |
\CJKttdefault { \token_to_str:N \setCJKmonofont } |
| 3734 |
} |
| 3735 |
{ \token_to_str:N \setCJKfamilyfont \{ #1 \} } |
| 3736 |
[<...>]\{<...>\} |
| 3737 |
} |
| 3738 |
\cs_new:Npn \__xeCJK_msg_family_map:n #1 |
| 3739 |
{ |
| 3740 |
\str_case_e:nnF {#1} |
| 3741 |
{ |
| 3742 |
\CJKrmdefault { \token_to_str:N \CJKrmdefault } |
| 3743 |
\CJKsfdefault { \token_to_str:N \CJKsfdefault } |
| 3744 |
\CJKttdefault { \token_to_str:N \CJKttdefault } |
| 3745 |
} |
| 3746 |
{#1} |
| 3747 |
} |
| 3748 |
\cs_new_protected:Npn \__xeCJK_pass_args:nnnn #1#2#3#4 |
| 3749 |
{ |
| 3750 |
\tl_if_novalue:nTF {#2} |
| 3751 |
{ \__xeCJK_post_arg:w {#1} {#3} {#4} } |
| 3752 |
{ |
| 3753 |
\use:e { #1 {#2} {#3} } |
| 3754 |
#4 |
| 3755 |
} |
| 3756 |
} |
| 3757 |
\NewDocumentCommand \__xeCJK_post_arg:w { m m m O { } } |
| 3758 |
{ |
| 3759 |
\use:e { #1 {#4} {#2} } |
| 3760 |
#3 |
| 3761 |
} |
| 3762 |
\NewDocumentCommand \setCJKmainfont { o m } |
| 3763 |
{ |
| 3764 |
\__xeCJK_pass_args:nnnn |
| 3765 |
{ \xeCJK_set_family:nnn { \CJKrmdefault } } {#1} {#2} |
| 3766 |
{ \__xeCJK_preamble_family:n { \CJKrmdefault } } |
| 3767 |
} |
| 3768 |
\cs_new_eq:NN \setCJKromanfont \setCJKmainfont |
| 3769 |
\NewDocumentCommand \setCJKsansfont { o m } |
| 3770 |
{ |
| 3771 |
\__xeCJK_pass_args:nnnn |
| 3772 |
{ \xeCJK_set_family:nnn { \CJKsfdefault } } {#1} {#2} |
| 3773 |
{ \__xeCJK_preamble_family:n { \CJKsfdefault } } |
| 3774 |
} |
| 3775 |
\NewDocumentCommand \setCJKmonofont { o m } |
| 3776 |
{ |
| 3777 |
\__xeCJK_pass_args:nnnn |
| 3778 |
{ \xeCJK_set_family:nnn { \CJKttdefault } } {#1} {#2} |
| 3779 |
{ \__xeCJK_preamble_family:n { \CJKttdefault } } |
| 3780 |
} |
| 3781 |
\@onlypreamble \setCJKmainfont |
| 3782 |
\@onlypreamble \setCJKmathfont |
| 3783 |
\@onlypreamble \setCJKsansfont |
| 3784 |
\@onlypreamble \setCJKmonofont |
| 3785 |
\@onlypreamble \setCJKromanfont |
| 3786 |
\cs_new_protected:Npn \__xeCJK_preamble_family:n #1 |
| 3787 |
{ \str_if_eq:eeT {#1} { \CJKfamilydefault } { \normalfont } } |
| 3788 |
\NewDocumentCommand \setCJKfamilyfont { m o m } |
| 3789 |
{ |
| 3790 |
\__xeCJK_pass_args:nnnn |
| 3791 |
{ \xeCJK_set_family:nnn {#1} } {#2} {#3} |
| 3792 |
{ } |
| 3793 |
} |
| 3794 |
\NewDocumentCommand \newCJKfontfamily { o m o m } |
| 3795 |
{ |
| 3796 |
\tl_set:Nx \l__xeCJK_tmp_tl |
| 3797 |
{ \tl_if_novalue:nTF {#1} { \cs_to_str:N #2 } {#1} } |
| 3798 |
\cs_new_protected:Npx #2 |
| 3799 |
{ \xeCJK_switch_family:n { \l__xeCJK_tmp_tl } } |
| 3800 |
\__xeCJK_pass_args:nnnn |
| 3801 |
{ \xeCJK_set_family:nnn { \l__xeCJK_tmp_tl } } {#3} {#4} |
| 3802 |
{ } |
| 3803 |
} |
| 3804 |
\NewDocumentCommand \CJKfontspec { o m } |
| 3805 |
{ |
| 3806 |
\__xeCJK_pass_args:nnnn |
| 3807 |
{ \xeCJK_fontspec:nn } {#1} {#2} |
| 3808 |
{ \tex_ignorespaces:D } |
| 3809 |
} |
| 3810 |
\cs_new_protected:Npn \xeCJK_fontspec:nn #1#2 |
| 3811 |
{ |
| 3812 |
\prop_get:NnNTF \g__xeCJK_fontspec_prop |
| 3813 |
{ CJKfontspec/#1/#2/id } \l_xeCJK_family_tl |
| 3814 |
{ \xeCJK_switch_family:o { \l_xeCJK_family_tl } } |
| 3815 |
{ |
| 3816 |
\__xeCJK_fontspec:enn |
| 3817 |
{ CJKfontspec ( \int_eval:n { \g__xeCJK_family_int + 1 } ) } |
| 3818 |
{#1} {#2} |
| 3819 |
} |
| 3820 |
} |
| 3821 |
\cs_new_protected:Npn \__xeCJK_fontspec:nnn #1#2#3 |
| 3822 |
{ |
| 3823 |
\prop_gput:Nnn \g__xeCJK_fontspec_prop { CJKfontspec/#2/#3/id } {#1} |
| 3824 |
\xeCJK_set_family:nnn {#1} {#2} {#3} |
| 3825 |
\xeCJK_switch_family:n {#1} |
| 3826 |
} |
| 3827 |
\cs_generate_variant:Nn \xeCJK_fontspec:nn { oo } |
| 3828 |
\cs_generate_variant:Nn \__xeCJK_fontspec:nnn { e } |
| 3829 |
\prop_new:N \g__xeCJK_fontspec_prop |
| 3830 |
\clist_new:N \g__xeCJK_default_features_clist |
| 3831 |
\NewDocumentCommand \defaultCJKfontfeatures { m } |
| 3832 |
{ \clist_gset:Nn \g__xeCJK_default_features_clist {#1} } |
| 3833 |
\@onlypreamble \defaultCJKfontfeatures |
| 3834 |
\NewDocumentCommand \addCJKfontfeatures { s O { } m } |
| 3835 |
{ |
| 3836 |
\xeCJK_add_font_features:Nee #1 {#2} {#3} |
| 3837 |
\tex_ignorespaces:D |
| 3838 |
} |
| 3839 |
\cs_new_eq:NN \addCJKfontfeature \addCJKfontfeatures |
| 3840 |
\cs_new_protected:Npn \xeCJK_add_font_features:Nnn #1#2#3 |
| 3841 |
{ |
| 3842 |
\prop_get:NoNTF \g__xeCJK_family_font_name_prop |
| 3843 |
\l_xeCJK_family_tl \l__xeCJK_font_name_tl |
| 3844 |
{ |
| 3845 |
\clist_set:Nn \l__xeCJK_add_font_features_clist {#3} |
| 3846 |
\seq_map_inline:Nn \g__xeCJK_sub_key_seq |
| 3847 |
{ \clist_remove_all:Nn \l__xeCJK_add_font_features_clist {##1} } |
| 3848 |
\seq_clear:N \l__xeCJK_sub_key_seq |
| 3849 |
\clist_clear:N \l__xeCJK_add_block_features_clist |
| 3850 |
\clist_map_function:nN {#2} \__xeCJK_add_sub_features:n |
| 3851 |
\bool_lazy_and:nnT |
| 3852 |
{#1} |
| 3853 |
{ \seq_if_empty_p:N \l__xeCJK_sub_key_seq } |
| 3854 |
{ |
| 3855 |
\seq_map_function:NN |
| 3856 |
\g__xeCJK_sub_key_seq \__xeCJK_add_sub_class_features:n |
| 3857 |
} |
| 3858 |
\prop_get:NoNT \g__xeCJK_family_font_options_prop |
| 3859 |
\l_xeCJK_family_tl \l__xeCJK_font_options_clist |
| 3860 |
{ |
| 3861 |
\bool_lazy_or:nnT |
| 3862 |
{ \seq_if_empty_p:N \l__xeCJK_sub_key_seq } |
| 3863 |
{#1} |
| 3864 |
{ |
| 3865 |
\clist_concat:NNN \l__xeCJK_font_options_clist |
| 3866 |
\l__xeCJK_font_options_clist \l__xeCJK_add_font_features_clist |
| 3867 |
} |
| 3868 |
\clist_concat:NNN \l__xeCJK_font_options_clist |
| 3869 |
\l__xeCJK_font_options_clist \l__xeCJK_add_block_features_clist |
| 3870 |
} |
| 3871 |
\xeCJK_fontspec:oo \l__xeCJK_font_options_clist \l__xeCJK_font_name_tl |
| 3872 |
} |
| 3873 |
{ \__xeCJK_warning:n { addCJKfontfeature-ignored } } |
| 3874 |
} |
| 3875 |
\cs_new_protected:Npn \__xeCJK_add_sub_features:n #1 |
| 3876 |
{ |
| 3877 |
\seq_if_in:NnTF \g__xeCJK_sub_key_seq {#1} |
| 3878 |
{ |
| 3879 |
\seq_put_right:Nn \l__xeCJK_sub_key_seq {#1} |
| 3880 |
\__xeCJK_add_sub_class_features:n {#1} |
| 3881 |
} |
| 3882 |
{ \__xeCJK_warning:nx { SubBlock-undefined } {#1} } |
| 3883 |
} |
| 3884 |
\clist_new:N \l__xeCJK_add_font_features_clist |
| 3885 |
\clist_new:N \l__xeCJK_add_block_features_clist |
| 3886 |
\cs_generate_variant:Nn \xeCJK_add_font_features:Nnn { Nee , Nne } |
| 3887 |
\__xeCJK_msg_new:nn { addCJKfontfeature-ignored } |
| 3888 |
{ |
| 3889 |
\token_to_str:N \addCJKfontfeature (s)~ignored.\\\\ |
| 3890 |
It~cannot~be~used~with~a~font~that~wasn't~selected~by~xeCJK. |
| 3891 |
} |
| 3892 |
\cs_new_protected:Npn \__xeCJK_add_sub_class_features:n #1 |
| 3893 |
{ |
| 3894 |
\prop_get:NoNTF \g__xeCJK_family_font_name_prop |
| 3895 |
{ \l_xeCJK_family_tl/#1 } \l__xeCJK_sub_font_name_tl |
| 3896 |
{ |
| 3897 |
\prop_get:NoN \g__xeCJK_family_font_options_prop |
| 3898 |
{ \l_xeCJK_family_tl/#1 } \l__xeCJK_sub_font_options_clist |
| 3899 |
} |
| 3900 |
{ |
| 3901 |
\prop_get:NeNTF \g__xeCJK_family_font_name_prop |
| 3902 |
{ \CJKfamilydefault/#1 } \l__xeCJK_sub_font_name_tl |
| 3903 |
{ |
| 3904 |
\prop_get:NeN \g__xeCJK_family_font_options_prop |
| 3905 |
{ \CJKfamilydefault/#1 } \l__xeCJK_sub_font_options_clist |
| 3906 |
} |
| 3907 |
{ |
| 3908 |
\prop_get:NoN \g__xeCJK_family_font_options_prop |
| 3909 |
\l_xeCJK_family_tl \l__xeCJK_sub_font_options_clist |
| 3910 |
\tl_set_eq:NN \l__xeCJK_sub_font_name_tl \l__xeCJK_font_name_tl |
| 3911 |
} |
| 3912 |
} |
| 3913 |
\clist_concat:NNN \l__xeCJK_sub_font_options_clist |
| 3914 |
\l__xeCJK_sub_font_options_clist \l__xeCJK_add_font_features_clist |
| 3915 |
\clist_put_right:Nx \l__xeCJK_add_block_features_clist |
| 3916 |
{ |
| 3917 |
#1 = |
| 3918 |
{ |
| 3919 |
[ \exp_not:o \l__xeCJK_sub_font_options_clist ] |
| 3920 |
{ \exp_not:o \l__xeCJK_sub_font_name_tl } |
| 3921 |
} |
| 3922 |
} |
| 3923 |
} |
| 3924 |
\cs_generate_variant:Nn \prop_get:NnN { Ne } |
| 3925 |
\prg_generate_conditional_variant:Nnn \prop_get:NnN { Ne } { T , TF } |
| 3926 |
\keys_define:nn { xeCJK / options } |
| 3927 |
{ LoadFandol .bool_gset:N = \g__xeCJK_fandol_bool } |
| 3928 |
\cs_new_protected:Npn \__xeCJK_load_fandol: |
| 3929 |
{ |
| 3930 |
\xeCJK_set_family:enn { \CJKrmdefault } |
| 3931 |
{ Extension = .otf , BoldFont = FandolSong-Bold , ItalicFont = FandolKai-Regular } |
| 3932 |
{ FandolSong-Regular } |
| 3933 |
\xeCJK_set_family:enn { \CJKsfdefault } |
| 3934 |
{ Extension = .otf , BoldFont = FandolHei-Bold } { FandolHei-Regular } |
| 3935 |
\xeCJK_set_family:enn { \CJKttdefault } |
| 3936 |
{ Extension = .otf } { FandolFang-Regular } |
| 3937 |
} |
| 3938 |
\__xeCJK_at_end_preamble:n |
| 3939 |
{ |
| 3940 |
\tl_if_eq:NNT \CJKfamilydefault \l__xeCJK_family_default_init_tl |
| 3941 |
{ |
| 3942 |
\group_begin: |
| 3943 |
\cs_set_eq:NN \__xeCJK_family_default_wrap:n \exp_not:n |
| 3944 |
\tl_gset:Nx \CJKfamilydefault |
| 3945 |
{ |
| 3946 |
\str_case:onF { \familydefault } |
| 3947 |
{ |
| 3948 |
{ \rmdefault } { \exp_not:N \CJKrmdefault } |
| 3949 |
{ \sfdefault } { \exp_not:N \CJKsfdefault } |
| 3950 |
{ \ttdefault } { \exp_not:N \CJKttdefault } |
| 3951 |
} |
| 3952 |
{ \CJKfamilydefault } |
| 3953 |
} |
| 3954 |
\group_end: |
| 3955 |
} |
| 3956 |
\prop_if_empty:NTF \g__xeCJK_family_font_name_prop |
| 3957 |
{ |
| 3958 |
\bool_if:NTF \g__xeCJK_fandol_bool |
| 3959 |
{ |
| 3960 |
\__xeCJK_warning:n { fandol } |
| 3961 |
\__xeCJK_load_fandol: |
| 3962 |
\xeCJK_ensure_default_family: |
| 3963 |
} |
| 3964 |
{ \__xeCJK_warning:nx { no-CJKfamily } { \CJKfamilydefault } } |
| 3965 |
} |
| 3966 |
{ \xeCJK_ensure_default_family: } |
| 3967 |
} |
| 3968 |
\cs_new_protected:Npn \xeCJK_ensure_default_family: |
| 3969 |
{ |
| 3970 |
\xeCJK_family_if_exist:eF { \CJKfamilydefault } |
| 3971 |
{ |
| 3972 |
\tl_set_eq:NN \l__xeCJK_tmp_tl \CJKfamilydefault |
| 3973 |
\str_if_eq:eeTF { \CJKfamilydefault } { \CJKrmdefault } |
| 3974 |
{ \use:n } |
| 3975 |
{ |
| 3976 |
\xeCJK_family_if_exist:eTF { \CJKrmdefault } |
| 3977 |
{ \tl_gset:Nn \CJKfamilydefault { \CJKrmdefault } } |
| 3978 |
} |
| 3979 |
{ |
| 3980 |
\prop_map_inline:Nn \g__xeCJK_family_font_name_prop |
| 3981 |
{ |
| 3982 |
\prop_map_break:n |
| 3983 |
{ \tl_gset_rescan:Nnn \CJKfamilydefault { } { ##1 } } |
| 3984 |
} |
| 3985 |
} |
| 3986 |
\__xeCJK_warning:nxx { CJKfamilydefault-undefined } |
| 3987 |
{ \l__xeCJK_tmp_tl } { \CJKfamilydefault } |
| 3988 |
} |
| 3989 |
\xeCJK_switch_family:e { \CJKfamilydefault } |
| 3990 |
\bool_if:NT \g__xeCJK_math_bool { \xeCJK_set_mathfont: } |
| 3991 |
} |
| 3992 |
\__xeCJK_msg_new:nn { no-CJKfamily } |
| 3993 |
{ |
| 3994 |
It~seems~that~you~have~not~declare~a~CJKfamily.\\ |
| 3995 |
If~you~want~to~use~xeCJK~in~the~right~way,~you~should~use\\\\ |
| 3996 |
`\__xeCJK_msg_def_family_map:n {#1}'\\\\ |
| 3997 |
in~the~preamble~to~declare~the~default~CJKfamily.\\ |
| 3998 |
} |
| 3999 |
\__xeCJK_msg_new:nn { CJKfamilydefault-undefined } |
| 4000 |
{ |
| 4001 |
Undefined~CJK~default~family~`\__xeCJK_msg_family_map:n {#1}'~ |
| 4002 |
has~been~replaced~by~`\__xeCJK_msg_family_map:n {#2}'.\\\\ |
| 4003 |
Try~to~use~`\__xeCJK_msg_def_family_map:n {#1}'~to~define~it. |
| 4004 |
} |
| 4005 |
\__xeCJK_msg_new:nn { fandol } |
| 4006 |
{ |
| 4007 |
Fandol~is~being~set~as~the~default~font~for~CJK~text.\\ |
| 4008 |
Please~make~sure~it~has~been~properly~installed. |
| 4009 |
} |
| 4010 |
\keys_define:nn { xeCJK / options } { CJKmath .bool_gset:N = \g__xeCJK_math_bool } |
| 4011 |
\NewDocumentCommand \setCJKmathfont { o m } |
| 4012 |
{ |
| 4013 |
\__xeCJK_pass_args:nnnn |
| 4014 |
{ \xeCJK_set_family:nnn { \c__xeCJK_math_tl } } {#1} {#2} |
| 4015 |
{ } |
| 4016 |
} |
| 4017 |
\tl_const:Nn \c__xeCJK_math_tl { CJKmath } |
| 4018 |
\cs_new_protected:Npn \xeCJK_set_mathfont: |
| 4019 |
{ |
| 4020 |
\cs_if_exist_use:N \__xeCJK_save_um_char: |
| 4021 |
\xeCJK_family_if_exist:eTF { \c__xeCJK_math_tl } |
| 4022 |
{ \__xeCJK_set_mathfont_aux: } |
| 4023 |
{ |
| 4024 |
\xeCJK_family_if_exist:eT { \CJKfamilydefault } |
| 4025 |
{ |
| 4026 |
\__xeCJK_copy_family:ee { \c__xeCJK_math_tl } { \CJKfamilydefault } |
| 4027 |
\__xeCJK_set_mathfont_aux: |
| 4028 |
} |
| 4029 |
} |
| 4030 |
\cs_if_exist_use:N \__xeCJK_restore_um_char: |
| 4031 |
} |
| 4032 |
\cs_new_protected:Npn \__xeCJK_set_mathfont_aux: |
| 4033 |
{ |
| 4034 |
\tl_const:Nx \c__xeCJK_math_family_tl |
| 4035 |
{ \l__xeCJK_fontspec_family_tl } |
| 4036 |
\xeCJK_declare_mathfont:ee |
| 4037 |
{ \c__xeCJK_math_tl } |
| 4038 |
{ \c__xeCJK_math_family_tl } |
| 4039 |
\int_const:Nn \c_xeCJK_math_fam_int |
| 4040 |
{ \use:c { sym \c__xeCJK_math_tl } } |
| 4041 |
\clist_gconcat:NNN \g__xeCJK_math_chars_clist |
| 4042 |
\g__xeCJK_CJK_range_clist \g__xeCJK_FullLeft_range_clist |
| 4043 |
\clist_gconcat:NNN \g__xeCJK_math_chars_clist |
| 4044 |
\g__xeCJK_math_chars_clist \g__xeCJK_FullRight_range_clist |
| 4045 |
\xeCJK_gset_mathcode:Nn \g__xeCJK_math_chars_clist |
| 4046 |
{ \c_xeCJK_math_fam_int } |
| 4047 |
\xeCJK_set_mathfont_block: |
| 4048 |
} |
| 4049 |
\clist_new:N \g__xeCJK_math_chars_clist |
| 4050 |
\prop_new:N \g__xeCJK_fam_prop |
| 4051 |
\cs_new_protected:Npn \xeCJK_set_mathfont_block: |
| 4052 |
{ |
| 4053 |
\seq_if_empty:NF \g__xeCJK_CJK_sub_class_seq |
| 4054 |
{ |
| 4055 |
\seq_map_function:NN |
| 4056 |
\g__xeCJK_CJK_sub_class_seq |
| 4057 |
\xeCJK_set_mathfont_block:n |
| 4058 |
} |
| 4059 |
} |
| 4060 |
\cs_new_protected:Npn \xeCJK_set_mathfont_block:n #1 |
| 4061 |
{ |
| 4062 |
\xeCJK_block_family:nn { \c__xeCJK_math_tl } {#1} |
| 4063 |
\prop_get:NoNTF \g__xeCJK_fam_prop |
| 4064 |
\l__xeCJK_fontspec_family_tl \l__xeCJK_tmp_tl |
| 4065 |
{ \int_set:Nn \l__xeCJK_fam_int { \l__xeCJK_tmp_tl } } |
| 4066 |
{ |
| 4067 |
\xeCJK_declare_mathfont:ee |
| 4068 |
{ \c__xeCJK_math_tl / #1 } |
| 4069 |
{ \l__xeCJK_fontspec_family_tl } |
| 4070 |
\__xeCJK_set_mathfont_block_aux:cn |
| 4071 |
{ sym \c__xeCJK_math_tl / #1 } {#1} |
| 4072 |
} |
| 4073 |
\xeCJK_gset_mathcode:cn { g__xeCJK_CJK/#1_range_clist } { \l__xeCJK_fam_int } |
| 4074 |
} |
| 4075 |
\cs_new_protected:Npn \__xeCJK_set_mathfont_block_aux:Nn #1#2 |
| 4076 |
{ |
| 4077 |
\int_set_eq:NN \l__xeCJK_fam_int #1 |
| 4078 |
\prop_gput:Nnn \g__xeCJK_block_fam_prop {#2} {#1} |
| 4079 |
} |
| 4080 |
\int_new:N \l__xeCJK_fam_int |
| 4081 |
\prop_new:N \g__xeCJK_block_fam_prop |
| 4082 |
\cs_generate_variant:Nn \__xeCJK_set_mathfont_block_aux:Nn { c } |
| 4083 |
\cs_new_protected:Npn \xeCJK_declare_mathfont:nn #1#2 |
| 4084 |
{ |
| 4085 |
\xeCJK_declare_symbol_font:nnnnn {#1} { \c__xeCJK_encoding_tl } |
| 4086 |
{#2} { \mddefault } { \shapedefault } |
| 4087 |
\cs_if_free:cF |
| 4088 |
{ \c__xeCJK_encoding_tl/#2/\bfdefault/\shapedefault } |
| 4089 |
{ |
| 4090 |
\SetSymbolFont {#1} { bold } { \c__xeCJK_encoding_tl } |
| 4091 |
{#2} { \bfdefault } { \shapedefault } |
| 4092 |
} |
| 4093 |
\prop_gput:Nne \g__xeCJK_fam_prop {#2} { \exp_not:c { sym #1 } } |
| 4094 |
} |
| 4095 |
\cs_generate_variant:Nn \prop_put:Nnn { Nne } |
| 4096 |
\cs_generate_variant:Nn \prop_gput:Nnn { Nne } |
| 4097 |
\cs_generate_variant:Nn \xeCJK_declare_mathfont:nn { ee } |
| 4098 |
\cs_new_protected:Npn \xeCJK_declare_symbol_font:nnnnn #1 |
| 4099 |
{ \__xeCJK_declare_symbol_font:cnnnn { sym #1 } } |
| 4100 |
\cs_new_protected:Npn \__xeCJK_declare_symbol_font:Nnnnn #1 |
| 4101 |
{ |
| 4102 |
\xeCJK_new_fam:N #1 |
| 4103 |
\xeCJK_new_symbol_font:Nnnnn #1 |
| 4104 |
} |
| 4105 |
\cs_generate_variant:Nn \__xeCJK_declare_symbol_font:Nnnnn { c } |
| 4106 |
\cs_new_protected:Npn \xeCJK_new_fam:N #1 |
| 4107 |
{ |
| 4108 |
\int_compare:nNnTF |
| 4109 |
{ \g__xeCJK_fam_allocation_int } > { \g__xeCJK_fam_bottom_int } |
| 4110 |
{ |
| 4111 |
\int_set_eq:NN \allocationnumber \g__xeCJK_fam_allocation_int |
| 4112 |
\int_const:Nn #1 { \allocationnumber } |
| 4113 |
\iow_log:x |
| 4114 |
{ |
| 4115 |
\token_to_str:N #1 = |
| 4116 |
\token_to_str:N \mathgroup \int_use:N \allocationnumber |
| 4117 |
} |
| 4118 |
\int_gdecr:N \g__xeCJK_fam_allocation_int |
| 4119 |
} |
| 4120 |
{ \__xeCJK_error:n { fam-exhausted } } |
| 4121 |
} |
| 4122 |
\tex_countdef:D \g__xeCJK_fam_bottom_int = 18 ~ |
| 4123 |
\int_new:N \g__xeCJK_fam_allocation_int |
| 4124 |
\int_gset:Nn \g__xeCJK_fam_allocation_int { 255 } |
| 4125 |
\__xeCJK_msg_new:nn { fam-exhausted } |
| 4126 |
{ No~room~for~a~new~fam. } |
| 4127 |
\cs_new_protected:Npn \xeCJK_new_symbol_font:Nnnnn #1#2#3#4#5 |
| 4128 |
{ \__xeCJK_new_symbol_font:Nc #1 { #2/#3/#4/#5 } } |
| 4129 |
\cs_new_protected:Npn \__xeCJK_new_symbol_font:NN #1#2 |
| 4130 |
{ |
| 4131 |
\tl_put_right:Nn \group@list { \group@elt #1 #2 } |
| 4132 |
\cs_set:Npn \version@elt ##1 |
| 4133 |
{ \tl_put_right:Nn ##1 { \getanddefine@fonts #1 #2 } } |
| 4134 |
\version@list |
| 4135 |
} |
| 4136 |
\cs_generate_variant:Nn \__xeCJK_new_symbol_font:NN { Nc } |
| 4137 |
\cs_new_protected:Npn \xeCJK_gset_mathcode:Nn #1#2 |
| 4138 |
{ |
| 4139 |
\clist_map_inline:Nn #1 |
| 4140 |
{ |
| 4141 |
\__xeCJK_set_char_class_aux:Nnw \xeCJK_gset_mathcode:nnnn { ##1 } |
| 4142 |
{ 0 } {#2} |
| 4143 |
} |
| 4144 |
} |
| 4145 |
\cs_generate_variant:Nn \xeCJK_gset_mathcode:Nn { c } |
| 4146 |
\cs_new_protected:Npn \xeCJK_gset_mathcode:nnnn #1#2#3#4 |
| 4147 |
{ |
| 4148 |
\__xeCJK_check_num_range:nnNN {#1} {#2} \l__xeCJK_begin_int \l__xeCJK_end_int |
| 4149 |
\xeCJK_int_until_do:nn { \l__xeCJK_begin_int > \l__xeCJK_end_int } |
| 4150 |
{ |
| 4151 |
\xeCJK_gset_mathcode:Nnn \l__xeCJK_begin_int {#3} {#4} |
| 4152 |
\int_incr:N \l__xeCJK_begin_int |
| 4153 |
} |
| 4154 |
} |
| 4155 |
\cs_new_protected:Npn \xeCJK_gset_mathcode:Nnn #1#2#3 |
| 4156 |
{ \tex_global:D \tex_Umathcode:D #1 = #2 ~ #3 ~ #1 } |
| 4157 |
\int_new:N \l__xeCJK_verb_case_int |
| 4158 |
\keys_define:nn { xeCJK / options } |
| 4159 |
{ |
| 4160 |
Verb .choices:nn = |
| 4161 |
{ true , env+ , env , false } |
| 4162 |
{ \int_set_eq:NN \l__xeCJK_verb_case_int \l_keys_choice_int } , |
| 4163 |
Verb .default:n = { env } |
| 4164 |
} |
| 4165 |
\cs_new_protected:Npn \__xeCJK_verb_font_hook: |
| 4166 |
{ |
| 4167 |
\if_case:w \l__xeCJK_verb_case_int |
| 4168 |
\or: |
| 4169 |
\__xeCJK_nobreak_skip_zero: |
| 4170 |
\or: |
| 4171 |
\int_compare:nNnTF \tex_currentgrouptype:D = { 14 } |
| 4172 |
{ \xeCJKVerbAddon } |
| 4173 |
{ \__xeCJK_nobreak_skip: } |
| 4174 |
\or: |
| 4175 |
\int_compare:nNnTF \tex_currentgrouptype:D = { 14 } |
| 4176 |
{ \xeCJKVerbAddon } |
| 4177 |
{ \__xeCJK_nobreak_skip_zero: } |
| 4178 |
\fi: |
| 4179 |
} |
| 4180 |
\__xeCJK_after_preamble:n |
| 4181 |
{ |
| 4182 |
\cs_set_protected:Npx \verbatim@font |
| 4183 |
{ \exp_not:o { \verbatim@font } \__xeCJK_verb_font_hook: } |
| 4184 |
} |
| 4185 |
\cs_new_protected:Npn \__xeCJK_nobreak_skip_zero: |
| 4186 |
{ |
| 4187 |
\__xeCJK_reset_shipout_skip: |
| 4188 |
\cs_set_eq:NN \__xeCJK_shipout_check_for_glue: \xeCJK_check_for_glue: |
| 4189 |
\cs_set_eq:NN \__xeCJK_shipout_boundary:w \xeCJK_CJK_and_Boundary:w |
| 4190 |
\tl_put_right:Nn \l__xeCJK_reset_shipout_skip_hook_tl |
| 4191 |
{ |
| 4192 |
\cs_set_eq:NN \xeCJK_check_for_glue: \__xeCJK_shipout_check_for_glue: |
| 4193 |
\cs_set_eq:NN \xeCJK_CJK_and_Boundary:w \__xeCJK_shipout_boundary:w |
| 4194 |
} |
| 4195 |
\xeCJK_cs_clear:N \CJKglue |
| 4196 |
\xeCJK_cs_clear:N \CJKecglue |
| 4197 |
\xeCJK_cs_clear:N \xeCJK_check_for_glue: |
| 4198 |
\cs_set_eq:NN \xeCJK_CJK_and_Boundary:w \xeCJK_class_group_end: |
| 4199 |
\cs_set_eq:NN \__xeCJK_punct_hskip:n \__xeCJK_nobreak_hskip:n |
| 4200 |
\cs_set_eq:NN \__xeCJK_punct_breakable_kern:n \__xeCJK_nobreak_hskip:n |
| 4201 |
} |
| 4202 |
\cs_new_protected:Npn \__xeCJK_nobreak_skip: |
| 4203 |
{ |
| 4204 |
\__xeCJK_reset_shipout_skip: |
| 4205 |
\xeCJK_glue_to_skip:nN { \CJKglue } \l__xeCJK_ccglue_skip |
| 4206 |
\skip_if_eq:nnTF { \l__xeCJK_ccglue_skip } { \c_zero_skip } |
| 4207 |
{ \xeCJK_cs_clear:N \CJKglue } |
| 4208 |
{ \cs_set_eq:NN \CJKglue \__xeCJK_nobreak_ccglue: } |
| 4209 |
\xeCJK_glue_to_skip:nN { \CJKecglue } \l__xeCJK_ecglue_skip |
| 4210 |
\skip_if_eq:nnTF { \l__xeCJK_ecglue_skip } { \c_zero_skip } |
| 4211 |
{ \xeCJK_cs_clear:N \CJKecglue } |
| 4212 |
{ \cs_set_eq:NN \CJKecglue \__xeCJK_nobreak_ecglue: } |
| 4213 |
\cs_set_eq:NN \__xeCJK_punct_hskip:n \__xeCJK_nobreak_hskip:n |
| 4214 |
\cs_set_eq:NN \__xeCJK_punct_breakable_kern:n \__xeCJK_nobreak_hskip:n |
| 4215 |
} |
| 4216 |
\cs_new_protected:Npn \__xeCJK_nobreak_ccglue: |
| 4217 |
{ \xeCJK_no_break: \skip_horizontal:N \l__xeCJK_ccglue_skip } |
| 4218 |
\cs_new_protected:Npn \__xeCJK_nobreak_ecglue: |
| 4219 |
{ \xeCJK_no_break: \skip_horizontal:N \l__xeCJK_ecglue_skip } |
| 4220 |
\cs_new_protected:Npn \__xeCJK_reset_shipout_skip: |
| 4221 |
{ |
| 4222 |
\cs_set_eq:NN \__xeCJK_shipout_CJKglue: \CJKglue |
| 4223 |
\cs_set_eq:NN \__xeCJK_shipout_CJKecglue: \CJKecglue |
| 4224 |
\cs_set_eq:NN \__xeCJK_shipout_punct_hskip:n \__xeCJK_punct_hskip:n |
| 4225 |
\cs_set_eq:NN |
| 4226 |
\__xeCJK_shipout_punct_breakable_kern:n \__xeCJK_punct_breakable_kern:n |
| 4227 |
\tl_set:Nx \l__xeCJK_off_verb_addon_tl |
| 4228 |
{ |
| 4229 |
\bool_if:NTF \l__xeCJK_xecglue_bool |
| 4230 |
{ \keys_set:nn { xeCJK / options } { xCJKecglue = true } } |
| 4231 |
{ \keys_set:nn { xeCJK / options } { xCJKecglue = false } } |
| 4232 |
\exp_not:n |
| 4233 |
{ |
| 4234 |
\cs_set_eq:NN \CJKglue \__xeCJK_shipout_CJKglue: |
| 4235 |
\cs_set_eq:NN \CJKecglue \__xeCJK_shipout_CJKecglue: |
| 4236 |
\cs_set_eq:NN \__xeCJK_punct_hskip:n \__xeCJK_shipout_punct_hskip:n |
| 4237 |
\cs_set_eq:NN \__xeCJK_punct_breakable_kern:n |
| 4238 |
\__xeCJK_shipout_punct_breakable_kern:n |
| 4239 |
\l__xeCJK_reset_shipout_skip_hook_tl |
| 4240 |
} |
| 4241 |
} |
| 4242 |
\xeCJK_add_to_shipout:n { \l__xeCJK_off_verb_addon_tl } |
| 4243 |
\keys_set:nn { xeCJK / options } { xCJKecglue = false } |
| 4244 |
} |
| 4245 |
\tl_new:N \l__xeCJK_reset_shipout_skip_hook_tl |
| 4246 |
\NewDocumentCommand \xeCJKVerbAddon { } |
| 4247 |
{ |
| 4248 |
\int_compare:nNnF \tex_currentgrouplevel:D = \c_zero_int |
| 4249 |
{ |
| 4250 |
\bool_if:NF \l__xeCJK_listings_env_bool |
| 4251 |
{ |
| 4252 |
\dim_compare:nNnTF |
| 4253 |
{ \tex_fontdimen:D 2 ~ \tex_font:D } = |
| 4254 |
{ \tex_fontcharwd:D \tex_font:D \c__xeCJK_mono_letter_int } |
| 4255 |
{ |
| 4256 |
\__xeCJK_set_verb_exspace: |
| 4257 |
\__xeCJK_verb_addon: |
| 4258 |
} |
| 4259 |
{ |
| 4260 |
\int_if_odd:nTF { \l__xeCJK_verb_case_int } |
| 4261 |
{ \__xeCJK_nobreak_skip_zero: } |
| 4262 |
{ \__xeCJK_nobreak_skip: } |
| 4263 |
} |
| 4264 |
} |
| 4265 |
} |
| 4266 |
} |
| 4267 |
\int_const:Nn \c__xeCJK_mono_letter_int { 77 } |
| 4268 |
\bool_new:N \l__xeCJK_listings_env_bool |
| 4269 |
\NewDocumentCommand \xeCJKOffVerbAddon { } |
| 4270 |
{ \tl_use:N \l__xeCJK_off_verb_addon_tl } |
| 4271 |
\tl_new:N \l__xeCJK_off_verb_addon_tl |
| 4272 |
\cs_new_protected:Npn \__xeCJK_verb_addon: |
| 4273 |
{ |
| 4274 |
\bool_if:NF \l__xeCJK_verb_addon_bool |
| 4275 |
{ \__xeCJK_verb_addon_action: } |
| 4276 |
\skip_if_eq:nnTF { \l__xeCJK_verb_exspace_skip } { \c_zero_skip } |
| 4277 |
{ |
| 4278 |
\xeCJK_cs_clear:N \CJKglue |
| 4279 |
\xeCJK_cs_clear:N \CJKecglue |
| 4280 |
} |
| 4281 |
{ |
| 4282 |
\skip_set_eq:NN \l__xeCJK_ccglue_skip \l__xeCJK_verb_exspace_skip |
| 4283 |
\skip_set:Nn \l__xeCJK_ecglue_skip { \l__xeCJK_verb_exspace_skip / 2 } |
| 4284 |
\cs_set_eq:NN \CJKglue \__xeCJK_nobreak_ccglue: |
| 4285 |
\cs_set_eq:NN \CJKecglue \__xeCJK_nobreak_ecglue: |
| 4286 |
} |
| 4287 |
\cs_set_eq:NN \xeCJK_check_for_glue: \CJKecglue |
| 4288 |
\cs_set_eq:NN \xeCJK_CJK_and_Boundary:w \__xeCJK_verb_CJK_and_Boundary:w |
| 4289 |
} |
| 4290 |
\cs_new_protected:Npn \__xeCJK_verb_addon_action: |
| 4291 |
{ |
| 4292 |
\bool_set_true:N \l__xeCJK_verb_addon_bool |
| 4293 |
\__xeCJK_set_char_class_eq:nn { FullLeft } { CJK } |
| 4294 |
\__xeCJK_set_char_class_eq:nn { FullRight } { CJK } |
| 4295 |
\__xeCJK_set_char_class_eq:nn { HalfLeft } { Default } |
| 4296 |
\__xeCJK_set_char_class_eq:nn { HalfRight } { Default } |
| 4297 |
\__xeCJK_set_char_class_eq:nn { NormalSpace } { Default } |
| 4298 |
\cs_set_eq:NN \__xeCJK_shipout_CJKglue: \CJKglue |
| 4299 |
\cs_set_eq:NN \__xeCJK_shipout_CJKecglue: \CJKecglue |
| 4300 |
\cs_set_eq:NN \__xeCJK_shipout_check_for_glue: \xeCJK_check_for_glue: |
| 4301 |
\cs_set_eq:NN \__xeCJK_shipout_boundary:w \xeCJK_CJK_and_Boundary:w |
| 4302 |
\cs_set_protected:Npx \xeCJKOffVerbAddon |
| 4303 |
{ |
| 4304 |
\__xeCJK_reset_char_class:n { FullLeft } |
| 4305 |
\__xeCJK_reset_char_class:n { FullRight } |
| 4306 |
\__xeCJK_reset_char_class:n { HalfLeft } |
| 4307 |
\__xeCJK_reset_char_class:n { HalfLeft } |
| 4308 |
\__xeCJK_reset_char_class:n { NormalSpace } |
| 4309 |
\bool_if:NTF \l__xeCJK_xecglue_bool |
| 4310 |
{ \keys_set:nn { xeCJK / options } { xCJKecglue = true } } |
| 4311 |
{ \keys_set:nn { xeCJK / options } { xCJKecglue = false } } |
| 4312 |
\exp_not:n |
| 4313 |
{ |
| 4314 |
\cs_set_eq:NN \CJKglue \__xeCJK_shipout_CJKglue: |
| 4315 |
\cs_set_eq:NN \CJKecglue \__xeCJK_shipout_CJKecglue: |
| 4316 |
\cs_set_eq:NN \xeCJK_check_for_glue: \__xeCJK_shipout_check_for_glue: |
| 4317 |
\cs_set_eq:NN \xeCJK_CJK_and_Boundary:w \__xeCJK_shipout_boundary:w |
| 4318 |
} |
| 4319 |
} |
| 4320 |
\xeCJK_add_to_shipout:n { \xeCJKOffVerbAddon } |
| 4321 |
\keys_set:nn { xeCJK / options } { xCJKecglue = false } |
| 4322 |
} |
| 4323 |
\cs_new_protected:Npn \__xeCJK_verb_CJK_and_Boundary:w |
| 4324 |
{ \xeCJK_class_group_end: \CJKecglue } |
| 4325 |
\cs_new_protected:Npn \__xeCJK_reset_char_class:n #1 |
| 4326 |
{ |
| 4327 |
\int_set:Nn \l__xeCJK_tmp_int { \xeCJK_class_num:n {#1} } |
| 4328 |
\clist_map_inline:cn { c__xeCJK_#1_chars_clist } |
| 4329 |
{ \tex_XeTeXcharclass:D ##1 = \l__xeCJK_tmp_int } |
| 4330 |
} |
| 4331 |
\bool_new:N \l__xeCJK_verb_addon_bool |
| 4332 |
\cs_new_eq:NN \CJKfixedspacing \xeCJKVerbAddon |
| 4333 |
\cs_new_protected:Npn \__xeCJK_set_verb_exspace: |
| 4334 |
{ |
| 4335 |
\tl_if_exist:cTF { xeCJK/verb/\CJK@family/\curr@fontshape/\f@size } |
| 4336 |
{ |
| 4337 |
\skip_set:Nn \l__xeCJK_verb_exspace_skip |
| 4338 |
{ \use:c { xeCJK/verb/\CJK@family/\curr@fontshape/\f@size } } |
| 4339 |
} |
| 4340 |
{ |
| 4341 |
\tl_set:Nx \l__xeCJK_current_coor_tl { \CJK@family/\curr@fontshape } |
| 4342 |
\prop_get:NoNTF \g__xeCJK_scale_family_prop |
| 4343 |
\l__xeCJK_current_coor_tl \l_xeCJK_family_tl |
| 4344 |
{ |
| 4345 |
\xeCJK_switch_family:o { \l_xeCJK_family_tl } |
| 4346 |
\skip_zero:N \l__xeCJK_verb_exspace_skip |
| 4347 |
} |
| 4348 |
{ |
| 4349 |
\group_begin: \xeCJK_select_font: \exp_args:NNo \group_end: |
| 4350 |
\__xeCJK_set_verb_exspace:n |
| 4351 |
{ \dim_use:N \tex_fontcharwd:D \tex_font:D "4E00 ~ } |
| 4352 |
} |
| 4353 |
} |
| 4354 |
} |
| 4355 |
\skip_new:N \l__xeCJK_verb_exspace_skip |
| 4356 |
\cs_new_protected:Npn \__xeCJK_set_verb_exspace:n #1 |
| 4357 |
{ |
| 4358 |
\skip_set:Nn \l__xeCJK_verb_exspace_skip |
| 4359 |
{ 2 \tex_fontdimen:D 2 ~ \tex_font:D - #1 } |
| 4360 |
\dim_compare:nNnTF \l__xeCJK_verb_exspace_skip < \c_zero_dim |
| 4361 |
{ |
| 4362 |
\skip_zero:N \l__xeCJK_verb_exspace_skip |
| 4363 |
\exp_args:Nee \__xeCJK_set_verb_scale:nn |
| 4364 |
{ \dim_to_fp:n { 2 \tex_fontdimen:D 2 ~ \tex_font:D } } |
| 4365 |
{ \dim_to_fp:n {#1} } |
| 4366 |
} |
| 4367 |
{ |
| 4368 |
\tl_const:cx { xeCJK/verb/\CJK@family/\curr@fontshape/\f@size } |
| 4369 |
{ \skip_use:N \l__xeCJK_verb_exspace_skip } |
| 4370 |
} |
| 4371 |
} |
| 4372 |
\cs_new_protected:Npn \__xeCJK_set_verb_scale:nn #1#2 |
| 4373 |
{ |
| 4374 |
\fp_set:Nn \l__xeCJK_scale_factor_fp { #1 / #2 } |
| 4375 |
\__xeCJK_warning:nxx { scale-factor } |
| 4376 |
{ \fp_eval:n { trunc ( \l__xeCJK_scale_factor_fp , 4 ) } } |
| 4377 |
{ \fp_eval:n { ceil ( #2 / #1 , 4 ) } } |
| 4378 |
\xeCJK_add_font_features:Nne \c_true_bool |
| 4379 |
{ } { Scale = { \fp_use:N \l__xeCJK_scale_factor_fp } } |
| 4380 |
\prop_gput:Noo \g__xeCJK_scale_family_prop |
| 4381 |
\l__xeCJK_current_coor_tl \l_xeCJK_family_tl |
| 4382 |
} |
| 4383 |
\__xeCJK_msg_new:nn { scale-factor } |
| 4384 |
{ |
| 4385 |
`\token_to_str:N \xeCJKVerbAddon'~may~not~work~properly.\\\\ |
| 4386 |
You~may~set~`Scale=#1'~to~CJKfamily~ |
| 4387 |
`\__xeCJK_msg_family_map:n { \l_xeCJK_family_tl }',\\ |
| 4388 |
or~set~`Scale=#2'~to~family~ |
| 4389 |
`\str_if_eq:eeTF \f@family \ttdefault |
| 4390 |
{ \token_to_str:N \ttdefault } { \f@family }'. |
| 4391 |
} |
| 4392 |
\fp_new:N \l__xeCJK_scale_factor_fp |
| 4393 |
\prop_new:N \g__xeCJK_scale_family_prop |
| 4394 |
\cs_new_protected:Npn \xeCJK_setup_visible_space: |
| 4395 |
{ |
| 4396 |
\xeCJK_make_boundary: |
| 4397 |
\xeCJK_glyph_if_exist:NTF { ^^^^2423 } |
| 4398 |
{ \tl_set:Nn \l__xeCJK_visible_space_tl { ^^^^2423 } } |
| 4399 |
{ |
| 4400 |
\int_compare:nNnTF { \tex_XeTeXfonttype:D \tex_font:D } = \c_zero_int |
| 4401 |
{ |
| 4402 |
\tl_set:Nx \l__xeCJK_visible_space_tl |
| 4403 |
{ |
| 4404 |
\str_if_eq:eeTF { \f@family } { \ttdefault } |
| 4405 |
{ \c_catcode_other_space_tl } |
| 4406 |
{ \exp_not:N \textvisiblespace } |
| 4407 |
} |
| 4408 |
} |
| 4409 |
{ \__xeCJK_visible_space_fallback: } |
| 4410 |
} |
| 4411 |
\cs_set_eq:NN \@xobeysp \l__xeCJK_visible_space_tl |
| 4412 |
} |
| 4413 |
\tl_new:N \l__xeCJK_visible_space_tl |
| 4414 |
\cs_set_eq:NN \@setupverbvisiblespace \xeCJK_setup_visible_space: |
| 4415 |
\cs_new_protected:Npn \__xeCJK_visible_space_fallback: |
| 4416 |
{ |
| 4417 |
\exp_args:Nc \__xeCJK_visible_space_fallback_auxi:N |
| 4418 |
{ xeCJK/space/\curr@fontshape/\f@size } |
| 4419 |
} |
| 4420 |
\cs_new_protected:Npn \__xeCJK_visible_space_fallback_auxi:N #1 |
| 4421 |
{ |
| 4422 |
\cs_if_exist:NF #1 |
| 4423 |
{ \__xeCJK_visible_space_fallback_auxii:N #1 } |
| 4424 |
\tl_set:Nn \l__xeCJK_visible_space_tl {#1} |
| 4425 |
} |
| 4426 |
\cs_new_protected:Npn \__xeCJK_visible_space_fallback_auxii:N #1 |
| 4427 |
{ |
| 4428 |
\group_begin: |
| 4429 |
\exp_args:No \__xeCJK_set_visible_space_size:n |
| 4430 |
{ \dim_use:N \tex_fontdimen:D 2 ~ \tex_font:D } |
| 4431 |
\cs_new_protected:Npx #1 |
| 4432 |
{ \group_begin: \tex_the:D \tex_font:D ^^^^2423 \group_end: } |
| 4433 |
\group_end: |
| 4434 |
} |
| 4435 |
\cs_new_protected:Npn \__xeCJK_set_visible_space_size:n #1 |
| 4436 |
{ |
| 4437 |
\fontencoding { \UnicodeEncodingName } |
| 4438 |
\tl_set:Nn \f@family { lmtt } |
| 4439 |
\selectfont |
| 4440 |
\dim_compare:nNnF {#1} = { \tex_fontdimen:D 2 ~ \tex_font:D } |
| 4441 |
{ |
| 4442 |
\fontsize |
| 4443 |
{ |
| 4444 |
\dim_eval:n |
| 4445 |
{ |
| 4446 |
\f@size pt * |
| 4447 |
\dim_ratio:nn {#1} { \tex_fontdimen:D 2 ~ \tex_font:D } |
| 4448 |
} |
| 4449 |
} |
| 4450 |
{ \f@baselineskip } |
| 4451 |
\selectfont |
| 4452 |
} |
| 4453 |
} |
| 4454 |
\keys_define:nn { xeCJK / options } |
| 4455 |
{ |
| 4456 |
LocalConfig .choice: , |
| 4457 |
LocalConfig / false .code:n = |
| 4458 |
{ \bool_gset_false:N \g__xeCJK_config_bool } , |
| 4459 |
LocalConfig / true .code:n = |
| 4460 |
{ |
| 4461 |
\bool_gset_true:N \g__xeCJK_config_bool |
| 4462 |
\tl_gset:Nn \g__xeCJK_config_name_tl { xeCJK } |
| 4463 |
} , |
| 4464 |
LocalConfig / unknown .code:n = |
| 4465 |
{ |
| 4466 |
\bool_gset_true:N \g__xeCJK_config_bool |
| 4467 |
\tl_gset:Nx \g__xeCJK_config_name_tl { xeCJK - \l_keys_value_tl } |
| 4468 |
} , |
| 4469 |
LocalConfig .default:n = { true } |
| 4470 |
} |
| 4471 |
\tl_new:N \g__xeCJK_config_name_tl |
| 4472 |
\bool_new:N \g__xeCJK_config_bool |
| 4473 |
\keys_define:nn { xeCJK / options } |
| 4474 |
{ |
| 4475 |
CJKnumber .code:n = |
| 4476 |
{ \__xeCJK_warning:nxx { option-deprecated } { \l_keys_key_tl } { CJKnumb } } , |
| 4477 |
indentfirst .code:n = |
| 4478 |
{ \__xeCJK_warning:nxx { option-deprecated } { \l_keys_key_tl } { indentfirst } } , |
| 4479 |
normalindentfirst .code:n = |
| 4480 |
{ \__xeCJK_warning:nxx { option-deprecated } { \l_keys_key_tl } { } } |
| 4481 |
} |
| 4482 |
\__xeCJK_msg_new:nn { option-deprecated } |
| 4483 |
{ |
| 4484 |
The~`#1'~option~is~deprecated.\\ |
| 4485 |
\tl_if_empty:nF {#2} |
| 4486 |
{ You~may~load~the~package~`#2'~after~xeCJK~to~use~its~function.\\ } |
| 4487 |
} |
| 4488 |
\keys_define:nn { xeCJK / options } |
| 4489 |
{ |
| 4490 |
quiet .code:n = |
| 4491 |
{ |
| 4492 |
\msg_redirect_module:nnn { xeCJK } { warning } { info } |
| 4493 |
\msg_redirect_module:nnn { xeCJK } { info } { none } |
| 4494 |
\xeCJK_if_package_loaded:nF { fontspec } |
| 4495 |
{ \PassOptionsToPackage { quiet } { fontspec } } |
| 4496 |
} , |
| 4497 |
silent .code:n = |
| 4498 |
{ |
| 4499 |
\msg_redirect_module:nnn { xeCJK } { warning } { none } |
| 4500 |
\msg_redirect_module:nnn { xeCJK } { info } { none } |
| 4501 |
\xeCJK_if_package_loaded:nF { fontspec } |
| 4502 |
{ \PassOptionsToPackage { silent } { fontspec } } |
| 4503 |
} , |
| 4504 |
unknown .code:n = |
| 4505 |
{ |
| 4506 |
\xeCJK_if_package_loaded:nTF { fontspec } |
| 4507 |
{ \__xeCJK_error:nx { key-unknown } { \l_keys_key_tl } } |
| 4508 |
{ \PassOptionsToPackage { \l_keys_key_tl } { fontspec } } |
| 4509 |
} |
| 4510 |
} |
| 4511 |
\__xeCJK_msg_new:nn { key-unknown } |
| 4512 |
{ |
| 4513 |
Sorry,~but~xeCJK/options~does~not~have~a~key~called~`#1'.\\\\ |
| 4514 |
The~key~`#1'~is~being~ignored. |
| 4515 |
} |
| 4516 |
\cs_new_eq:NN \CJKsymbol \use:n |
| 4517 |
\cs_new_eq:NN \CJKpunctsymbol \use:n |
| 4518 |
\keys_set:nn { xeCJK / options } |
| 4519 |
{ |
| 4520 |
CJKglue = { \skip_horizontal:n { \c_zero_dim plus 0.08 \tex_baselineskip:D } } , |
| 4521 |
CJKecglue = { ~ } , |
| 4522 |
xCJKecglue = false , |
| 4523 |
CheckSingle = false , |
| 4524 |
PlainEquation = false , |
| 4525 |
CheckFullRight = false , |
| 4526 |
CJKspace = false , |
| 4527 |
CJKmath = false , |
| 4528 |
xeCJKactive = true , |
| 4529 |
LocalConfig = true , |
| 4530 |
LoadFandol = true , |
| 4531 |
RubberPunctSkip = true , |
| 4532 |
Verb = env , |
| 4533 |
EmboldenFactor = 4 , |
| 4534 |
SlantFactor = 0.167 , |
| 4535 |
PunctStyle = quanjiao , |
| 4536 |
NewLineCS = { \par \[ } , |
| 4537 |
EnvCS = { \begin \end } , |
| 4538 |
WidowPenalty = { 10 000 } , |
| 4539 |
NoBreakCS = { \footnote \footnotemark \nobreak } , |
| 4540 |
KaiMingPunct = { ^^^^3002 ^^^^ff0e ^^^^ff1f ^^^^ff01 } , |
| 4541 |
LongPunct = { ^^^^2014 ^^^^2e3a ^^^^2025 ^^^^2026 } , |
| 4542 |
MiddlePunct = { ^^^^2013 ^^^^2014 ^^^^2e3a ^^^^2027 ^^^^00b7 ^^^^30fb ^^^^ff65 } , |
| 4543 |
AllowBreakBetweenPuncts = false |
| 4544 |
} |
| 4545 |
\defaultCJKfontfeatures { Script = CJK } |
| 4546 |
\xeCJKsetwidth { ^^^^2013 } { 0.5 em } |
| 4547 |
\cs_if_exist:NTF \ProcessKeyOptions |
| 4548 |
{ \ProcessKeyOptions [ xeCJK / options ] } |
| 4549 |
{ |
| 4550 |
\RequirePackage { l3keys2e } |
| 4551 |
\ProcessKeysOptions { xeCJK / options } |
| 4552 |
} |
| 4553 |
\RequirePackage { fontspec } [ 2020/02/03 ] |
| 4554 |
\tl_const:Nx \c__xeCJK_encoding_tl { \g_fontspec_encoding_tl } |
| 4555 |
\keys_define:nn { xeCJK / options } |
| 4556 |
{ |
| 4557 |
LocalConfig .code:n = |
| 4558 |
{ \__xeCJK_warning:nx { option-invalid } { \l_keys_key_tl } } |
| 4559 |
} |
| 4560 |
\__xeCJK_msg_new:nn { option-invalid } |
| 4561 |
{ |
| 4562 |
The~`#1'~option~can~only~be~set~in~the~optional~argument~to~the\\ |
| 4563 |
\token_to_str:N \usepackage \ command~when~xeCJK~is~being~loaded.\\\\ |
| 4564 |
Please~do~not~set~it~via~the~\token_to_str:N \xeCJKsetup \ command. |
| 4565 |
} |
| 4566 |
\tl_if_exist:NF \CJKrmdefault { \tl_gset:Nn \CJKrmdefault { rm } } |
| 4567 |
\tl_if_exist:NF \CJKsfdefault { \tl_gset:Nn \CJKsfdefault { sf } } |
| 4568 |
\tl_if_exist:NF \CJKttdefault { \tl_gset:Nn \CJKttdefault { tt } } |
| 4569 |
\tl_new:N \l__xeCJK_family_default_init_tl |
| 4570 |
\cs_new_eq:NN \__xeCJK_family_default_wrap:n \use:n |
| 4571 |
\tl_set:Nx \l__xeCJK_family_default_init_tl |
| 4572 |
{ |
| 4573 |
\exp_not:N \__xeCJK_family_default_wrap:n |
| 4574 |
{ |
| 4575 |
\tl_if_exist:NTF \CJKfamilydefault |
| 4576 |
{ \exp_not:o \CJKfamilydefault } |
| 4577 |
{ \exp_not:N \CJKrmdefault } |
| 4578 |
} |
| 4579 |
} |
| 4580 |
\tl_gset_eq:NN \CJKfamilydefault \l__xeCJK_family_default_init_tl |
| 4581 |
\NewDocumentCommand \xeCJKsetup { +m } |
| 4582 |
{ |
| 4583 |
\keys_set:nn { xeCJK / options } {#1} |
| 4584 |
\tex_ignorespaces:D |
| 4585 |
} |
| 4586 |
\NewDocumentCommand \xeCJKsetemboldenfactor { m } |
| 4587 |
{ \xeCJKsetup { EmboldenFactor = {#1} } } |
| 4588 |
\NewDocumentCommand \xeCJKsetslantfactor { m } |
| 4589 |
{ \xeCJKsetup { SlantFactor = {#1} } } |
| 4590 |
\NewDocumentCommand \punctstyle { m } { \xeCJKsetup { PunctStyle = {#1} } } |
| 4591 |
\NewDocumentCommand \xeCJKplainchr { } { \xeCJKsetup { PunctStyle = plain } } |
| 4592 |
\NewDocumentCommand \CJKsetecglue { m } { \xeCJKsetup { CJKecglue = {#1} } } |
| 4593 |
\cs_new_eq:NN \xeCJKsetecglue \CJKsetecglue |
| 4594 |
\NewDocumentCommand \CJKspace { } { \xeCJKsetup { CJKspace = true } } |
| 4595 |
\NewDocumentCommand \CJKnospace { } { \xeCJKsetup { CJKspace = false } } |
| 4596 |
\NewDocumentCommand \xeCJKallowbreakbetweenpuncts { } |
| 4597 |
{ \xeCJKsetup { AllowBreakBetweenPuncts = true } } |
| 4598 |
\NewDocumentCommand \xeCJKnobreakbetweenpuncts { } |
| 4599 |
{ \xeCJKsetup { AllowBreakBetweenPuncts = false } } |
| 4600 |
\NewDocumentCommand \xeCJKenablefallback { } |
| 4601 |
{ \xeCJKsetup { AutoFallBack = true } } |
| 4602 |
\NewDocumentCommand \xeCJKdisablefallback { } |
| 4603 |
{ \xeCJKsetup { AutoFallBack = false } } |
| 4604 |
\NewDocumentCommand \xeCJKsetcharclass { m m m } |
| 4605 |
{ |
| 4606 |
\xeCJK_set_char_class:nnn {#1} {#2} {#3} |
| 4607 |
\xeCJKResetPunctClass |
| 4608 |
} |
| 4609 |
\cs_new_protected:Npn \xeCJK@update@fam |
| 4610 |
{ |
| 4611 |
\addto@hook \everymath |
| 4612 |
{ |
| 4613 |
\__xeCJK_update_main_fam: |
| 4614 |
\__xeCJK_update_block_fam: |
| 4615 |
} |
| 4616 |
} |
| 4617 |
\cs_new_protected:Npn \__xeCJK_update_main_fam: |
| 4618 |
{ |
| 4619 |
\group_begin: |
| 4620 |
\xeCJK_select_font: |
| 4621 |
\exp_last_unbraced:NNNo \group_end: |
| 4622 |
\tex_textfont:D \c_xeCJK_math_fam_int \tex_the:D \tex_font:D |
| 4623 |
} |
| 4624 |
\cs_new_protected:Npn \__xeCJK_update_block_fam: |
| 4625 |
{ |
| 4626 |
\prop_if_empty:NF \g__xeCJK_block_fam_prop |
| 4627 |
{ |
| 4628 |
\prop_map_function:NN |
| 4629 |
\g__xeCJK_block_fam_prop |
| 4630 |
\__xeCJK_update_block_fam:nn |
| 4631 |
} |
| 4632 |
} |
| 4633 |
\cs_new_protected:Npn \__xeCJK_update_block_fam:nn #1#2 |
| 4634 |
{ |
| 4635 |
\int_set:Nn \l__xeCJK_fam_int {#2} |
| 4636 |
\group_begin: |
| 4637 |
\xeCJK_select_font:n {#1} |
| 4638 |
\exp_last_unbraced:NNNo \group_end: |
| 4639 |
\tex_textfont:D \l__xeCJK_fam_int \tex_the:D \tex_font:D |
| 4640 |
} |
| 4641 |
\__xeCJK_after_end_preamble:n |
| 4642 |
{ |
| 4643 |
\bool_lazy_and:nnT |
| 4644 |
{ \g__xeCJK_math_bool } |
| 4645 |
{ \cs_if_exist_p:N \Url@MathSetup } |
| 4646 |
{ \tl_put_right:Nn \Url@MathSetup { \xeCJK@update@fam } } |
| 4647 |
} |
| 4648 |
\cs_new_protected:Npn \__xeCJK_math_robust:N #1 |
| 4649 |
{ |
| 4650 |
\group_begin: \exp_args:NcNc \group_end: |
| 4651 |
{ __xeCJK_math_robust_aux:NN } #1 { \cs_to_str:N #1 ~ } |
| 4652 |
} |
| 4653 |
\cs_new_protected:Npn \__xeCJK_math_robust_aux:NN #1#2 |
| 4654 |
{ |
| 4655 |
\exp_args:Ne \str_case:nnTF { \cs_replacement_spec:N #1 } |
| 4656 |
{ |
| 4657 |
{ \x@protect #1 \protect #2 } { } |
| 4658 |
{ \protect #2 } { } |
| 4659 |
} |
| 4660 |
{ \__xeCJK_math_robust:NN #1#2 } |
| 4661 |
{ \__xeCJK_math_robust:NN #1#1 } |
| 4662 |
} |
| 4663 |
\cs_new_protected:Npn \__xeCJK_math_robust:NN #1#2 |
| 4664 |
{ |
| 4665 |
\str_if_eq:eeTF { \cs_argument_spec:N #2 } { } |
| 4666 |
{ |
| 4667 |
\exp_args:No \tl_if_head_eq_meaning:nNTF {#2} \scan_stop: |
| 4668 |
{ |
| 4669 |
\cs_gset_protected:Npx #1 |
| 4670 |
{ \tl_tail:N #2 } |
| 4671 |
} |
| 4672 |
{ |
| 4673 |
\cs_if_eq:NNTF #1 \ensuremath |
| 4674 |
{ |
| 4675 |
\cs_gset_protected:Npx #1 |
| 4676 |
{ \exp_not:o {#2} } |
| 4677 |
} |
| 4678 |
{ |
| 4679 |
\__xeCJK_warning:nxx { robust-failure } |
| 4680 |
{ \token_to_str:N #1 } { \token_to_meaning:N #2 } |
| 4681 |
} |
| 4682 |
} |
| 4683 |
} |
| 4684 |
{ |
| 4685 |
\__xeCJK_warning:nxx { robust-failure } |
| 4686 |
{ \token_to_str:N #1 } { \token_to_meaning:N #2 } |
| 4687 |
} |
| 4688 |
} |
| 4689 |
\__xeCJK_msg_new:nnn { robust-failure } |
| 4690 |
{ xeCJK~can~not~make~`#1'~robust. } |
| 4691 |
{ |
| 4692 |
The~current~meaning~of~`#1'~is:\\ |
| 4693 |
\iow_indent:n {#2} |
| 4694 |
} |
| 4695 |
\cs_if_eq:NNTF \( \math |
| 4696 |
{ |
| 4697 |
\__xeCJK_math_robust:N \( |
| 4698 |
\cs_set_eq:NN \math \( |
| 4699 |
} |
| 4700 |
{ |
| 4701 |
\__xeCJK_math_robust:N \( |
| 4702 |
\__xeCJK_math_robust:N \math |
| 4703 |
} |
| 4704 |
\cs_if_eq:NNTF \) \endmath |
| 4705 |
{ |
| 4706 |
\__xeCJK_math_robust:N \) |
| 4707 |
\cs_set_eq:NN \endmath \) |
| 4708 |
} |
| 4709 |
{ |
| 4710 |
\__xeCJK_math_robust:N \) |
| 4711 |
\__xeCJK_math_robust:N \endmath |
| 4712 |
} |
| 4713 |
\__xeCJK_math_robust:N \ensuremath |
| 4714 |
\ctex_if_format_at_least:nTF { 2020/10/01 } |
| 4715 |
{ |
| 4716 |
\cs_set_eq:NN \xeCJK@family \xeCJK_switch_family:e |
| 4717 |
\ctex_gadd_ltxhook:nn { rmfamily } { \xeCJK@family { \CJKrmdefault } } |
| 4718 |
\ctex_gadd_ltxhook:nn { sffamily } { \xeCJK@family { \CJKsfdefault } } |
| 4719 |
\ctex_gadd_ltxhook:nn { ttfamily } { \xeCJK@family { \CJKttdefault } } |
| 4720 |
\ctex_gadd_ltxhook:nn { normalfont } { \xeCJK@family { \CJKfamilydefault } } |
| 4721 |
} |
| 4722 |
{ |
| 4723 |
\cs_if_exist:NTF \@rmfamilyhook |
| 4724 |
{ |
| 4725 |
\cs_set_eq:NN \xeCJK@family \xeCJK_switch_family:e |
| 4726 |
\g@addto@macro \@rmfamilyhook { \xeCJK@family { \CJKrmdefault } } |
| 4727 |
\g@addto@macro \@sffamilyhook { \xeCJK@family { \CJKsfdefault } } |
| 4728 |
\g@addto@macro \@ttfamilyhook { \xeCJK@family { \CJKttdefault } } |
| 4729 |
\exp_args:Nc \g@addto@macro |
| 4730 |
{ |
| 4731 |
\cs_if_exist:NTF \@defaultfamilyhook |
| 4732 |
{ @defaultfamilyhook } { normalfont ~ } |
| 4733 |
} |
| 4734 |
{ \xeCJK@family { \CJKfamilydefault } } |
| 4735 |
} |
| 4736 |
{ |
| 4737 |
\RenewDocumentCommand \fontfamily { m } |
| 4738 |
{ |
| 4739 |
\tl_set:Nx \f@family {#1} |
| 4740 |
\xeCJK@fontfamily {#1} |
| 4741 |
} |
| 4742 |
\cs_new_protected:Npn \xeCJK@fontfamily #1 |
| 4743 |
{ |
| 4744 |
\str_if_eq:nnTF {#1} { \familydefault } |
| 4745 |
{ \xeCJK_switch_family:e { \CJKfamilydefault } } |
| 4746 |
{ \__xeCJK_update_family_aux: } |
| 4747 |
} |
| 4748 |
\cs_new_protected:Npn \__xeCJK_update_family_aux: |
| 4749 |
{ |
| 4750 |
\str_case_e:nn { \f@family } |
| 4751 |
{ |
| 4752 |
{ \rmdefault } { \xeCJK_switch_family:e { \CJKrmdefault } } |
| 4753 |
{ \sfdefault } { \xeCJK_switch_family:e { \CJKsfdefault } } |
| 4754 |
{ \ttdefault } { \xeCJK_switch_family:e { \CJKttdefault } } |
| 4755 |
{ \familydefault } { \xeCJK_switch_family:e { \CJKfamilydefault } } |
| 4756 |
} |
| 4757 |
} |
| 4758 |
} |
| 4759 |
} |
| 4760 |
\cs_new_eq:NN \xeCJK@fix@penalty \fix@penalty |
| 4761 |
\tl_replace_once:Nnn \xeCJK@fix@penalty { \@@italiccorr } { \xeCJK@italiccorr } |
| 4762 |
\tl_replace_once:Nnn \sw@slant { \fix@penalty } { \xeCJK@fix@penalty } |
| 4763 |
\cs_new_protected:Npn \xeCJK@italiccorr |
| 4764 |
{ |
| 4765 |
\int_compare:nNnTF \tex_XeTeXinterchartokenstate:D > \c_zero_int |
| 4766 |
{ \xeCJK_italic_correction: } |
| 4767 |
{ \@@italiccorr } |
| 4768 |
} |
| 4769 |
\cs_new_protected:Npn \xeCJK_italic_correction: |
| 4770 |
{ \__xeCJK_if_last_kern:T { \__xeCJK_italic_correction: } } |
| 4771 |
\cs_new_protected:Npn \__xeCJK_italic_correction: |
| 4772 |
{ |
| 4773 |
\dim_case:nnF { \tex_lastkern:D } |
| 4774 |
{ |
| 4775 |
{ \__xeCJK_node:n { default } } |
| 4776 |
{ |
| 4777 |
\xeCJK_remove_node: \tex_italiccorrection:D |
| 4778 |
\xeCJK_make_node:n { default } |
| 4779 |
} |
| 4780 |
{ \__xeCJK_node:n { CJK } } |
| 4781 |
{ |
| 4782 |
\xeCJK_remove_node: \tex_italiccorrection:D |
| 4783 |
\xeCJK_make_node:n { CJK } |
| 4784 |
\__xeCJK_italic_correction_aux: |
| 4785 |
} |
| 4786 |
{ \__xeCJK_node:n { CJK-space } } |
| 4787 |
{ |
| 4788 |
\xeCJK_remove_node: \tex_italiccorrection:D |
| 4789 |
\xeCJK_make_node:n { CJK-space } |
| 4790 |
\__xeCJK_italic_correction_aux: |
| 4791 |
} |
| 4792 |
} |
| 4793 |
{ \tex_italiccorrection:D } |
| 4794 |
} |
| 4795 |
\cs_new_protected:Npn \__xeCJK_italic_correction_aux: |
| 4796 |
{ |
| 4797 |
\exp_after:wN \exp_after:wN \exp_after:wN |
| 4798 |
\exp_after:wN \exp_after:wN \exp_after:wN \exp_after:wN |
| 4799 |
\exp_after:wN \exp_after:wN \exp_after:wN \exp_after:wN |
| 4800 |
\exp_after:wN \exp_after:wN \exp_after:wN \exp_after:wN |
| 4801 |
\xeCJK_ignore_spaces:w |
| 4802 |
} |
| 4803 |
\cs_new_eq:NN \g__xeCJK_xetex_allocator_int \xe@alloc@intercharclass |
| 4804 |
\__xeCJK_after_end_preamble:n |
| 4805 |
{ |
| 4806 |
\int_compare:nNnF |
| 4807 |
{ \c__xeCJK_class_begin_int + \seq_count:N \g__xeCJK_new_class_seq } = |
| 4808 |
{ \g__xeCJK_xetex_allocator_int } |
| 4809 |
{ |
| 4810 |
\int_step_inline:nnn |
| 4811 |
{ \c__xeCJK_class_begin_int + 1 } |
| 4812 |
{ \g__xeCJK_xetex_allocator_int } |
| 4813 |
{ |
| 4814 |
\seq_if_in:NnF \g__xeCJK_new_class_seq {#1} |
| 4815 |
{ \__xeCJK_set_others_toks:n {#1} } |
| 4816 |
} |
| 4817 |
} |
| 4818 |
} |
| 4819 |
\cs_new_protected:Npn \__xeCJK_set_others_toks:n #1 |
| 4820 |
{ |
| 4821 |
\int_set:cn { \__xeCJK_class_csname:n { Others } } {#1} |
| 4822 |
\seq_map_inline:Nn \g__xeCJK_CJK_class_seq |
| 4823 |
{ |
| 4824 |
\xeCJK_copy_inter_class_toks:nnnn {##1} { Others } {##1} { NormalSpace } |
| 4825 |
\xeCJK_copy_inter_class_toks:nnnn { Others } {##1} { NormalSpace } {##1} |
| 4826 |
\xeCJK_app_inter_class_toks:nne {##1} { Others } |
| 4827 |
{ \xeCJK_get_inter_class_toks:nn { Default } { Others } } |
| 4828 |
\xeCJK_pre_inter_class_toks:nne { Others } {##1} |
| 4829 |
{ \xeCJK_get_inter_class_toks:nn { Others } { Default } } |
| 4830 |
\tl_if_blank:eT |
| 4831 |
{ \xeCJK_get_inter_class_toks:nn { Others } { Boundary } } |
| 4832 |
{ |
| 4833 |
\xeCJK_copy_inter_class_toks:nnnn |
| 4834 |
{ Others } { Boundary } { Default } { Boundary } |
| 4835 |
} |
| 4836 |
\tl_if_blank:eT |
| 4837 |
{ \xeCJK_get_inter_class_toks:nn { Boundary } { Others } } |
| 4838 |
{ |
| 4839 |
\xeCJK_copy_inter_class_toks:nnnn |
| 4840 |
{ Boundary } { Others } { Boundary } { Default } |
| 4841 |
} |
| 4842 |
} |
| 4843 |
} |
| 4844 |
\cs_new_protected:Npn \__xeCJK_inactive_group_begin: |
| 4845 |
{ \group_begin: \makexeCJKinactive } |
| 4846 |
\cs_new_eq:NN \__xeCJK_inactive_group_end: \group_end: |
| 4847 |
\prop_const_from_keyval:Nn \c__xeCJK_ambiguous_char_prop |
| 4848 |
{ |
| 4849 |
"00B7 = \textperiodcentered \textcentereddot \textcdot , |
| 4850 |
"2013 = \textendash , |
| 4851 |
"2014 = \textemdash , |
| 4852 |
"2018 = \textquoteleft \textgrq , |
| 4853 |
"2019 = \textquoteright , |
| 4854 |
"201C = \textquotedblleft \textgrqq , |
| 4855 |
"201D = \textquotedblright , |
| 4856 |
"2025 = \texthdotfor , |
| 4857 |
"2026 = \textellipsis , |
| 4858 |
"2027 = \texthyphenationpoint , |
| 4859 |
"2E3A = \texttwoemdash |
| 4860 |
} |
| 4861 |
\__xeCJK_at_end_preamble:n { \__xeCJK_patch_text_command: } |
| 4862 |
\cs_new_protected:Npn \__xeCJK_patch_text_command: |
| 4863 |
{ |
| 4864 |
\xeCJK_if_package_loaded:nTF { xunicode } |
| 4865 |
{ \__xeCJK_patch_xunicode_ambiguous_char: } |
| 4866 |
{ |
| 4867 |
\exp_args:Ne \__xeCJK_patch_tuenc_ambiguous_char:n |
| 4868 |
{ \UnicodeEncodingName } |
| 4869 |
\__xeCJK_patch_tuenc_accent: |
| 4870 |
\__xeCJK_patch_tuenc_composite: |
| 4871 |
} |
| 4872 |
} |
| 4873 |
\cs_new_protected:Npn \__xeCJK_patch_xunicode_ambiguous_char: |
| 4874 |
{ |
| 4875 |
\RequirePackage { xunicode-addon } |
| 4876 |
\prop_map_inline:Nn \c__xeCJK_ambiguous_char_prop |
| 4877 |
{ |
| 4878 |
\tl_map_inline:nn { ##2 } |
| 4879 |
{ |
| 4880 |
\xunadd_set_begin_hook:nn { ####1 } |
| 4881 |
{ \__xeCJK_inactive_group_begin: } |
| 4882 |
\xunadd_set_end_hook:nn { ####1 } |
| 4883 |
{ \__xeCJK_inactive_group_end: } |
| 4884 |
} |
| 4885 |
} |
| 4886 |
\xunadd_append_begin_hook:n { \xeCJK_make_boundary: } |
| 4887 |
} |
| 4888 |
\cs_new_protected:Npn \__xeCJK_patch_tuenc_ambiguous_char:n #1 |
| 4889 |
{ |
| 4890 |
\prop_map_inline:Nn \c__xeCJK_ambiguous_char_prop |
| 4891 |
{ |
| 4892 |
\tl_map_inline:nn { ##2 } |
| 4893 |
{ |
| 4894 |
\cs_if_exist:NF ####1 |
| 4895 |
{ \DeclareTextSymbol ####1 {#1} { ##1 } } |
| 4896 |
\__xeCJK_patch_ambiguous_char:nN {#1} ####1 |
| 4897 |
} |
| 4898 |
} |
| 4899 |
} |
| 4900 |
\cs_new_protected:Npn \__xeCJK_patch_ambiguous_char:nN #1#2 |
| 4901 |
{ |
| 4902 |
\exp_args:Ne \__xeCJK_patch_ambiguous_char:nn |
| 4903 |
{ #1 \token_to_str:N #2 } |
| 4904 |
{ #1 - #2 } |
| 4905 |
} |
| 4906 |
\cs_new_protected:Npx \__xeCJK_patch_ambiguous_char:nNn #1#2#3 |
| 4907 |
{ |
| 4908 |
\exp_not:N \exp_args:Ne |
| 4909 |
\exp_not:N \__xeCJK_patch_ambiguous_char:nn |
| 4910 |
{ |
| 4911 |
\c_backslash_str #1 |
| 4912 |
\exp_not:N \token_to_str:N #2 - |
| 4913 |
\exp_not:N \token_to_str:N #3 |
| 4914 |
} |
| 4915 |
{ #1 - #2#3 } |
| 4916 |
} |
| 4917 |
\cs_new_protected:Npn \__xeCJK_patch_ambiguous_char:nn #1#2 |
| 4918 |
{ |
| 4919 |
\cs_if_free:cF {#1} |
| 4920 |
{ \exp_args:Nc \__xeCJK_patch_ambiguous_char:Nn {#1} {#2} } |
| 4921 |
} |
| 4922 |
\cs_new_protected:Npn \__xeCJK_patch_ambiguous_char:Nn #1#2 |
| 4923 |
{ |
| 4924 |
\token_if_chardef:NTF #1 |
| 4925 |
{ |
| 4926 |
\prop_gput:Nne \c__xeCJK_ambiguous_slot_prop {#2} |
| 4927 |
{ \int_eval:n {#1} } |
| 4928 |
\cs_set_protected:Npx #1 |
| 4929 |
{ \__xeCJK_ambiguous_char:n { \tex_Uchar:D #1 } } |
| 4930 |
} |
| 4931 |
{ |
| 4932 |
\prop_gput:Nne \c__xeCJK_ambiguous_slot_prop {#2} |
| 4933 |
{ \int_eval:n { \exp_after:wN ` #1 } } |
| 4934 |
\cs_set_protected:Npx #1 |
| 4935 |
{ \__xeCJK_ambiguous_char:n { \exp_not:o {#1} } } |
| 4936 |
} |
| 4937 |
} |
| 4938 |
\cs_new_protected:Npn \__xeCJK_ambiguous_char:n #1 |
| 4939 |
{ |
| 4940 |
\int_compare:nNnTF \tex_XeTeXinterchartokenstate:D > \c_zero_int |
| 4941 |
{ \__xeCJK_inactive_group_begin: #1 \__xeCJK_inactive_group_end: } |
| 4942 |
{#1} |
| 4943 |
} |
| 4944 |
\prop_new:N \c__xeCJK_ambiguous_slot_prop |
| 4945 |
\cs_new_protected:Npn \xeCJK_text_composite_patch: |
| 4946 |
{ |
| 4947 |
\str_if_eq:eeT { \f@encoding } { \UnicodeEncodingName } |
| 4948 |
{ \xeCJK_make_boundary: } |
| 4949 |
} |
| 4950 |
\cs_new_protected:Npn \__xeCJK_patch_tuenc_composite: |
| 4951 |
{ |
| 4952 |
\cs_set_nopar:Npn \@text@composite@x |
| 4953 |
{ |
| 4954 |
\xeCJK_text_composite_patch: |
| 4955 |
\cs_if_exist_use:NF |
| 4956 |
} |
| 4957 |
} |
| 4958 |
\group_begin: |
| 4959 |
\char_set_catcode_other:n { "A0 } |
| 4960 |
\cs_new_protected:Npn \__xeCJK_patch_tuenc_accent: |
| 4961 |
{ |
| 4962 |
\cs_set_protected_nopar:Npn \add@unicode@accent ##1 ##2 |
| 4963 |
{ |
| 4964 |
\tl_if_blank:nTF { ##2 } { ^^a0 } { ##2 } |
| 4965 |
\tex_Uchar:D \tex_numexpr:D ##1 \scan_stop: |
| 4966 |
} |
| 4967 |
} |
| 4968 |
\group_end: |
| 4969 |
\prop_const_from_keyval:Nn \c__xeCJK_middle_dot_prop |
| 4970 |
{ |
| 4971 |
T2A = \cyrchvcrs , |
| 4972 |
T2B = \cyrchldsc , |
| 4973 |
T2C = \cyrabhha , |
| 4974 |
X2 = \cyrchldsc , |
| 4975 |
TS1 = \textperiodcentered , |
| 4976 |
LY1 = \textperiodcentered , |
| 4977 |
T1 = \r u , |
| 4978 |
T4 = \B t , |
| 4979 |
T5 = \` \ecircumflex |
| 4980 |
} |
| 4981 |
\__xeCJK_at_end_preamble:n { \__xeCJK_patch_middle_dot: } |
| 4982 |
\cs_new_protected:Npn \__xeCJK_patch_middle_dot: |
| 4983 |
{ |
| 4984 |
\prop_map_inline:Nn \c__xeCJK_middle_dot_prop |
| 4985 |
{ \__xeCJK_patch_middle_dot:nw { ##1 } ##2 \q_stop } |
| 4986 |
\__xeCJK_patch_ambiguous_char:nNn { T5 } \` { \^ - e } |
| 4987 |
} |
| 4988 |
\cs_new_protected:Npn \__xeCJK_patch_middle_dot:nw #1#2#3 \q_stop |
| 4989 |
{ |
| 4990 |
\tl_if_empty:nTF {#3} |
| 4991 |
{ \__xeCJK_patch_ambiguous_char:nN {#1} #2 } |
| 4992 |
{ \__xeCJK_patch_ambiguous_char:nNn {#1} #2 {#3} } |
| 4993 |
} |
| 4994 |
\__xeCJK_package_hook:nn { pifont } |
| 4995 |
{ |
| 4996 |
\RenewDocumentCommand \Pifont { m } |
| 4997 |
{ \makexeCJKinactive \usefont { U } {#1} { m } { n } } |
| 4998 |
} |
| 4999 |
\__xeCJK_package_hook:nn { unicode-math } |
| 5000 |
{ |
| 5001 |
\prop_const_from_keyval:Nn \c__xeCJK_um_ambiguous_char_prop |
| 5002 |
{ |
| 5003 |
"00B7 = \cdotp , |
| 5004 |
"2025 = \enleadertwodots , |
| 5005 |
"2026 = \unicodeellipsis |
| 5006 |
} |
| 5007 |
\cs_new_protected:Npn \__xeCJK_save_um_char: |
| 5008 |
{ |
| 5009 |
\cs_set_protected:Npx \__xeCJK_restore_um_char: |
| 5010 |
{ |
| 5011 |
\prop_map_function:NN |
| 5012 |
\c__xeCJK_um_ambiguous_char_prop |
| 5013 |
\__xeCJK_restore_um_char_aux:nn |
| 5014 |
} |
| 5015 |
} |
| 5016 |
\cs_new_eq:NN \__xeCJK_restore_um_char: \prg_do_nothing: |
| 5017 |
\cs_new:Npn \__xeCJK_restore_um_char_aux:nn #1#2 |
| 5018 |
{ |
| 5019 |
\__xeCJK_gset_mathcodenum:nn |
| 5020 |
{ \int_value:w #1 } |
| 5021 |
{ \int_value:w \tex_Umathcodenum:D #1 } |
| 5022 |
} |
| 5023 |
\cs_new_protected:Npn \__xeCJK_gset_mathcodenum:nn #1#2 |
| 5024 |
{ |
| 5025 |
\int_compare:nNnF { \tex_Umathcodenum:D #1 } = {#2} |
| 5026 |
{ \tex_global:D \tex_Umathcodenum:D #1 = #2 ~ } |
| 5027 |
} |
| 5028 |
} |
| 5029 |
\cs_new_protected:Npn \__xeCJK_patch_microtype_get_slot: |
| 5030 |
{ |
| 5031 |
\cs_new_eq:NN \xeCJK@original@get@slot \MT@get@slot@ |
| 5032 |
\cs_set_eq:NN \MT@get@slot@ \xeCJK@microtype@get@slot |
| 5033 |
\cs_set_eq:NN \MT@warn@unknown@once \use_none:n |
| 5034 |
} |
| 5035 |
\cs_new_protected_nopar:Npn \xeCJK@microtype@get@slot |
| 5036 |
{ |
| 5037 |
\int_compare:nNnT \MT@char < \c_zero_int |
| 5038 |
{ \__xeCJK_get_ambiguous_slot: } |
| 5039 |
\xeCJK@original@get@slot |
| 5040 |
} |
| 5041 |
\cs_new_protected:Npn \__xeCJK_get_ambiguous_slot: |
| 5042 |
{ |
| 5043 |
\prop_get:NeNT \c__xeCJK_ambiguous_slot_prop |
| 5044 |
{ \MT@encoding - \tex_the:D \MT@toks } \l__xeCJK_tmp_tl |
| 5045 |
{ \cs_set_eq:NN \MT@char \l__xeCJK_tmp_tl } |
| 5046 |
} |
| 5047 |
\cs_new_protected:Npn \xeCJK@microtype@restore@pickupfont |
| 5048 |
{ \__xeCJK_gadd_font_initial_hook:n { \MT@ltx@pickupfont } } |
| 5049 |
\__xeCJK_package_hook:nn { microtype } |
| 5050 |
{ |
| 5051 |
\cs_if_free:NF \MT@get@slot@ |
| 5052 |
{ \__xeCJK_patch_microtype_get_slot: } |
| 5053 |
\MT@addto@setup { \xeCJK@microtype@restore@pickupfont } |
| 5054 |
} |
| 5055 |
\__xeCJK_package_hook:nn { hyperref } |
| 5056 |
{ |
| 5057 |
\pdfstringdefDisableCommands |
| 5058 |
{ |
| 5059 |
\__xeCJK_gobble_CJKfamily: |
| 5060 |
\xeCJK_cs_clear:N \__xeCJK_inactive_group_begin: |
| 5061 |
\xeCJK_cs_clear:N \__xeCJK_inactive_group_end: |
| 5062 |
\xeCJK_cs_clear:N \makexeCJKinactive |
| 5063 |
\xeCJK_cs_clear:N \xeCJK_text_composite_patch: |
| 5064 |
} |
| 5065 |
} |
| 5066 |
\__xeCJK_package_hook:nn { cprotect } |
| 5067 |
{ |
| 5068 |
\cs_if_free:NF \icprotect |
| 5069 |
{ \exp_after:wN \tex_let:D \cs:w cprotect \cs_end: \icprotect } |
| 5070 |
} |
| 5071 |
\__xeCJK_package_hook:nn { listings } |
| 5072 |
{ \RequirePackage { xeCJK-listings } } |
| 5073 |
\__xeCJK_package_hook:nn { everysel } |
| 5074 |
{ |
| 5075 |
\cs_if_exist:NF \@EverySelectfont@Legacy |
| 5076 |
{ \cs_undefine:c { ver@CJK . \c__xeCJK_package_ext_tl } } |
| 5077 |
} |
| 5078 |
\ctex_at_begin_package:nn { CJKnumb } |
| 5079 |
{ |
| 5080 |
\tl_new:N \l__xeCJK_CJK_version_tl |
| 5081 |
\tl_set_eq:Nc \l__xeCJK_CJK_version_tl { ver@CJK . \c__xeCJK_package_ext_tl } |
| 5082 |
\tl_set:cn { ver@CJK . \c__xeCJK_package_ext_tl } { 9999/99/99 } |
| 5083 |
\cs_new_protected:Npn \CJKaddEncHook #1#2 |
| 5084 |
{ |
| 5085 |
\str_if_eq:nnT {#1} { \CJK@UnicodeEnc } |
| 5086 |
{ |
| 5087 |
\group_begin: |
| 5088 |
\cs_set_eq:NN \Unicode \xeCJK_unicode_char:nn |
| 5089 |
\cs_set_eq:NN \def \xdef |
| 5090 |
#2 |
| 5091 |
\group_end: |
| 5092 |
\str_gset:Nn \CJK@tenthousand { ^^^^4e07 } |
| 5093 |
\str_gset:Nn \CJK@hundredmillion { ^^^^4ebf } |
| 5094 |
\tl_if_exist:NF \CJK@UnicodeEnc |
| 5095 |
{ \tl_const:Nn \CJK@UnicodeEnc { UTF8 } } |
| 5096 |
\cs_if_exist:NF \Unicode |
| 5097 |
{ \cs_new_eq:NN \Unicode \xeCJK_unicode_char:nn } |
| 5098 |
} |
| 5099 |
} |
| 5100 |
\cs_new:Npn \xeCJK_unicode_char:nn #1#2 |
| 5101 |
{ \tex_Uchar:D \tex_numexpr:D (#1) * 256 + (#2) \scan_stop: } |
| 5102 |
} |
| 5103 |
\ctex_at_end_package:nn { CJKnumb } |
| 5104 |
{ \tl_set_eq:cN { ver@CJK . \c__xeCJK_package_ext_tl } \l__xeCJK_CJK_version_tl } |
| 5105 |
\bool_if:NT \g__xeCJK_config_bool |
| 5106 |
{ |
| 5107 |
\ExplSyntaxOff |
| 5108 |
\file_input:n { \g__xeCJK_config_name_tl .cfg } |
| 5109 |
\ExplSyntaxOn |
| 5110 |
} |
| 5111 |
%% |
| 5112 |
%% This package consists of the files xeCJK.dtx, |
| 5113 |
%% full-stop.map, |
| 5114 |
%% fullwidth-stop.map, |
| 5115 |
%% han-simp.map, |
| 5116 |
%% han-trad.map, |
| 5117 |
%% and the derived files xeCJK.pdf, |
| 5118 |
%% xeCJK.sty, |
| 5119 |
%% xeCJK.cfg, |
| 5120 |
%% xeCJK.ins, |
| 5121 |
%% xeCJKfntef.sty, |
| 5122 |
%% xeCJK-listings.sty, |
| 5123 |
%% xunicode-addon.sty, |
| 5124 |
%% xunicode-extra.def, |
| 5125 |
%% xeCJK-example-autofake.tex, |
| 5126 |
%% xeCJK-example-fallback.tex, |
| 5127 |
%% xeCJK-example-subCJKblock.tex, |
| 5128 |
%% xeCJK-example-CJKecglue.tex, |
| 5129 |
%% xeCJK-example-checksingle.tex, |
| 5130 |
%% xeCJK-example-CJKfntef.tex, |
| 5131 |
%% xeCJK-example-punctstyle.tex, |
| 5132 |
%% xeCJK-example-verbatim.tex, |
| 5133 |
%% xeCJK-example-CM.tex, |
| 5134 |
%% xeCJK-example-listings.tex, |
| 5135 |
%% xeCJK-example-mathblock.tex, |
| 5136 |
%% xunicode-symbols.tex, |
| 5137 |
%% xunicode-commands.tex, |
| 5138 |
%% xunicode-combine-marks.tex, |
| 5139 |
%% xunicode-symbols.pdf, |
| 5140 |
%% full-stop.tec, |
| 5141 |
%% fullwidth-stop.tec, |
| 5142 |
%% han-simp.tec, |
| 5143 |
%% han-trad.tec, and |
| 5144 |
%% README.md. |
| 5145 |
%% |
| 5146 |
%% End of file `xeCJK.sty'. |