summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex/xecjk
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-07-23 21:57:16 +0000
committerKarl Berry <karl@freefriends.org>2012-07-23 21:57:16 +0000
commit572e26630db65b54448140e24335b2cb1472044d (patch)
treef040c1e096c3928201719da9245f47d98f09b217 /Master/texmf-dist/tex/xelatex/xecjk
parentbbaa9588d1b77278d1752d39b8b2ac3aa26d36c2 (diff)
xecjk (23jul12)
git-svn-id: svn://tug.org/texlive/trunk@27119 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/xecjk')
-rw-r--r--Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty815
1 files changed, 440 insertions, 375 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
index 90bf31d5444..98b6c613b88 100644
--- a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
+++ b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
@@ -6,7 +6,7 @@
%%
%% xeCJK.dtx (with options: `package')
%%
-%% $Id: xeCJK.dtx 343 2012-05-21 05:59:17Z sobenlee $
+%% $Id: xeCJK.dtx 351 2012-07-20 05:30:58Z sobenlee $
%% $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
%% -----------------------------------------------------------------
%% Author:
@@ -31,45 +31,144 @@
%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\GetIdInfo$Id: xeCJK.dtx 343 2012-05-21 05:59:17Z sobenlee $
+\GetIdInfo$Id: xeCJK.dtx 351 2012-07-20 05:30:58Z sobenlee $
{package for typesetting CJK scripts with XeLaTeX}
-\ProvidesExplPackage{\ExplFileName}{\ExplFileDate}{3.0.6}{\ExplFileDescription}
-\cs_new_nopar:Npn \xeCJK_msg_new:nn { \msg_new:nnn { xeCJK } }
-\cs_new_nopar:Npn \xeCJK_error:n { \msg_error:nn { xeCJK } }
-\cs_new_nopar:Npn \xeCJK_error:nx { \msg_error:nnx { xeCJK } }
-\cs_new_nopar:Npn \xeCJK_warning:n { \msg_warning:nn { xeCJK } }
-\cs_new_nopar:Npn \xeCJK_warning:nx { \msg_warning:nnx { xeCJK } }
-\cs_new_nopar:Npn \xeCJK_warning:nxx { \msg_warning:nnxx { xeCJK } }
-\cs_new_nopar:Npn \xeCJK_info:nx { \msg_info:nnx { xeCJK } }
-\cs_new_nopar:Npn \xeCJK_info:nxx { \msg_info:nnxx { xeCJK } }
-\xeCJK_msg_new:nn { Require-XeTeX }
+\ProvidesExplPackage{\ExplFileName}{\ExplFileDate}{3.0.7}{\ExplFileDescription}
+\msg_new:nnn { xeCJK } { Require-XeTeX }
{
The~xeCJK~package~requires~XeTeX~to~function.\\\\
You~must~change~your~typesetting~engine~to~"xelatex" \\
- instead~of~plain~"latex"~or~"pdflatex"~or~"lualatex".
+ instead~of~plain~"latex"~or~"pdflatex"~or~"lualatex".\\
+ Loading~xeCJK~will~abort!
}
\xetex_if_engine:F { \msg_critical:nn { xeCJK } { Require-XeTeX } }
-\xeCJK_msg_new:nn { l3-too-old }
+\msg_new:nnn { xeCJK } { l3-too-old }
{
Support~package~'expl3'~too~old. \\\\
Please~update~an~up~to~date~version~of~the~bundles\\\\
'l3kernel'~and~'l3packages'\\\\
- using~your~TeX~package~manager~or~from~CTAN.
+ using~your~TeX~package~manager~or~from~CTAN.\\
+ Loading~xeCJK~will~abort!
}
-\@ifpackagelater { expl3 } { 2012/02/19 } { } { \xeCJK_error:n { l3-too-old } }
+\@ifpackagelater { expl3 } { 2012/07/16 } { }
+ { \msg_critical:nn { xeCJK } { l3-too-old } }
\RequirePackage{xparse}
\RequirePackage{l3keys2e}
-\xeCJK_msg_new:nn { XeTeX-too-old }
+\msg_new:nnn { xeCJK } { XeTeX-too-old }
{
\token_to_str:N \XeTeXglyphbounds\c_space_tl is~not~defined.\\\\
You~have~to~update~XeTeX~to~the~version~0.9995.0~or~later.
}
\cs_if_free:NT \XeTeXglyphbounds
{
- \xeCJK_error:n { XeTeX-too-old }
- \AtBeginDocument { \punctstyle { plain } }
+ \msg_error:nn { xeCJK } { XeTeX-too-old }
+ \AtEndOfPackage { \xeCJK_AfterPreamble:n { \punctstyle { plain } } }
+ }
+\int_new:N \l_xeCJK_tmpa_int
+\int_new:N \l_xeCJK_tmpb_int
+\int_new:N \l_xeCJK_tmpc_int
+\dim_new:N \l_xeCJK_tmpa_dim
+\dim_new:N \l_xeCJK_tmpb_dim
+\dim_new:N \l_xeCJK_tmpc_dim
+\tl_new:N \l_xeCJK_tmpa_tl
+\tl_new:N \l_xeCJK_tmpb_tl
+\clist_new:N \l_xeCJK_tmpa_clist
+\clist_new:N \l_xeCJK_tmpb_clist
+\clist_new:N \l_xeCJK_tmpc_clist
+\tl_new:N \g_xeCJK_at_end_preamble_hook
+\tl_new:N \g_xeCJK_after_preamble_hook
+\tl_new:N \g_xeCJK_after_end_preamble_hook
+\cs_new:Nn \xeCJK_AtEndPreamble:n
+ { \tl_gput_right:Nn \g_xeCJK_at_end_preamble_hook {#1} }
+\cs_new:Nn \xeCJK_AfterPreamble:n
+ { \tl_gput_right:Nn \g_xeCJK_after_preamble_hook {#1} }
+\cs_new:Nn \xeCJK_AfterEndPreamble:n
+ { \tl_gput_right:Nn \g_xeCJK_after_end_preamble_hook {#1} }
+\AtBeginDocument { \g_xeCJK_after_preamble_hook }
+\tl_put_left:Nn \document { \group_end: \g_xeCJK_at_end_preamble_hook \group_begin: }
+\tl_put_right:Nn \document { \g_xeCJK_after_end_preamble_hook \tex_ignorespaces:D }
+\group_begin:
+\char_set_lccode:nn { `\Z } { `\t }
+\char_set_lccode:nn { `\Y } { `\c }
+\char_set_lccode:nn { `\; } { `\: }
+\char_set_lccode:nn { `\/ } { `\\ }
+\tl_map_inline:nn { \T \F \C \J \K } { \char_set_lccode:nn { `#1 } { `#1 } }
+\tl_map_function:nN { \O \U \Z \E \R \M \A \Y \R \; \/ } \char_set_catcode_other:N
+\tl_to_lowercase:n
+ {
+ \group_end:
+ \prg_new_conditional:Nnn \xeCJK_if_outer_macro:c { p , T , F , TF }
+ {
+ \exp_last_unbraced:Nf \xeCJK_if_outer_macro_aux:w
+ { \cs_meaning:c {#1} } OUZER ~ MAYRO ; \q_stop
+ }
+ \cs_new_nopar:Npn \xeCJK_if_outer_macro_aux:w #1 OUZER ~ MAYRO ; #2 \q_stop
+ {
+ \if_cs_exist:w c_xeCJK_prefix_ #1 _aux_tl \cs_end:
+ \prg_return_true: \else: \prg_return_false: \fi:
+ }
+ \tl_new:c { c_xeCJK_prefix_/_aux_tl }
+ \tl_new:c { c_xeCJK_prefix_/long/_aux_tl }
+ \tl_new:c { c_xeCJK_prefix_/protected/_aux_tl }
+ \tl_new:c { c_xeCJK_prefix_/protected/long/_aux_tl }
}
-\char_set_catcode_ignore:n { "FEFF }
+\token_new:Nn \l_xeCJK_peek_search_token { ? }
+\cs_new_protected:Npn \xeCJK_peek_catcode_ignore_spaces:NTF #1#2#3
+ {
+ \cs_set_eq:NN \l_xeCJK_peek_search_token #1
+ \cs_set:Npx \xeCJK_peek_true:w
+ {
+ \exp_not:N \group_align_safe_end:
+ \exp_not:n {#2}
+ }
+ \cs_set:Npx \xeCJK_peek_false:w
+ {
+ \exp_not:N \group_align_safe_end:
+ \exp_not:n {#3}
+ }
+ \group_align_safe_begin:
+ \peek_after:Nw \xeCJK_peek_ignore_spaces_execute_branches:
+ }
+\cs_new_protected:Npn \xeCJK_peek_catcode_ignore_spaces:NT #1#2
+ { \xeCJK_peek_catcode_ignore_spaces:NTF #1 {#2} { } }
+\cs_new_protected:Npn \xeCJK_peek_catcode_ignore_spaces:NF #1#2
+ { \xeCJK_peek_catcode_ignore_spaces:NTF #1 { } {#2} }
+\cs_new_nopar:Nn \xeCJK_peek_ignore_spaces_execute_branches:
+ {
+ \if_meaning:w \l_peek_token \c_space_token
+ \tex_afterassignment:D \xeCJK_peek_ignore_spaces_execute_branches_aux:
+ \exp_after:wN \cs_set_eq:NN \exp_after:wN \xeCJK_peek_tmp:w
+ \else:
+ \exp_after:wN \xeCJK_peek_execute_branches_catcode:
+ \fi:
+ }
+\cs_new_protected_nopar:Nn \xeCJK_peek_ignore_spaces_execute_branches_aux:
+ { \peek_after:Nw \xeCJK_peek_ignore_spaces_execute_branches: }
+\cs_new_nopar:Nn \xeCJK_peek_execute_branches_catcode:
+ {
+ \if_catcode:w \exp_not:N \l_peek_token \exp_not:N \l_xeCJK_peek_search_token
+ \exp_after:wN \xeCJK_peek_true:w
+ \else:
+ \exp_after:wN \xeCJK_peek_false:w
+ \fi:
+ }
+\prg_new_conditional:Nnn \xeCJK_tl_if_blank:x { p , T , F , TF }
+ {
+ \if_int_compare:w \pdftex_strcmp:D { \c_empty_tl } {#1} = \c_zero
+ \prg_return_true:
+ \else:
+ \if_int_compare:w \pdftex_strcmp:D { \c_space_tl } {#1} = \c_zero
+ \prg_return_true: \else: \prg_return_false: \fi:
+ \fi:
+ }
+\cs_new_nopar:Npn \xeCJK_msg_new:nn { \msg_new:nnn { xeCJK } }
+\cs_new_nopar:Npn \xeCJK_error:n { \msg_error:nn { xeCJK } }
+\cs_new_nopar:Npn \xeCJK_error:nx { \msg_error:nnx { xeCJK } }
+\cs_new_nopar:Npn \xeCJK_warning:n { \msg_warning:nn { xeCJK } }
+\cs_new_nopar:Npn \xeCJK_warning:nx { \msg_warning:nnx { xeCJK } }
+\cs_new_nopar:Npn \xeCJK_warning:nxx { \msg_warning:nnxx { xeCJK } }
+\cs_new_nopar:Npn \xeCJK_info:nx { \msg_info:nnx { xeCJK } }
+\cs_new_nopar:Npn \xeCJK_info:nxx { \msg_info:nnxx { xeCJK } }
\keys_define:nn { xeCJK / options }
{
xeCJKactive .choice:,
@@ -79,6 +178,7 @@
}
\NewDocumentCommand \makexeCJKactive { } { \XeTeXinterchartokenstate = \c_one }
\NewDocumentCommand \makexeCJKinactive { } { \XeTeXinterchartokenstate = \c_zero }
+\char_set_catcode_ignore:n { "FEFF }
\int_const:Nn \xeCJK_Default_class { 0 }
\int_const:Nn \xeCJK_CJK_class { 1 }
\int_const:Nn \xeCJK_FullLeft_class { 2 }
@@ -111,21 +211,12 @@
\cs_generate_variant:Nn \prop_gput:Nnn { Nvx }
\clist_map_inline:nn { CJK, FullLeft, FullRight } { \xeCJK_save_CJK_class:n {#1} }
\cs_new_nopar:Nn \xeCJK_class_num:n { \tl_use:c { xeCJK_#1_class } }
-\prg_set_conditional:Nnn \tl_if_blank:x { p , T , F , TF }
- {
- \if_int_compare:w \pdftex_strcmp:D { \c_empty_tl } {#1} = \c_zero
- \prg_return_true:
- \else:
- \if_int_compare:w \pdftex_strcmp:D { \c_space_tl } {#1} = \c_zero
- \prg_return_true: \else: \prg_return_false: \fi:
- \fi:
- }
\NewDocumentCommand \xeCJKDeclareCharClass { > { \TrimSpaces } m m }
{
\clist_gput_right:cx { g_xeCJK_#1_range_clist } {#2}
\clist_map_inline:xn {#2}
{
- \str_if_eq:xxF {##1} { -> }
+ \str_if_eq_x:nnF {##1} { -> }
{
\xeCJK_setcharclass_aux:Nn \xeCJKsetcharclass {##1}
{ \xeCJK_class_num:n {#1} }
@@ -137,23 +228,23 @@
\cs_generate_variant:Nn \clist_map_inline:nn { x }
\NewDocumentCommand \xeCJKsetcharclass { m m m }
{
- \xeCJK_check_num_range:nnNN {#1} {#2} \l_tmpa_int \l_tmpb_int
- \int_set:Nn \l_tmpc_int {#3}
- \prop_if_in:NVTF \g_xeCJK_CJK_class_prop \l_tmpc_int
+ \xeCJK_check_num_range:nnNN {#1} {#2} \l_xeCJK_tmpa_int \l_xeCJK_tmpb_int
+ \int_set:Nn \l_xeCJK_tmpc_int {#3}
+ \prop_if_in:NVTF \g_xeCJK_CJK_class_prop \l_xeCJK_tmpc_int
{ \cs_set_eq:NN \xeCJK_set_catcode:n \char_set_catcode_other:n }
{ \cs_set_eq:NN \xeCJK_set_catcode:n \use_none:n }
\loop
- \xeCJK_set_catcode:n \l_tmpa_int
- \XeTeXcharclass \l_tmpa_int = \l_tmpc_int
- \if_int_compare:w \l_tmpa_int < \l_tmpb_int
- \int_incr:N \l_tmpa_int
+ \xeCJK_set_catcode:n \l_xeCJK_tmpa_int
+ \XeTeXcharclass \l_xeCJK_tmpa_int = \l_xeCJK_tmpc_int
+ \if_int_compare:w \l_xeCJK_tmpa_int < \l_xeCJK_tmpb_int
+ \int_incr:N \l_xeCJK_tmpa_int
\repeat
}
\cs_new_nopar:Nn \xeCJK_check_num_range:nnNN
{
- \bool_if:nTF { \tl_if_blank_p:x {#1} || \tl_if_blank_p:x {#2} }
+ \bool_if:nTF { \xeCJK_tl_if_blank_p:x {#1} || \xeCJK_tl_if_blank_p:x {#2} }
{
- \int_set:Nn #3 { \tl_if_blank:xTF {#1} {#2} {#1} }
+ \int_set:Nn #3 { \xeCJK_tl_if_blank:xTF {#1} {#2} {#1} }
\int_set_eq:NN #3 #4
}
{
@@ -305,18 +396,15 @@
{
\tex_unskip:D
\bool_if:nTF
- {
- \int_compare_p:nNn \tex_lastkern:D = \c_one ||
- \int_compare_p:nNn \tex_lastkern:D = \c_two
- }
+ { \xeCJK_if_last_node_p:n { CJK } || \xeCJK_if_last_node_p:n { CJK_space } }
{ \CJKecglue } { \c_space_token }
}
{
- \int_compare:nNnTF \tex_lastkern:D = \c_one { \CJKecglue }
- { \int_compare:nNnT \tex_lastkern:D = \c_two \xeCJK_space_or_xecglue: }
+ \xeCJK_if_last_node:nTF { CJK } { \CJKecglue }
+ { \xeCJK_if_last_node:nT { CJK_space } { \xeCJK_space_or_xecglue: } }
}
}
- \str_if_eq:xxF {#1} { NormalSpace }
+ \str_if_eq_x:nnF {#1} { NormalSpace }
{ \xeCJK_app_inter_class_toks:nnn { CJK } {#1} { \CJKecglue } }
}
\clist_map_inline:nn { Default, HalfRight, NormalSpace }
@@ -324,68 +412,65 @@
\xeCJK_inter_class_toks:nnn {#1} { Boundary }
{
\peek_catcode:NTF \c_space_token
- { { \xeCJK_default_space_kern: } } { { \xeCJK_default_kern: } }
+ { { \xeCJK_make_node:n { default_space } } }
+ { { \xeCJK_make_node:n { default } } }
}
- \str_if_eq:xxF {#1} { NormalSpace }
+ \str_if_eq_x:nnF {#1} { NormalSpace }
{ \xeCJK_pre_inter_class_toks:nnn {#1} { CJK } { \CJKecglue } }
}
\xeCJK_inter_class_toks:nnn { Boundary } { CJK } { \xeCJK_Boundary_and_CJK: }
\cs_new_nopar:Nn \xeCJK_Boundary_and_CJK:
{
- {
- \bool_if:nTF
- {
- \int_compare_p:nNn \tex_lastkern:D = \c_one ||
- \int_compare_p:nNn \tex_lastkern:D = \c_two
- }
- { \CJKglue }
- {
- \bool_if:nTF
- {
- \int_compare_p:nNn \tex_lastkern:D = \c_three ||
- \int_compare_p:nNn \etex_lastnodetype:D = \c_ten ||
- ( \int_compare_p:nNn \etex_lastnodetype:D = \c_twelve &&
- \g_xeCJK_itcorr_bool )
- }
- { \CJKecglue }
- {
- \bool_if:nT
- {
- \l_xeCJK_xecglue_bool &&
- \int_compare_p:nNn \etex_lastnodetype:D = \c_eleven &&
- ( \skip_if_eq_p:nn \tex_lastskip:D \l_xeCJK_space_glue_tl ||
- \int_compare_p:nNn \tex_lastskip:D = \l_xeCJK_ecglue_dim )
- }
- {
- \skip_set_eq:NN \l_tmpa_skip \tex_lastskip:D
- \tex_unskip:D
- \bool_if:nTF
- {
- \int_compare_p:nNn \tex_lastkern:D = \c_four ||
- \int_compare_p:nNn \etex_lastnodetype:D = \c_ten ||
- \int_compare_p:nNn \tex_lastkern:D = \c_three ||
- \g_xeCJK_itcorr_bool
- }
- { \CJKecglue }
- {
- \bool_if:nT
- {
- ! ( \int_compare_p:nNn \tex_lastkern:D = \c_one ) ||
- ! ( \int_compare_p:nNn \tex_lastkern:D = \c_two ) ||
- \l_xeCJK_space_bool
- }
- { \skip_horizontal:N \l_tmpa_skip }
- }
- }
- }
- }
- \bool_gset_false:N \g_xeCJK_itcorr_bool
- }
+ { \xeCJK_check_for_glue: }
\c_group_begin_token
\xeCJK_clear_CJK_toks:
\xeCJK_select_font:
\CJKsymbol
}
+\cs_new_nopar:Nn \xeCJK_check_for_glue:
+ {
+ \bool_if:nTF
+ { \xeCJK_if_last_node_p:n { CJK } || \xeCJK_if_last_node_p:n { CJK_space } }
+ { \CJKglue }
+ {
+ \bool_if:nTF
+ {
+ \xeCJK_if_last_node_p:n { default } ||
+ \int_compare_p:nNn \etex_lastnodetype:D = \c_ten ||
+ \xeCJK_if_last_node_p:n { default_itcorr }
+ }
+ { \CJKecglue }
+ {
+ \bool_if:nT
+ {
+ \l_xeCJK_xecglue_bool &&
+ \int_compare_p:nNn \etex_lastnodetype:D = \c_eleven &&
+ ( \skip_if_eq_p:nn \tex_lastskip:D \l_xeCJK_space_glue_tl ||
+ \dim_compare_p:nNn \tex_lastskip:D = \l_xeCJK_ecglue_dim )
+ }
+ {
+ \tex_unskip:D
+ \bool_if:nTF
+ {
+ \xeCJK_if_last_node_p:n { default_space } ||
+ \int_compare_p:nNn \etex_lastnodetype:D = \c_ten ||
+ \xeCJK_if_last_node_p:n { default } ||
+ \xeCJK_if_last_node_p:n { default_itcorr }
+ }
+ { \CJKecglue }
+ {
+ \bool_if:nTF
+ {
+ \xeCJK_if_last_node_p:n { CJK } ||
+ \xeCJK_if_last_node_p:n { CJK_space }
+ }
+ { \bool_if:NTF \l_xeCJK_space_bool \c_space_token \CJKglue }
+ { \c_space_token }
+ }
+ }
+ }
+ }
+ }
\tl_set:Nn \l_xeCJK_space_glue_tl
{
\tex_fontdimen:D \c_two \tex_font:D
@@ -395,7 +480,7 @@
\xeCJK_inter_class_toks:nnn { CJK } { Boundary }
{
\c_group_end_token
- { \xeCJK_CJK_kern: }
+ { \xeCJK_make_node:n { CJK } }
\xeCJK_ignorespaces:
}
\xeCJK_inter_class_toks:nnn { CJK } { CJK } { \xeCJK_CJK_and_CJK:N }
@@ -415,7 +500,7 @@
\clist_map_inline:Nn \g_xeCJK_base_class_clist
{
\bool_if:nF
- { \str_if_eq_p:xx {#1} { FullLeft } || \str_if_eq_p:xx {#1} { FullRight } }
+ { \str_if_eq_x_p:nn {#1} { FullLeft } || \str_if_eq_x_p:nn {#1} { FullRight } }
{
\xeCJK_pre_inter_class_toks:nnn { FullLeft } {#1} { \nobreak }
\xeCJK_pre_inter_class_toks:nnn { FullRight } {#1} { \xeCJK_after_FullRight: }
@@ -438,8 +523,8 @@
\skip_horizontal:n
{
\dim_eval:c { \l_xeCJK_punct_coor_tl/glue/#1 }
- \@plus \dim_eval:n { \tl_use:c { \l_xeCJK_punct_coor_tl/glue/#1 } /4 }
- \@minus \dim_eval:n { \tl_use:c { \l_xeCJK_punct_coor_tl/glue/#1 } /2 }
+ \@plus \dim_eval:n { ( \tl_use:c { \l_xeCJK_punct_coor_tl/glue/#1 } ) /4 }
+ \@minus \dim_eval:n { ( \tl_use:c { \l_xeCJK_punct_coor_tl/glue/#1 } ) /2 }
}
}
\cs_new_nopar:Nn \xeCJK_punct_kern:n
@@ -521,16 +606,33 @@
\tl_set:Nx \l_xeCJK_lastpunct_tl {#1}
\CJKpunctsymbol {#1}
}
-\cs_new_nopar:Nn \xeCJK_CJK_kern: { \tex_kern:D -1 sp \tex_kern:D 1 sp }
-\cs_new_nopar:Nn \xeCJK_CJK_space_kern: { \tex_kern:D -2 sp \tex_kern:D 2 sp }
-\cs_new_nopar:Nn \xeCJK_default_kern: { \tex_kern:D -3 sp \tex_kern:D 3 sp }
-\cs_new_nopar:Nn \xeCJK_default_space_kern: { \tex_kern:D -4 sp \tex_kern:D 4 sp }
-\keys_define:nn { xeCJK / options } { CJKglue .tl_set_x:N = \CJKglue }
+ \prg_new_conditional:Nnn \xeCJK_if_last_node:n { p , T , F , TF }
+ {
+ \if_dim:w \dim_use:c { c_xeCJK_#1_node_dim } = \tex_lastkern:D
+ \prg_return_true: \else: \prg_return_false: \fi:
+ }
+\cs_new_nopar:Nn \xeCJK_def_node:nn
+ {
+ \dim_if_exist:cTF { c_xeCJK_#1_node_dim }
+ { \dim_gset:cn } { \dim_const:cn }
+ { c_xeCJK_#1_node_dim } {#2}
+ }
+\cs_new_protected_nopar:Nn \xeCJK_make_node:n
+ {
+ \tex_kern:D - \dim_use:c { c_xeCJK_#1_node_dim }
+ \tex_kern:D \dim_use:c { c_xeCJK_#1_node_dim }
+ }
+\xeCJK_def_node:nn { CJK } { 11 sp }
+\xeCJK_def_node:nn { CJK_space } { 12 sp }
+\xeCJK_def_node:nn { default } { 13 sp }
+\xeCJK_def_node:nn { default_space } { 14 sp }
+\xeCJK_def_node:nn { default_itcorr } { 15 sp }
+\keys_define:nn { xeCJK / options } { CJKglue .tl_set:N = \CJKglue }
\keys_define:nn { xeCJK / options }
{
CJKecglue .code:n =
{
- \cs_set:Npx \CJKecglue {#1}
+ \cs_set:Npn \CJKecglue {#1}
\settowidth \l_xeCJK_ecglue_dim \CJKecglue
},
xCJKecglue .choice:,
@@ -547,7 +649,7 @@
xCJKecglue / unknown .code:n =
{
\bool_set_true:N \l_xeCJK_xecglue_bool
- \cs_set:Npx \CJKecglue {#1}
+ \cs_set:Npn \CJKecglue {#1}
\settowidth \l_xeCJK_ecglue_dim \CJKecglue
\cs_set_eq:NN \xeCJK_space_or_xecglue: \CJKecglue
},
@@ -578,9 +680,9 @@
{
\peek_catcode:NTF \c_space_token
{
- \int_compare:nNnT \tex_lastkern:D = \c_one
- { \tex_unkern:D \tex_unkern:D { \xeCJK_CJK_space_kern: } }
- \peek_catcode_ignore_spaces:NTF \c_math_toggle_token
+ \xeCJK_if_last_node:nT { CJK }
+ { \tex_unkern:D \tex_unkern:D { \xeCJK_make_node:n { CJK_space } } }
+ \xeCJK_peek_catcode_ignore_spaces:NTF \c_math_toggle_token
{ \xeCJK_space_or_xecglue: }
{
\bool_if:nT
@@ -603,9 +705,10 @@
{
\peek_catcode:NTF \c_space_token
{
- \int_compare:nNnT \tex_lastkern:D = \c_one
- { \tex_unkern:D \tex_unkern:D { \xeCJK_CJK_space_kern: } }
- \peek_catcode_ignore_spaces:NF \c_space_token { \xeCJK_space_or_xecglue: }
+ \xeCJK_if_last_node:nT { CJK }
+ { \tex_unkern:D \tex_unkern:D { \xeCJK_make_node:n { CJK_space } } }
+ \xeCJK_peek_catcode_ignore_spaces:NF \c_space_token
+ { \xeCJK_space_or_xecglue: }
}
{
\xeCJK_if_outer_macro:cF { l_peek_token }
@@ -622,7 +725,6 @@
CheckSingle / false .code:n = { \xeCJKdisablechecksingle },
CheckSingle .default:n = { true },
CJKchecksingle .meta:n = { CheckSingle = true } ,
- CheckSingleglue .tl_set_x:N = { \CJKchecksingleglue },
}
\bool_new:N \l_xeCJK_checksingle_bool
\NewDocumentCommand \xeCJKenablechecksingle { }
@@ -631,9 +733,7 @@
{
\bool_set_true:N \l_xeCJK_checksingle_bool
\cs_set_eq:NN \xeCJK_checksingle_save_CJKsymbol:N \xeCJK_CJK_and_CJK:N
- \cs_set_eq:NN \xeCJK_checksingle_save_CJKglue \CJKglue
\cs_set_eq:NN \xeCJK_CJK_and_CJK:N \xeCJK_checksingle:N
- \cs_set_nopar:Npn \CJKglue { \CJKchecksingleglue }
}
}
\NewDocumentCommand \xeCJKdisablechecksingle { }
@@ -641,7 +741,6 @@
\bool_if:NT \l_xeCJK_checksingle_bool
{
\bool_set_false:N \l_xeCJK_checksingle_bool
- \cs_set_eq:NN \CJKglue \xeCJK_checksingle_save_CJKglue
\cs_set_eq:NN \xeCJK_CJK_and_CJK:N \xeCJK_checksingle_save_CJKsymbol:N
}
}
@@ -676,7 +775,7 @@
{
\bool_if:nTF { \token_if_space_p:c { l_peek_token } }
{
- \peek_catcode_ignore_spaces:NTF \c_catcode_other_token
+ \xeCJK_peek_catcode_ignore_spaces:NTF \c_catcode_other_token
{ \xeCJK_checksingle_save_CJKsymbol:N {#1} #2 \c_space_token }
{
\bool_if:nTF
@@ -748,42 +847,6 @@
\cs_generate_variant:Nn \token_get_arg_spec:N { c }
\cs_generate_variant:Nn \token_if_math_toggle_p:N { c }
\cs_generate_variant:Nn \token_if_math_toggle:NTF { c }
-\group_begin:
-\char_set_lccode:nn { `\; } { `\: }
-\char_set_lccode:nn { `\Z } { `\t }
-\char_set_lccode:nn { `\Y } { `\c }
-\char_set_lccode:nn { `\T } { `\T }
-\char_set_lccode:nn { `\F } { `\F }
-\tl_map_function:nN { O U Z E R M A Y R ; } \char_set_catcode_other:N
-\tl_to_lowercase:n
- {
- \group_end:
- \prg_new_conditional:Nnn \xeCJK_if_outer_macro:c { p, T , F , TF }
- {
- \exp_last_unbraced:Nf \xeCJK_if_outer_macro_aux:w
- \cs_meaning:c {#1} OUZER ~ MAYRO ; \q_stop
- }
- \cs_new_nopar:Npn \xeCJK_if_outer_macro_aux:w #1 OUZER ~ MAYRO ; #2 \q_stop
- {
- \prg_case_str:xxn { #1 ~ }
- {
- { \token_to_str:N \ } { \prg_return_true: }
- { \token_to_str:N \long \token_to_str:N \ } { \prg_return_true: }
- { \token_to_str:N \protected \token_to_str:N \ } { \prg_return_true: }
- { \token_to_str:N \protected \token_to_str:N \long \token_to_str:N \ }
- { \prg_return_true: }
- }
- { \prg_return_false: }
- }
- }
-\tl_replace_once:Nnn \peek_ignore_spaces_execute_branches:
- { \token_if_eq_meaning:NNTF \l_peek_token }
- { \xeCJK_if_eq_meaning:cNTF { l_peek_token } }
-\prg_new_conditional:Nnn \xeCJK_if_eq_meaning:cN { p , T , F , TF }
- {
- \exp_args:Nc \if_meaning:w {#1} #2
- \prg_return_true: \else: \prg_return_false: \fi:
- }
\tl_new:N \xeCJK_UL_subclass_patch_tl
\clist_new:N \g_xeCJK_CJK_subclass_clist
\cs_new_nopar:Nn \xeCJK_erase_CJKsymbol:
@@ -825,7 +888,7 @@
{
\xeCJKDeclareCharClass
{ CJK \bool_if:NF \l_xeCJK_sub_cancel_bool { /##1 } }
- { \clist_use:c { g_xeCJK_CJK/##1_range_clist } }
+ { \tl_use:c { g_xeCJK_CJK/##1_range_clist } }
}
}
}
@@ -854,7 +917,7 @@
{
\xeCJK_copy_inter_class_toks:nnnn { #1/#2 } {##1} {#1} {##1}
\xeCJK_copy_inter_class_toks:nnnn {##1} { #1/#2 } {##1} {#1}
- \str_if_eq:xxTF {##1} { CJK }
+ \str_if_eq_x:nnTF {##1} { CJK }
{
\xeCJK_pre_inter_class_toks:nnn {##1} { #1/#2 }
{ \xeCJK_switch_font:nn {#1} {#2} }
@@ -893,7 +956,7 @@
{
\clist_map_inline:nn { Default, HalfLeft, HalfRight }
{
- \str_if_eq:xxTF {##1} { HalfLeft }
+ \str_if_eq_x:nnTF {##1} { HalfLeft }
{ \xeCJK_inter_class_toks:nnn {#1} { #1/#2 } { \CJKecglue \CJKsymbol } }
{ \xeCJK_inter_class_toks:nnn {#1} { #1/#2 } { \CJKsymbol } }
\xeCJK_inter_class_toks:nnn { Boundary } { #1/#2 }
@@ -911,32 +974,20 @@
{ CCT , halfwidth , fullwidth , marginkerning , mixedwidth , plain }
\clist_map_inline:Nn \g_xeCJK_punctstyle_clist
{ \tl_const:cn { c_xeCJK_ps_#1_tl } {#1} }
-\cs_generate_variant:Nn \keys_choices_generate:n { V }
-\cs_new_protected:cpn { \c_keys_props_root_tl .generate_choices:V } #1
- { \keys_choices_generate:V {#1} }
+\cs_generate_variant:Nn \keys_define:nn { nx }
\keys_define:nn { xeCJK / options }
{
- AllowBreakBetweenPuncts .choice:,
- AllowBreakBetweenPuncts / true .code:n = { \xeCJKallowbreakbetweenpuncts },
- AllowBreakBetweenPuncts / false .code:n = { \xeCJKnobreakbetweenpuncts },
- AllowBreakBetweenPuncts .default:n = { true },
- KaiMingPunct .code:n = { \xeCJK_set_special_punct:nn { mixedwidth } {#1} },
- KaiMingPunct+ .code:n = { \xeCJK_add_special_punct:nn { mixedwidth } {#1} },
- KaiMingPunct- .code:n = { \xeCJK_sub_special_punct:nn { mixedwidth } {#1} },
- LongPunct .code:n = { \xeCJK_set_special_punct:nn { long } {#1} },
- LongPunct+ .code:n = { \xeCJK_add_special_punct:nn { long } {#1} },
- LongPunct- .code:n = { \xeCJK_sub_special_punct:nn { long } {#1} },
- MiddlePunct+ .code:n = { \xeCJK_add_special_punct:nn { middle } {#1} },
- MiddlePunct .code:n = { \xeCJK_set_special_punct:nn { middle } {#1} },
- MiddlePunct- .code:n = { \xeCJK_sub_special_punct:nn { middle } {#1} },
- PunctWidth .tl_gset:N = \g_xeCJK_punct_width_tl ,
PunctStyle .choice_code:n =
{
\tl_set:Nx \l_xeCJK_punctstyle_tl { \l_keys_choice_tl }
\tl_if_eq:NNT \l_xeCJK_punctstyle_tl \c_xeCJK_ps_plain_tl
- { \xeCJKallowbreakbetweenpuncts }
+ { \xeCJKallowbreakbetweenpuncts }
},
- PunctStyle .generate_choices:V = \g_xeCJK_punctstyle_clist,
+ }
+\keys_define:nx { xeCJK / options }
+ { PunctStyle .generate_choices:n = { \exp_not:V \g_xeCJK_punctstyle_clist } }
+\keys_define:nn { xeCJK / options }
+ {
PunctStyle / banjiao .meta:n = { PunctStyle = halfwidth },
PunctStyle / quanjiao .meta:n = { PunctStyle = fullwidth },
PunctStyle / kaiming .meta:n = { PunctStyle = mixedwidth },
@@ -950,6 +1001,23 @@
You~can~only~use~one~of\\\\
"\g_xeCJK_punctstyle_clist".\\
}
+\keys_define:nn { xeCJK / options }
+ {
+ AllowBreakBetweenPuncts .choice:,
+ AllowBreakBetweenPuncts / true .code:n = { \xeCJKallowbreakbetweenpuncts },
+ AllowBreakBetweenPuncts / false .code:n = { \xeCJKnobreakbetweenpuncts },
+ AllowBreakBetweenPuncts .default:n = { true },
+ KaiMingPunct .code:n = { \xeCJK_set_special_punct:nn { mixedwidth } {#1} },
+ KaiMingPunct+ .code:n = { \xeCJK_add_special_punct:nn { mixedwidth } {#1} },
+ KaiMingPunct- .code:n = { \xeCJK_sub_special_punct:nn { mixedwidth } {#1} },
+ LongPunct .code:n = { \xeCJK_set_special_punct:nn { long } {#1} },
+ LongPunct+ .code:n = { \xeCJK_add_special_punct:nn { long } {#1} },
+ LongPunct- .code:n = { \xeCJK_sub_special_punct:nn { long } {#1} },
+ MiddlePunct+ .code:n = { \xeCJK_add_special_punct:nn { middle } {#1} },
+ MiddlePunct .code:n = { \xeCJK_set_special_punct:nn { middle } {#1} },
+ MiddlePunct- .code:n = { \xeCJK_sub_special_punct:nn { middle } {#1} },
+ PunctWidth .tl_gset:N = \g_xeCJK_punct_width_tl ,
+ }
\NewDocumentCommand \xeCJKallowbreakbetweenpuncts { }
{ \cs_set_eq:NN \xeCJK_punct_nobreak: \xeCJK_zero_glue: }
\NewDocumentCommand \xeCJKnobreakbetweenpuncts { }
@@ -979,7 +1047,7 @@
\tl_map_inline:xn {#2}
{
\tl_remove_all:cn { l_xeCJK_#1_punct_tl } {##1}
- \prop_del:cn { l_xeCJK_#1_punct_prop } {##1}
+ \prop_remove:cn { l_xeCJK_#1_punct_prop } {##1}
}
}
\cs_generate_variant:Nn \tl_map_inline:nn { x }
@@ -1002,31 +1070,31 @@
{ { \xeCJK_select_font: \xeCJK_get_punct_dimen:N {#2} } }
\xeCJK_punct_if_long:NTF {#2}
{
- \dim_zero:N \l_tmpa_dim
- \dim_zero:N \l_tmpb_dim
- \dim_zero:N \l_tmpc_dim
+ \dim_zero:N \l_xeCJK_tmpa_dim
+ \dim_zero:N \l_xeCJK_tmpb_dim
+ \dim_zero:N \l_xeCJK_tmpc_dim
}
{
- \dim_set:Nc \l_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/#1/#2 }
- \dim_set:Nc \l_tmpb_dim
- { \l_xeCJK_punct_coor_tl/bound/\str_if_eq:xxTF {#1} lrl/#2 }
- \dim_set:Nn \l_tmpc_dim
+ \dim_set:Nc \l_xeCJK_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/#1/#2 }
+ \dim_set:Nc \l_xeCJK_tmpb_dim
+ { \l_xeCJK_punct_coor_tl/bound/\str_if_eq_x:nnTF {#1} lrl/#2 }
+ \dim_set:Nn \l_xeCJK_tmpc_dim
{
\cs_if_exist_use:cF { g_xeCJK_punct_width/#2 }
{
- \tl_if_blank:xTF \g_xeCJK_punct_width_tl
+ \xeCJK_tl_if_blank:xTF \g_xeCJK_punct_width_tl
{ \c_zero_dim }
{ \g_xeCJK_punct_width_tl }
}
}
\xeCJK_punct_if_middle:NTF {#2}
{
- \dim_set:Nn \l_tmpc_dim
+ \dim_set:Nn \l_xeCJK_tmpc_dim
{
- \dim_compare:nNnTF \l_tmpc_dim > \c_zero_dim
- { \l_tmpc_dim }
+ \dim_compare:nNnTF \l_xeCJK_tmpc_dim > \c_zero_dim
+ { \l_xeCJK_tmpc_dim }
{
- \prg_case_tl:Nnn \l_xeCJK_punctstyle_tl
+ \tl_case:Nnn \l_xeCJK_punctstyle_tl
{
\c_xeCJK_ps_halfwidth_tl { .5 em }
\c_xeCJK_ps_mixedwidth_tl { .5 em }
@@ -1037,49 +1105,49 @@
}
- \tl_use:c { \l_xeCJK_punct_coor_tl/dimen/#2 }
}
- \dim_set:Nn \l_tmpc_dim { .5 \l_tmpc_dim }
+ \dim_set:Nn \l_xeCJK_tmpc_dim { .5 \l_xeCJK_tmpc_dim }
}
{
- \dim_compare:nNnTF \l_tmpc_dim > \c_zero_dim
+ \dim_compare:nNnTF \l_xeCJK_tmpc_dim > \c_zero_dim
{
- \dim_set:Nn \l_tmpc_dim
+ \dim_set:Nn \l_xeCJK_tmpc_dim
{
- \l_tmpc_dim - \l_tmpb_dim
+ \l_xeCJK_tmpc_dim - \l_xeCJK_tmpb_dim
- \tl_use:c { \l_xeCJK_punct_coor_tl/dimen/#2 }
}
}
{
- \dim_set_eq:NN \l_tmpc_dim \l_tmpa_dim
- \dim_set_min:Nn \l_tmpc_dim \l_tmpb_dim
- \prg_case_tl:Nnn \l_xeCJK_punctstyle_tl
+ \dim_set_eq:NN \l_xeCJK_tmpc_dim \l_xeCJK_tmpa_dim
+ \dim_set_min:Nn \l_xeCJK_tmpc_dim \l_xeCJK_tmpb_dim
+ \tl_case:Nnn \l_xeCJK_punctstyle_tl
{
\c_xeCJK_ps_halfwidth_tl { \prg_do_nothing: }
\c_xeCJK_ps_mixedwidth_tl
{
\xeCJK_punct_if_mixedwidth:NT {#2}
{
- \dim_add:Nn \l_tmpc_dim { .5 \l_tmpa_dim }
- \dim_set_min:Nn \l_tmpc_dim \l_tmpa_dim
+ \dim_add:Nn \l_xeCJK_tmpc_dim { .5 \l_xeCJK_tmpa_dim }
+ \dim_set_min:Nn \l_xeCJK_tmpc_dim \l_xeCJK_tmpa_dim
}
}
\c_xeCJK_ps_CCT_tl
{
\xeCJK_punct_if_mixedwidth:NTF {#2}
- { \dim_add:Nn \l_tmpc_dim { .5 \l_tmpa_dim } }
- { \dim_add:Nn \l_tmpc_dim { .3 \l_tmpa_dim } }
- \dim_set_min:Nn \l_tmpc_dim \l_tmpa_dim
+ { \dim_add:Nn \l_xeCJK_tmpc_dim { .5 \l_xeCJK_tmpa_dim } }
+ { \dim_add:Nn \l_xeCJK_tmpc_dim { .3 \l_xeCJK_tmpa_dim } }
+ \dim_set_min:Nn \l_xeCJK_tmpc_dim \l_xeCJK_tmpa_dim
}
}
- { \dim_set_eq:NN \l_tmpc_dim \l_tmpa_dim }
+ { \dim_set_eq:NN \l_xeCJK_tmpc_dim \l_xeCJK_tmpa_dim }
}
}
- \dim_set_max:Nn \l_tmpc_dim \c_zero_dim
+ \dim_set_max:Nn \l_xeCJK_tmpc_dim \c_zero_dim
}
\tl_gset:cx { \l_xeCJK_punct_coor_tl/rule/#1/#2 }
- { - \dim_use:N \l_tmpa_dim }
+ { - \dim_use:N \l_xeCJK_tmpa_dim }
\tl_gset:cx { \l_xeCJK_punct_coor_tl/rule/m/#2 }
- { - \dim_use:N \l_tmpb_dim }
- \tl_gset:cV { \l_xeCJK_punct_coor_tl/glue/#1/#2 } \l_tmpc_dim
+ { - \dim_use:N \l_xeCJK_tmpb_dim }
+ \tl_gset:cV { \l_xeCJK_punct_coor_tl/glue/#1/#2 } \l_xeCJK_tmpc_dim
}
}
}
@@ -1115,14 +1183,14 @@
{
\tl_if_exist:cF { \l_xeCJK_punct_coor_tl/kern/#1-#2 }
{
- \dim_zero:N \l_tmpa_dim
+ \dim_zero:N \l_xeCJK_tmpa_dim
\tl_if_eq:NNF \l_xeCJK_punctstyle_tl \c_xeCJK_ps_plain_tl
{
\tl_if_exist:cTF { g_xeCJK_punct/kern/#1-#2 }
- { \dim_set:Nc \l_tmpa_dim { g_xeCJK_punct/kern/#1-#2 } }
+ { \dim_set:Nc \l_xeCJK_tmpa_dim { g_xeCJK_punct/kern/#1-#2 } }
{ \xeCJK_calc_kern:NN {#1} {#2} }
}
- \tl_gset:cV { \l_xeCJK_punct_coor_tl/kern/#1-#2 } \l_tmpa_dim
+ \tl_gset:cV { \l_xeCJK_punct_coor_tl/kern/#1-#2 } \l_xeCJK_tmpa_dim
}
}
\cs_new_nopar:Nn \xeCJK_calc_kern:NN
@@ -1130,21 +1198,21 @@
\tl_if_eq:NNTF \l_xeCJK_punctstyle_tl \c_xeCJK_ps_marginkerning_tl
{
\xeCJK_punct_if_right:NT {#1}
- { \dim_add:Nc \l_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/r/#1 } }
+ { \dim_add:Nc \l_xeCJK_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/r/#1 } }
\xeCJK_punct_if_right:NF {#2}
- { \dim_add:Nc \l_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/l/#2 } }
+ { \dim_add:Nc \l_xeCJK_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/l/#2 } }
}
{
\tl_if_eq:NNTF \l_xeCJK_punctstyle_tl \c_xeCJK_ps_fullwidth_tl
- { \xeCJK_calc_kern:NnNN \l_tmpa_dim { 1.5 em } {#1} {#2} }
+ { \xeCJK_calc_kern:NnNN \l_xeCJK_tmpa_dim { 1.5 em } {#1} {#2} }
{
\xeCJK_punct_if_both_left_right:NNTF {#1} {#2}
{
\xeCJK_punct_if_mixedwidth:NT {#1}
{
- \xeCJK_calc_kern:NnNN \l_tmpa_dim { 1 em } {#1} {#2}
- \dim_compare:nNnT \l_tmpa_dim < { .1 em }
- { \dim_set:Nc \l_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/l/#1 } }
+ \xeCJK_calc_kern:NnNN \l_xeCJK_tmpa_dim { 1 em } {#1} {#2}
+ \dim_compare:nNnT \l_xeCJK_tmpa_dim < { .1 em }
+ { \dim_set:Nc \l_xeCJK_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/l/#1 } }
}
}
{
@@ -1154,27 +1222,27 @@
! ( \tl_if_eq_p:NN \l_xeCJK_punctstyle_tl \c_xeCJK_ps_halfwidth_tl )
}
{
- \dim_set:Nc \l_tmpa_dim { \l_xeCJK_punct_coor_tl/glue/r/#1 }
- \dim_set:Nn \l_tmpa_dim { .7 \l_tmpa_dim }
+ \dim_set:Nc \l_xeCJK_tmpa_dim { \l_xeCJK_punct_coor_tl/glue/r/#1 }
+ \dim_set:Nn \l_xeCJK_tmpa_dim { .7 \l_xeCJK_tmpa_dim }
}
{
- \xeCJK_calc_kern:NnNN \l_tmpa_dim { 1 em } {#1} {#2}
- \dim_compare:nNnT \l_tmpa_dim < { .1 em }
+ \xeCJK_calc_kern:NnNN \l_xeCJK_tmpa_dim { 1 em } {#1} {#2}
+ \dim_compare:nNnT \l_xeCJK_tmpa_dim < { .1 em }
{
- \dim_set:Nc \l_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/l/#1 }
- \dim_set_min:Nc \l_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/r/#1 }
- \dim_set:Nc \l_tmpb_dim { \l_xeCJK_punct_coor_tl/bound/l/#2 }
- \dim_set_min:Nc \l_tmpb_dim { \l_xeCJK_punct_coor_tl/bound/r/#2 }
- \dim_set_max:Nn \l_tmpa_dim \l_tmpb_dim
+ \dim_set:Nc \l_xeCJK_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/l/#1 }
+ \dim_set_min:Nc \l_xeCJK_tmpa_dim { \l_xeCJK_punct_coor_tl/bound/r/#1 }
+ \dim_set:Nc \l_xeCJK_tmpb_dim { \l_xeCJK_punct_coor_tl/bound/l/#2 }
+ \dim_set_min:Nc \l_xeCJK_tmpb_dim { \l_xeCJK_punct_coor_tl/bound/r/#2 }
+ \dim_set_max:Nn \l_xeCJK_tmpa_dim \l_xeCJK_tmpb_dim
}
}
}
}
\bool_if:nT
{ \xeCJK_punct_if_long_p:N {#1} || \xeCJK_punct_if_long_p:N {#2} }
- { \dim_set_max:Nn \l_tmpa_dim { .1 em } }
+ { \dim_set_max:Nn \l_xeCJK_tmpa_dim { .1 em } }
}
- \dim_set_max:Nn \l_tmpa_dim \c_zero_dim
+ \dim_set_max:Nn \l_xeCJK_tmpa_dim \c_zero_dim
}
\cs_generate_variant:Nn \xeCJK_get_kern:NN { V }
\cs_new_nopar:Nn \xeCJK_calc_kern:NnNN
@@ -1194,26 +1262,26 @@
}
\cs_new_nopar:Nn \xeCJK_get_punct_dimen:N
{
- \xeCJK_get_glyph_bounds:nNN { left } {#1} \l_tmpa_dim
- \tl_gset:cV { \l_xeCJK_punct_coor_tl/bound/l/#1 } \l_tmpa_dim
- \dim_set_eq:NN \l_tmpb_dim \l_tmpa_dim
- \xeCJK_get_glyph_bounds:nNN { right } {#1} \l_tmpa_dim
- \tl_gset:cV { \l_xeCJK_punct_coor_tl/bound/r/#1 } \l_tmpa_dim
- \dim_add:Nn \l_tmpb_dim \l_tmpa_dim
+ \xeCJK_get_glyph_bounds:nNN { left } {#1} \l_xeCJK_tmpa_dim
+ \tl_gset:cV { \l_xeCJK_punct_coor_tl/bound/l/#1 } \l_xeCJK_tmpa_dim
+ \dim_set_eq:NN \l_xeCJK_tmpb_dim \l_xeCJK_tmpa_dim
+ \xeCJK_get_glyph_bounds:nNN { right } {#1} \l_xeCJK_tmpa_dim
+ \tl_gset:cV { \l_xeCJK_punct_coor_tl/bound/r/#1 } \l_xeCJK_tmpa_dim
+ \dim_add:Nn \l_xeCJK_tmpb_dim \l_xeCJK_tmpa_dim
\tl_gset:cx { \l_xeCJK_punct_coor_tl/dimen/#1 }
- { \dim_eval:n { \etex_fontcharwd:D \tex_font:D `#1 - \l_tmpb_dim } }
+ { \dim_eval:n { \etex_fontcharwd:D \tex_font:D `#1 - \l_xeCJK_tmpb_dim } }
\bool_if:nT
{
\xeCJK_punct_if_long_p:N {#1} &&
- ! ( \str_if_eq_p:xx {#1} { … } || \str_if_eq_p:xx {#1} { ‥ } )
+ ! ( \str_if_eq_x_p:nn {#1} { … } || \str_if_eq_x_p:nn {#1} { ‥ } )
}
{
\clist_map_inline:Nn \g_xeCJK_punctstyle_clist
{
- \str_if_eq:xxF \c_xeCJK_ps_plain_tl {##1}
+ \str_if_eq_x:nnF \c_xeCJK_ps_plain_tl {##1}
{
\tl_gset:cx { \l_xeCJK_font_coor_tl/##1/kern/#1-#1 }
- { - \dim_use:N \l_tmpb_dim }
+ { - \dim_use:N \l_xeCJK_tmpb_dim }
}
}
}
@@ -1223,10 +1291,10 @@
\dim_set:Nn #3
{
\XeTeXglyphbounds
- \prg_case_str:xxn {#1}
+ \str_case_x:nnn {#1}
{
- { left } { \c_one } { top } { \c_two }
- { right } { \c_three } { bottom } { \c_four }
+ { left } { \c_one } { top } { \c_two }
+ { right } { \c_three } { bottom } { \c_four }
}
{ \c_three }
\int_eval:n { \XeTeXcharglyph `#2 }
@@ -1265,7 +1333,7 @@
\font_glyph_if_exist:NnTF \tex_font:D {`#1}
{ \xeCJK_fallback_save_CJKsymbol:N {#1} }
{
- \xeCJK_family_if_exist:nTF { \xeCJK@family/FallBack }
+ \xeCJK_family_if_exist:xTF { \xeCJK@family/FallBack }
{ {
\tl_put_right:Nn \xeCJK@family { /FallBack }
\xeCJK_select_font:
@@ -1350,7 +1418,7 @@
{
#1 .code:n =
{
- \tl_if_blank:xTF {##1}
+ \xeCJK_tl_if_blank:xTF {##1}
{
\bool_set_false:c { l_xeCJK_copy_#1_bool }
\bool_set_false:c { l_xeCJK_add_#1_bool }
@@ -1358,7 +1426,7 @@
}
{
\clist_put_right:Nx \l_xeCJK_sub_key_clist {#1}
- \str_if_eq:xxTF {##1} *
+ \str_if_eq_x:nnTF {##1} *
{
\bool_set_true:c { l_xeCJK_copy_#1_bool }
\bool_set_false:c { l_xeCJK_add_#1_bool }
@@ -1376,20 +1444,20 @@
\cs_generate_variant:Nn \xeCJK_new_sub_key:n { x }
\cs_new_nopar:Nn \xeCJK_get_sub_features:nn
{
- \tl_set:Nx \l_tmpa_tl {#2}
+ \tl_set:Nx \l_xeCJK_tmpa_tl {#2}
\clist_clear:N \l_xeCJK_sub_fontfeat_clist
- \xeCJK_gobble_brace:N \l_tmpa_tl
- \exp_args:No \tl_if_head_eq_charcode:nNTF \l_tmpa_tl [ % ]
+ \xeCJK_gobble_brace:N \l_xeCJK_tmpa_tl
+ \exp_args:No \tl_if_head_eq_charcode:nNTF \l_xeCJK_tmpa_tl [ % ]
{
- \exp_after:wN \xeCJK_get_sub_features_aux:n \l_tmpa_tl \c_empty_tl
- \tl_if_blank:xT \l_xeCJK_sub_fontname_tl
+ \exp_after:wN \xeCJK_get_sub_features_aux:n \l_xeCJK_tmpa_tl \c_empty_tl
+ \xeCJK_tl_if_blank:xT \l_xeCJK_sub_fontname_tl
{
- \tl_set:Nx \l_xeCJK_sub_fontname_tl \l_tmpa_tl
+ \tl_set:Nx \l_xeCJK_sub_fontname_tl \l_xeCJK_tmpa_tl
\clist_clear:N \l_xeCJK_sub_fontfeat_clist
}
}
- { \tl_set:Nx \l_xeCJK_sub_fontname_tl \l_tmpa_tl }
- \tl_if_blank:xTF \l_xeCJK_sub_fontname_tl
+ { \tl_set:Nx \l_xeCJK_sub_fontname_tl \l_xeCJK_tmpa_tl }
+ \xeCJK_tl_if_blank:xTF \l_xeCJK_sub_fontname_tl
{ \tl_set:Nx \l_xeCJK_sub_fontname_tl \l_xeCJK_fontname_tl }
{ \tl_replace_all:Nnx \l_xeCJK_sub_fontname_tl * \l_xeCJK_fontname_tl }
\clist_set:cx { l_xeCJK_#1_fontfeat_clist } \l_xeCJK_sub_fontfeat_clist
@@ -1409,10 +1477,6 @@
\tl_set:Nx \l_xeCJK_sub_fontname_tl {#2}
}
\xeCJK_new_sub_key:n { FallBack }
-\cs_set_protected:cpn { \c_keys_props_root_tl .clist_set_x:N } #1
- { \keys_variable_set:NnN #1 { clist } x }
-\cs_set_protected:cpn { \c_keys_props_root_tl .clist_set_x:c } #1
- { \keys_variable_set:cnN {#1} { clist } x }
\cs_new_nopar:Nn \xeCJK_map_features_id:n
{ \prop_get:Nn \g_xeCJK_features_id_prop { #1 } }
\prop_new:N \g_xeCJK_features_id_prop
@@ -1425,8 +1489,8 @@
{
\keys_define:nn { xeCJK / features }
{
- #2Font .tl_set_x:c = { l_xeCJK_fontname_#1_tl },
- #2Features .clist_set_x:c = { l_xeCJK_fontfeat_#1_clist } ,
+ #2Font .tl_set_x:c = { l_xeCJK_fontname_#1_tl },
+ #2Features .tl_set_x:c = { l_xeCJK_fontfeat_#1_clist } ,
}
}
\keys_define:nn { xeCJK / features }
@@ -1516,10 +1580,10 @@
\cs_generate_variant:Nn \xeCJK_set_family:nnn { ncc }
\cs_new_nopar:Nn \xeCJK_check_family:n
{
- \prop_get:NnNT \g_xeCJK_family_prop {#1} \l_tmpa_tl
+ \prop_get:NnNT \g_xeCJK_family_prop {#1} \l_xeCJK_tmpa_tl
{
- \prop_gpop:NnNT \g_xeCJK_family_name_prop {#1} \l_tmpa_tl { }
- \xeCJK_warning:nxx { CJKfamily-redef } {#1} \l_tmpa_tl
+ \prop_gpop:NnNT \g_xeCJK_family_name_prop {#1} \l_xeCJK_tmpa_tl { }
+ \xeCJK_warning:nxx { CJKfamily-redef } {#1} \l_xeCJK_tmpa_tl
}
}
\cs_generate_variant:Nn \xeCJK_check_family:n { V }
@@ -1564,7 +1628,7 @@
{ \xeCJK_add_font_if_new:nv {bf#1} { l_xeCJK_fontname_#1_tl } }
}
{
- \str_if_eq:xxT {#1} {bf}
+ \str_if_eq_x:nnT {#1} {bf}
{
\clist_map_inline:nn { it , sl }
{
@@ -1578,25 +1642,25 @@
}
\prg_new_conditional:Nnn \xeCJK_if_font_select:n { p, T, F, TF }
{
- \exp_args:Nc
- \tl_if_blank:xTF { l_xeCJK_fontname_#1_tl } \prg_return_false: \prg_return_true:
+ \exp_args:Nc \xeCJK_tl_if_blank:xTF { l_xeCJK_fontname_#1_tl }
+ \prg_return_false: \prg_return_true:
}
\prg_new_conditional:Nnn \xeCJK_if_it_or_sl:n { p, T, F, TF }
{
- \bool_if:nTF { \str_if_eq_p:xx { it } {#1} || \str_if_eq_p:xx { sl } {#1} }
+ \bool_if:nTF { \str_if_eq_x_p:nn { it } {#1} || \str_if_eq_x_p:nn { sl } {#1} }
\prg_return_true: \prg_return_false:
}
\cs_new_nopar:Nn \xeCJK_set_fake:n
{
- \str_if_eq:xxTF {#1} { bf }
+ \str_if_eq_x:nnTF {#1} { bf }
{ \bool_if:NT \l_xeCJK_AutoFakeBold_bool { \xeCJK_add_fake_bold:n {#1} } }
{
\bool_if:NTF \l_xeCJK_AutoFakeSlant_bool
{
\bool_if:nT
{ \xeCJK_if_it_or_sl_p:n {#1} ||
- ( \str_if_eq_p:xx {#1} {bfit} && ! ( \xeCJK_if_font_select_p:n {it} ) ) ||
- ( \str_if_eq_p:xx {#1} {bfsl} && ! ( \xeCJK_if_font_select_p:n {sl} ) )
+ ( \str_if_eq_x_p:nn {#1} {bfit} && ! ( \xeCJK_if_font_select_p:n {it} ) ) ||
+ ( \str_if_eq_x_p:nn {#1} {bfsl} && ! ( \xeCJK_if_font_select_p:n {sl} ) )
}
{ \xeCJK_add_fake_slant:n {#1} }
}
@@ -1620,10 +1684,10 @@
}
}
\cs_new_nopar:Nn \xeCJK_get_map_font:n
- { \tl_use:c { l_xeCJK_fontname_\str_if_eq:xxTF {#1} {it} {sl} {it} _tl } }
+ { \tl_use:c { l_xeCJK_fontname_\str_if_eq_x:nnTF {#1} {it} {sl} {it} _tl } }
\prg_new_conditional:Nnn \xeCJK_if_map_font_select:n { p, T, F, TF }
{
- \tl_if_blank:xTF { \xeCJK_get_map_font:n {#1} }
+ \xeCJK_tl_if_blank:xTF { \xeCJK_get_map_font:n {#1} }
\prg_return_false: \prg_return_true:
}
\cs_new_nopar:Nn \xeCJK_pass_features:
@@ -1633,12 +1697,12 @@
\clist_if_empty:cF { l_xeCJK_fontfeat_##1_clist }
{
\clist_put_right:Nx \l_xeCJK_pass_features_clist
- { ##2Features = { \clist_use:c { l_xeCJK_fontfeat_##1_clist } } }
+ { ##2Features = { \tl_use:c { l_xeCJK_fontfeat_##1_clist } } }
}
}
\prop_map_inline:Nn \l_xeCJK_add_font_prop
{ \clist_put_right:Nx \l_xeCJK_pass_features_clist { ##1 = { ##2 } } }
- \tl_if_blank:xF \l_xeCJK_monoscale_tl
+ \xeCJK_tl_if_blank:xF \l_xeCJK_monoscale_tl
{ \clist_put_right:Nx \l_xeCJK_pass_features_clist \l_xeCJK_monoscale_tl }
}
\prop_new:N \g_xeCJK_family_prop
@@ -1665,27 +1729,27 @@
\bool_if:cT { l_xeCJK_copy_##1_bool }
{
\xeCJK_check_family:V \l_xeCJK_sub_family_tl
- \prop_get:NVNT \g_xeCJK_family_prop \l_xeCJK_family_tl \l_tmpa_tl
- { \prop_gput:NVV \g_xeCJK_family_prop \l_xeCJK_sub_family_tl \l_tmpa_tl }
- \prop_get:NVNT \g_xeCJK_family_options_prop \l_xeCJK_family_tl \l_tmpa_clist
+ \prop_get:NVNT \g_xeCJK_family_prop \l_xeCJK_family_tl \l_xeCJK_tmpa_tl
+ { \prop_gput:NVV \g_xeCJK_family_prop \l_xeCJK_sub_family_tl \l_xeCJK_tmpa_tl }
+ \prop_get:NVNT \g_xeCJK_family_options_prop \l_xeCJK_family_tl \l_xeCJK_tmpa_clist
{
- \clist_remove_all:Nn \l_tmpa_clist { ##1 = * }
- \prop_gput:NVV \g_xeCJK_family_options_prop \l_xeCJK_sub_family_tl \l_tmpa_clist
+ \clist_remove_all:Nn \l_xeCJK_tmpa_clist { ##1 = * }
+ \prop_gput:NVV \g_xeCJK_family_options_prop \l_xeCJK_sub_family_tl \l_xeCJK_tmpa_clist
}
\cs_gset_protected_nopar:cpx { xeCJK/family/\l_xeCJK_sub_family_tl }
{
- \xeCJK_family_if_exist:nT { \l_xeCJK_family_tl }
+ \xeCJK_family_if_exist:xT { \l_xeCJK_family_tl }
{
\prop_get:NnNT \exp_not:N \g_xeCJK_family_name_prop
- { \l_xeCJK_family_tl } \exp_not:N \l_tmpa_tl
+ { \l_xeCJK_family_tl } \exp_not:N \l_xeCJK_tmpa_tl
{
\prop_gput:NnV \exp_not:N \g_xeCJK_family_name_prop
- { \l_xeCJK_sub_family_tl } \exp_not:N \l_tmpa_tl
+ { \l_xeCJK_sub_family_tl } \exp_not:N \l_xeCJK_tmpa_tl
\cs_gset_protected_nopar:cpx { xeCJK/family/\l_xeCJK_sub_family_tl }
\exp_not:n
{ {
\exp_not:N \fontencoding { \g_fontspec_encoding_tl }
- \exp_not:N \fontfamily { \l_tmpa_tl }
+ \exp_not:N \fontfamily { \l_xeCJK_tmpa_tl }
\exp_not:N \selectfont
} }
}
@@ -1701,11 +1765,11 @@
}
\cs_new_nopar:Nn \xeCJK_copy_family:nn
{
- \xeCJK_family_if_exist:nT {#2}
+ \xeCJK_family_if_exist:xT {#2}
{
\tl_map_inline:nn
{ \g_xeCJK_family_prop \g_xeCJK_family_options_prop \g_xeCJK_family_name_prop }
- { \prop_get:NnNT ##1 {#2} \l_tmpa_tl { \prop_gput:NnV ##1 {#1} \l_tmpa_tl } }
+ { \prop_get:NnNT ##1 {#2} \l_xeCJK_tmpa_tl { \prop_gput:NnV ##1 {#1} \l_xeCJK_tmpa_tl } }
\cs_gset_eq:cc { xeCJK/family/#1 } { xeCJK/family/#2 }
}
}
@@ -1717,32 +1781,32 @@
{
\tl_set:Nx \l_xeCJK_current_coor_tl \l_xeCJK_font_coor_tl
\cs_if_exist_use:cT { xeCJK/family/\xeCJK@family }
- { \exp_last_unbraced:NNV \cs_gset_eq:cN \l_xeCJK_current_coor_tl \font@name }
+ { \exp_last_unbraced:NNV \cs_gset_eq:cN \l_xeCJK_current_coor_tl \tex_font:D }
}
}
\cs_new_eq:NN \xeCJK@setfont \xeCJK_select_font:
\cs_new_nopar:Nn \xeCJK_switch_font:nn
{
- \str_if_eq:xxF {#1} {#2}
+ \str_if_eq_x:nnF {#1} {#2}
{
\xeCJK_info:nxx { CJK-block } {#1} {#2}
\tl_remove_all:Nn \xeCJK@family { /#1 }
- \str_if_eq:xxF {#2} { CJK }
+ \str_if_eq_x:nnF {#2} { CJK }
{
- \tl_set:Nx \l_tmpa_tl \xeCJK@family
+ \tl_set:Nx \l_xeCJK_tmpa_tl \xeCJK@family
\tl_put_right:Nx \xeCJK@family { /#2 }
- \xeCJK_family_if_exist:nF \xeCJK@family
+ \xeCJK_family_if_exist:xF \xeCJK@family
{
- \xeCJK_family_if_exist:nTF { \CJKfamilydefault/#2 }
+ \xeCJK_family_if_exist:xTF { \CJKfamilydefault/#2 }
{ \xeCJK_copy_family:xx \xeCJK@family { \CJKfamilydefault/#2 } }
- { \xeCJK_copy_family:xx \xeCJK@family \l_tmpa_tl }
+ { \xeCJK_copy_family:xx \xeCJK@family \l_xeCJK_tmpa_tl }
}
}
}
\xeCJK_select_font:
}
\xeCJK_msg_new:nn { CJK-block } { Switch~from~block~'#1'~to~'#2'. }
-\prg_new_protected_conditional:Nnn \xeCJK_family_if_exist:n { T, F, TF }
+\prg_new_protected_conditional:Nnn \xeCJK_family_if_exist:x { T, F, TF }
{
\cs_if_free:cTF { xeCJK/family/#1 } \prg_return_false:
{
@@ -1752,22 +1816,23 @@
}
\NewDocumentCommand \CJKfamily { m }
{
- \xeCJK_family_if_exist:nTF {#1}
+ \xeCJK_family_if_exist:xTF {#1}
{ \tl_set:Nx \xeCJK@family {#1} }
{
- \cs_if_free:cT { xeCJK_warned_aux_#1 }
+ \seq_if_in:NxF \g_xeCJK_unknown_family_seq {#1}
{
+ \seq_gput_right:Nx \g_xeCJK_unknown_family_seq {#1}
\xeCJK_warning:nx { CJKfamily-Unknown } {#1}
- \tl_new:c { xeCJK_warned_aux_#1 }
}
}
\tex_ignorespaces:D
}
+\seq_new:N \g_xeCJK_unknown_family_seq
\xeCJK_msg_new:nn { CJKfamily-Unknown }
{
Unknown~CJK~family~'#1'~is~ignored.\\\\
Try~to~use~
- \prg_case_str:xxn {#1}
+ \str_case_x:nnn {#1}
{
\CJKrmdefault { \token_to_str:N \setCJKmainfont }
\CJKsfdefault { \token_to_str:N \setCJKsansfont }
@@ -1811,35 +1876,35 @@
\prop_if_in:NVTF \g_xeCJK_family_prop \xeCJK@family
{
\group_begin:
- \clist_set:Nx \l_tmpa_clist {#1}
- \prop_get:NVN \g_xeCJK_family_prop \xeCJK@family \l_tmpa_tl
+ \clist_set:Nx \l_xeCJK_tmpa_clist {#1}
+ \prop_get:NVN \g_xeCJK_family_prop \xeCJK@family \l_xeCJK_tmpa_tl
\clist_map_inline:Nn \g_xeCJK_CJK_subclass_clist
{
- \clist_if_in:NnT \l_tmpa_clist {##1}
+ \clist_if_in:NnT \l_xeCJK_tmpa_clist {##1}
{
- \clist_remove_all:Nn \l_tmpa_clist {##1}
- \prop_get:NxNF \g_xeCJK_family_prop { \xeCJK@family/##1 } \l_tmpb_tl
+ \clist_remove_all:Nn \l_xeCJK_tmpa_clist {##1}
+ \prop_get:NxNF \g_xeCJK_family_prop { \xeCJK@family/##1 } \l_xeCJK_tmpb_tl
{
\prop_get:NxNF \g_xeCJK_family_prop
- { \CJKfamilydefault/##1 } \l_tmpb_tl
- { \tl_set:Nx \l_tmpb_tl \l_tmpa_tl }
+ { \CJKfamilydefault/##1 } \l_xeCJK_tmpb_tl
+ { \tl_set:Nx \l_xeCJK_tmpb_tl \l_xeCJK_tmpa_tl }
}
- \clist_set:Nx \l_tmpa_clist
- { ##1 = { [ \l_tmpa_clist ] { \l_tmpb_tl } } }
+ \clist_set:Nx \l_xeCJK_tmpa_clist
+ { ##1 = { [ \l_xeCJK_tmpa_clist ] { \l_xeCJK_tmpb_tl } } }
\clist_map_break:
}
}
- \prop_get:NVNF \g_xeCJK_family_options_prop \xeCJK@family \l_tmpb_clist
- { \clist_clear:N \l_tmpb_clist }
- \clist_clear:N \l_tmpc_clist
- \clist_map_inline:Nn \l_tmpb_clist
+ \prop_get:NVNF \g_xeCJK_family_options_prop \xeCJK@family \l_xeCJK_tmpb_clist
+ { \clist_clear:N \l_xeCJK_tmpb_clist }
+ \clist_clear:N \l_xeCJK_tmpc_clist
+ \clist_map_inline:Nn \l_xeCJK_tmpb_clist
{
- \clist_if_in:NnF \l_tmpa_clist {##1}
- { \clist_put_right:Nn \l_tmpc_clist {##1} }
+ \clist_if_in:NnF \l_xeCJK_tmpa_clist {##1}
+ { \clist_put_right:Nn \l_xeCJK_tmpc_clist {##1} }
}
- \clist_put_left:NV \l_tmpa_clist \l_tmpc_clist
+ \clist_put_left:NV \l_xeCJK_tmpa_clist \l_xeCJK_tmpc_clist
\use:x
- { \group_end: \exp_not:N \CJKfontspec [ \l_tmpa_clist ] { \l_tmpa_tl } }
+ { \group_end: \exp_not:N \CJKfontspec [ \l_xeCJK_tmpa_clist ] { \l_xeCJK_tmpa_tl } }
}
{ \xeCJK_warning:n { addCJKfontfeature-ignored } }
\tex_ignorespaces:D
@@ -1868,68 +1933,66 @@
\etex_protected:D \tl_put_right:Nn \ttfamily { \CJKfamily \CJKttdefault }
\cs_set_eq:NN \reset@font \normalfont
}
+\@onlypreamble \setCJKmainfont
+\@onlypreamble \setCJKmathfont
+\@onlypreamble \setCJKsansfont
+\@onlypreamble \setCJKmonofont
+\@onlypreamble \setCJKromanfont
\NewDocumentCommand \setCJKmathfont { O{} m }
{ \xeCJK_set_family:nnn \c_xeCJK_math_tl {#1} {#2} }
\tl_const:Nn \c_xeCJK_math_tl { CJKmath }
\keys_define:nn { xeCJK / options } { CJKmath .bool_gset:N = \g_xeCJK_math_bool }
\NewDocumentCommand \xeCJKsetmathcode { m m m m }
{
- \xeCJK_check_num_range:nnNN {#1} {#2} \l_tmpa_int \l_tmpb_int
- \int_set:Nn \l_tmpc_int { \xeCJK_math_type:n {#3} }
+ \xeCJK_check_num_range:nnNN {#1} {#2} \l_xeCJK_tmpa_int \l_xeCJK_tmpb_int
+ \int_set:Nn \l_xeCJK_tmpc_int { \xeCJK_math_type:n {#3} }
\loop
- \XeTeXmathcode \l_tmpa_int = \l_tmpc_int \use:c { sym #4 } \l_tmpa_int
- \if_int_compare:w \l_tmpa_int < \l_tmpb_int
- \int_incr:N \l_tmpa_int
+ \XeTeXmathcode
+ \l_xeCJK_tmpa_int = \l_xeCJK_tmpc_int \use:c { sym #4 } \l_xeCJK_tmpa_int
+ \if_int_compare:w \l_xeCJK_tmpa_int < \l_xeCJK_tmpb_int
+ \int_incr:N \l_xeCJK_tmpa_int
\repeat
}
-\cs_set_eq:NN \xeCJK_math_type:n \mathchar@type
-\tl_put_left:Nn \document
+\cs_new_eq:NN \xeCJK_math_type:n \mathchar@type
+\cs_new_nopar:Nn \xeCJK_set_mathfont:
{
- \group_end:
- \normalfont
- \prop_if_empty:NTF \g_xeCJK_family_prop
- { \xeCJK_warning:n { no-CJKfamily } }
+ \xeCJK_family_if_exist:xTF \c_xeCJK_math_tl
+ { \tl_set:Nx \l_xeCJK_tmpa_tl \c_xeCJK_math_tl }
+ {
+ \xeCJK_family_if_exist:xTF \CJKfamilydefault
+ { \tl_set:Nx \l_xeCJK_tmpa_tl \CJKfamilydefault }
+ { \tl_set_eq:NN \l_xeCJK_tmpa_tl \q_no_value }
+ }
+ \prop_get:NVNT \g_xeCJK_family_name_prop \l_xeCJK_tmpa_tl \l_xeCJK_math_family_tl
{
- \bool_if:NT \g_xeCJK_math_bool
+ \DeclareSymbolFont \c_xeCJK_math_tl \g_fontspec_encoding_tl
+ \l_xeCJK_math_family_tl \mddefault \shapedefault
+ \SetSymbolFont \c_xeCJK_math_tl { bold } \g_fontspec_encoding_tl
+ \l_xeCJK_math_family_tl \bfdefault \shapedefault
+ \clist_map_inline:nn { CJK, FullLeft, FullRight }
{
- \xeCJK_family_if_exist:nTF \c_xeCJK_math_tl
- { \tl_set:Nx \l_tmpa_tl \c_xeCJK_math_tl }
+ \clist_map_inline:cn { g_xeCJK_##1_range_clist }
{
- \xeCJK_family_if_exist:nTF \CJKfamilydefault
- { \tl_set:Nx \l_tmpa_tl \CJKfamilydefault }
- { \tl_set_eq:NN \l_tmpa_tl \q_no_value }
- }
- \prop_get:NVNT \g_xeCJK_family_name_prop \l_tmpa_tl \l_xeCJK_math_family_tl
- {
- \DeclareSymbolFont \c_xeCJK_math_tl \g_fontspec_encoding_tl
- \l_xeCJK_math_family_tl \mddefault \shapedefault
- \SetSymbolFont \c_xeCJK_math_tl { bold } \g_fontspec_encoding_tl
- \l_xeCJK_math_family_tl \bfdefault \shapedefault
- \clist_map_inline:nn { CJK, FullLeft, FullRight }
- {
- \clist_map_inline:cn { g_xeCJK_#1_range_clist }
- {
- \xeCJK_setcharclass_aux:Nn \xeCJKsetmathcode {##1}
- \mathalpha \c_xeCJK_math_tl
- }
- }
+ \xeCJK_setcharclass_aux:Nn \xeCJKsetmathcode {####1}
+ \mathalpha \c_xeCJK_math_tl
}
}
}
- \group_begin:
+ }
+\xeCJK_AtEndPreamble:n
+ {
+ \normalfont
+ \prop_if_empty:NTF \g_xeCJK_family_prop
+ { \xeCJK_warning:n { no-CJKfamily } }
+ { \bool_if:NT \g_xeCJK_math_bool { \xeCJK_set_mathfont: } }
}
\xeCJK_msg_new:nn { no-CJKfamily }
{
It~seems~that~you~have~not~declare~a~CJKfamily.\\
If~you~want~to~use~xeCJK~in~the~right~way,~you~should~use\\\\
- \token_to_str:N~\xeCJKmainfont[...]{...}\\\\
+ \token_to_str:N \xeCJKmainfont[...]{...}\\\\
in~the~preamble~to~declare~the~main~CJKfamily.\\
}
-\@onlypreamble \setCJKmainfont
-\@onlypreamble \setCJKmathfont
-\@onlypreamble \setCJKsansfont
-\@onlypreamble \setCJKmonofont
-\@onlypreamble \setCJKromanfont
\fp_new:N \g_xeCJK_monoscale_fp
\dim_new:N \g_xeCJK_exspace_dim
\NewDocumentCommand \setCJKmonoscale { }
@@ -1942,9 +2005,8 @@
{
\group_begin:
\fontfamily \ttdefault \selectfont
- \fp_gset_from_dim:Nn \g_xeCJK_monoscale_fp
- { \c_two \tex_fontdimen:D \c_two \tex_font:D }
- \fp_gdiv:Nn \g_xeCJK_monoscale_fp \f@size
+ \fp_gset:Nn \g_xeCJK_monoscale_fp
+ { \dim_to_fp:n { \c_two \tex_fontdimen:D \c_two \tex_font:D } / ( \f@size ) }
\group_end:
}
\NewDocumentCommand \setCJKmonoexspace { } { \xeCJK_set_monoexspace: }
@@ -1990,7 +2052,7 @@
}
}
\bool_new:N \l_xeCJK_fixed_spacing_bool
-\AtBeginDocument { \tl_put_right:Nn \verbatim@font \CJKfixedspacing }
+\xeCJK_AfterPreamble:n { \tl_put_right:Nn \verbatim@font \CJKfixedspacing }
\NewDocumentCommand \setCJKmonofont { s t+ O{} m }
{
\IfBooleanTF {#1}
@@ -2035,7 +2097,6 @@
{
CJKglue = { \skip_horizontal:n { \c_zero_skip \@plus .08\baselineskip } } ,
CJKecglue = \c_space_token ,
- CheckSingleglue = \CJKglue ,
xCJKecglue = false ,
CheckSingle = false ,
CJKspace = false ,
@@ -2064,38 +2125,43 @@
\keys_set:nn { xeCJK / options } {#1}
\tex_ignorespaces:D
}
-\NewDocumentCommand \xeCJKsetEmboldenFactor { m }
+\NewDocumentCommand \xeCJKsetemboldenfactor { m }
{ \xeCJKsetup { EmboldenFactor = {#1} } }
-\NewDocumentCommand \xeCJKsetSlantFactor { m }
+\NewDocumentCommand \xeCJKsetslantfactor { m }
{ \xeCJKsetup { SlantFactor = {#1} } }
\NewDocumentCommand \punctstyle { m } { \xeCJKsetup { PunctStyle = {#1} } }
\cs_new_nopar:Npn \xeCJKplainchr { \punctstyle { plain } }
\NewDocumentCommand \CJKsetecglue { m } { \xeCJKsetup { CJKecglue = {#1} } }
\cs_new_eq:NN \xeCJKsetecglue \CJKsetecglue
-\cs_new_eq:NN \xeCJK_itcorr_aux \/
-\bool_new:N \g_xeCJK_itcorr_bool
-\cs_set_protected_nopar:Npn \/
+\cs_new_nopar:Nn \xeCJK_fix_itcorr:
{
\scan_stop:
- \int_compare:nNnT \tex_lastkern:D = \c_three
+ \xeCJK_if_last_node:nTF { default }
{
\tex_unkern:D \tex_unkern:D
- \bool_gset_true:N \g_xeCJK_itcorr_bool
+ \xeCJK_itcorr_aux
+ { \xeCJK_make_node:n { default_itcorr } }
}
- \xeCJK_itcorr_aux
+ { \xeCJK_itcorr_aux }
+ }
+\cs_new_eq:NN \xeCJK_itcorr_aux \/
+\cs_set_protected_nopar:Npn \/
+ {
+ \int_compare:nNnTF \XeTeXinterchartokenstate > \c_zero
+ { \xeCJK_fix_itcorr: } { \xeCJK_itcorr_aux }
}
\cs_set_eq:NN \@@italiccorr \/
-\cs_new_nopar:Nn \xeCJK_compatibility_hook:
+\xeCJK_AfterEndPreamble:n
{
\int_compare:nNnF
- { \c_three + \seq_length:N \g_xeCJK_class_seq } = \xe@alloc@intercharclass
+ { \c_three + \seq_count:N \g_xeCJK_class_seq } = \xe@alloc@intercharclass
{
- \int_set_eq:NN \l_tmpa_int \c_three
- \int_until_do:nNnn \l_tmpa_int = \xe@alloc@intercharclass
+ \int_set_eq:NN \l_xeCJK_tmpa_int \c_three
+ \int_until_do:nNnn \l_xeCJK_tmpa_int = \xe@alloc@intercharclass
{
- \int_incr:N \l_tmpa_int
- \seq_if_in:NVF \g_xeCJK_class_seq \l_tmpa_int
- { \xeCJK_set_others_toks:n \l_tmpa_int }
+ \int_incr:N \l_xeCJK_tmpa_int
+ \seq_if_in:NVF \g_xeCJK_class_seq \l_xeCJK_tmpa_int
+ { \xeCJK_set_others_toks:n \l_xeCJK_tmpa_int }
}
}
}
@@ -2123,10 +2189,9 @@
}
}
\int_new:N \xeCJK_Others_class
-\tl_put_right:Nn \document { \xeCJK_compatibility_hook: \tex_ignorespaces:D }
\cs_new_nopar:Nn \xeCJK_patch:Nnn
{ \tl_put_left:Nn #1 {#2} \tl_put_right:Nn #1 {#3} }
-\AtBeginDocument
+\xeCJK_AfterPreamble:n
{
\tl_map_inline:nn
{
@@ -2185,7 +2250,7 @@
}
\xeCJK_UL_subclass_patch_tl
}
-\AtBeginDocument
+\xeCJK_AfterPreamble:n
{
\cs_if_exist:NT \UL@hook
{
@@ -2196,7 +2261,7 @@
\cs_set_nopar:Npn \CJKsymbol #1
{
{ \xeCJK_select_font: \xeCJK_UL_CJKsymbol {#1} }
- \xeCJK_CJK_kern: \xeCJK_ignorespaces:
+ \xeCJK_make_node:n { CJK } \xeCJK_ignorespaces:
}
\cs_set_nopar:Npn \CJKpunctsymbol #1
{ { \xeCJK_select_font: \xeCJK_UL_CJKpunctsymbol {#1} } }
@@ -2214,7 +2279,7 @@
\tl_set:Nn \CJK@UnicodeEnc { UTF8 }
\cs_set_nopar:Npn \CJKaddEncHook #1#2 { \cs_set_nopar:cpn { xeCJK_enc_#1 } {#2} }
\cs_set_nopar:Npn \Unicode #1#2
- { \tex_char:D \int_eval:n { #1 * \c_two_hundred_fifty_six + #2 } }
+ { \tex_char:D \int_eval:n { (#1) * \c_two_hundred_fifty_six + (#2) } }
\RequirePackage { CJKnumb }
\use:c { xeCJK_enc_\CJK@UnicodeEnc }
\tl_set:Nn \CJK@tenthousand { 万 }