From 81f3a7b776ea8fe83f4dbbe5ebf2d78648af9497 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 26 Jul 2013 23:10:53 +0000 Subject: xecjk (26jul13) git-svn-id: svn://tug.org/texlive/trunk@31290 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty | 395 +++++++++++++++++--------- 1 file changed, 253 insertions(+), 142 deletions(-) (limited to 'Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty') diff --git a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty index 86734bccd7d..629aaf9d8dd 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 465 2013-07-06 10:30:24Z sobenlee $ +%% $Id: xeCJK.dtx 477 2013-07-25 22:15:20Z sobenlee $ %% $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $ %% ----------------------------------------------------------------- %% Author: @@ -33,11 +33,11 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: xeCJK.dtx 465 2013-07-06 10:30:24Z sobenlee $ +\GetIdInfo$Id: xeCJK.dtx 477 2013-07-25 22:15:20Z sobenlee $ {Typesetting CJK scripts with XeLaTeX} \ProvidesExplPackage {\ExplFileName} - {\ExplFileDate}{3.2.4}{\ExplFileDescription} + {\ExplFileDate}{3.2.5}{\ExplFileDescription} \msg_new:nnn { xeCJK } { Require-XeTeX } { The~xeCJK~package~requires~XeTeX~to~function.\\\\ @@ -46,23 +46,33 @@ Loading~xeCJK~will~abort! } \xetex_if_engine:F { \msg_critical:nn { xeCJK } { Require-XeTeX } } +\prg_new_conditional:Npnn \xeCJK_if_package_loaded:n #1 { p , T , F , TF } + { + \tl_if_exist:cTF { ver@ #1 . \c__xeCJK_package_ext_tl } + { \prg_return_true: } { \prg_return_false: } + } +\tl_const:Nx \c__xeCJK_package_ext_tl { \@pkgextension } \msg_new:nnn { xeCJK } { incompatible-package } { The~`#1'~package~and~xeCJK~are~incompatible.\\\\ - Please ~ \str_if_eq:nnTF {#1} { CJKnumb } - { load~it~after~xeCJK. } { do~not~use~it. } + Please~do~not~use~it. } -\clist_map_inline:nn { CJKnumb , CJKulem , CJKvert , CJKpunct , CJKutf8 , CJK } +\msg_new:nnn { xeCJK } { after-package } { - \@ifpackageloaded {#1} + The~`#1'~package~and~xeCJK~are~incompatible.\\\\ + Please~load~it~after~xeCJK. + } +\clist_map_inline:nn { CJKfntef , CJKnumb } + { + \xeCJK_if_package_loaded:nT {#1} + { \msg_error:nnn { xeCJK } { after-package } {#1} } + } +\clist_map_inline:nn { CJKulem , CJKvert , CJKpunct , CJKutf8 , CJK } + { + \xeCJK_if_package_loaded:nTF {#1} { \msg_error:nnn { xeCJK } { incompatible-package } {#1} } - { } + { \tl_const:cn { ver@ #1 . \c__xeCJK_package_ext_tl } { 9999/99/99 } } } -\tl_gset:cn { ver@CJK.sty } { 9999/99/99 } -\tl_gset_eq:cc { ver@CJKutf8.sty } { ver@CJK.sty } -\tl_gset_eq:cc { ver@CJKvert.sty } { ver@CJK.sty } -\tl_gset_eq:cc { ver@CJKulem.sty } { ver@CJK.sty } -\tl_gset_eq:cc { ver@CJKpunct.sty } { ver@CJK.sty } \msg_new:nnn { xeCJK } { l3-too-old } { Support~package~`#1'~too~old. \\\\ @@ -84,22 +94,16 @@ \bool_new:N \l__xeCJK_tmp_bool \skip_new:N \l__xeCJK_tmp_skip \clist_new:N \l__xeCJK_tmp_clist -\cs_new_protected_nopar:Npn \__xeCJK_msg_new:nn { \msg_new:nnn { xeCJK } } -\cs_new_protected_nopar:Npn \__xeCJK_error:n { \msg_error:nn { xeCJK } } -\cs_new_protected_nopar:Npn \__xeCJK_error:nx { \msg_error:nnx { xeCJK } } -\cs_new_protected_nopar:Npn \__xeCJK_warning:n { \msg_warning:nn { xeCJK } } -\cs_new_protected_nopar:Npn \__xeCJK_warning:nx { \msg_warning:nnx { xeCJK } } -\cs_new_protected_nopar:Npn \__xeCJK_warning:nxx { \msg_warning:nnxx { xeCJK } } -\cs_new_protected_nopar:Npn \__xeCJK_info:nx { \msg_info:nnx { xeCJK } } -\cs_new_protected_nopar:Npn \__xeCJK_info:nxx { \msg_info:nnxx { xeCJK } } +\cs_new_protected_nopar:Npn \__xeCJK_msg_new:nn { \msg_new:nnn { xeCJK } } +\cs_new_protected_nopar:Npn \__xeCJK_error:n { \msg_error:nn { xeCJK } } +\cs_new_protected_nopar:Npn \__xeCJK_error:nx { \msg_error:nnx { xeCJK } } +\cs_new_protected_nopar:Npn \__xeCJK_warning:n { \msg_warning:nn { xeCJK } } +\cs_new_protected_nopar:Npn \__xeCJK_warning:nx { \msg_warning:nnx { xeCJK } } +\cs_new_protected_nopar:Npn \__xeCJK_warning:nxx { \msg_warning:nnxx { xeCJK } } +\cs_new_protected_nopar:Npn \__xeCJK_warning:nxxx { \msg_warning:nnxxx { xeCJK } } +\cs_new_protected_nopar:Npn \__xeCJK_info:nxx { \msg_info:nnxx { xeCJK } } \cs_new_protected_nopar:Npn \xeCJK_allow_break: { \tex_penalty:D \c_zero } \cs_new_protected_nopar:Npn \xeCJK_no_break: { \tex_penalty:D \c_ten_thousand } -\prg_new_conditional:Npnn \xeCJK_if_package_loaded:n #1 { p , T , F , TF } - { - \tl_if_exist:cTF { ver@ #1 . \c__xeCJK_package_ext_tl } - { \prg_return_true: } { \prg_return_false: } - } -\tl_const:Nx \c__xeCJK_package_ext_tl { \@pkgextension } \tl_new:N \g__xeCJK_at_end_preamble_hook_tl \tl_new:N \g__xeCJK_after_preamble_hook_tl \tl_new:N \g__xeCJK_after_end_preamble_hook_tl @@ -591,7 +595,12 @@ { \seq_map_function:NN \g__xeCJK_CJK_class_seq \__xeCJK_clear_Boundary_and_CJK_toks:n } \cs_new_protected_nopar:Npn \__xeCJK_clear_Boundary_and_CJK_toks:n #1 { \xeCJK_clear_inter_class_toks:nn { Boundary } {#1} } -\cs_new_eq:NN \xeCJK_class_group_begin: \c_group_begin_token +\cs_new_protected_nopar:Npn \xeCJK_class_group_begin: + { + \c_group_begin_token + \bool_set_true:N \l__xeCJK_CJK_group_bool + } +\bool_new:N \l__xeCJK_CJK_group_bool \cs_new_eq:NN \xeCJK_class_group_end: \c_group_end_token \AtEndOfPackage { @@ -618,11 +627,10 @@ } \xeCJK_inter_class_toks:nnn { CJK } {#1} { \xeCJK_class_group_end: } } -\clist_map_inline:nn { Default , HalfLeft , NormalSpace } +\clist_map_inline:nn { Default , HalfLeft } { \xeCJK_inter_class_toks:nnn { Boundary } {#1} { \xeCJK_Boundary_and_Default: } - \str_if_eq:nnF {#1} { NormalSpace } - { \xeCJK_app_inter_class_toks:nnn { CJK } {#1} { \CJKecglue } } + \xeCJK_app_inter_class_toks:nnn { CJK } {#1} { \CJKecglue } } \cs_new_protected_nopar:Npn \xeCJK_Boundary_and_Default: { @@ -654,7 +662,7 @@ } } } -\clist_map_inline:nn { Default , HalfRight , NormalSpace } +\clist_map_inline:nn { Default , HalfRight } { \xeCJK_inter_class_toks:nnn {#1} { Boundary } { @@ -667,8 +675,42 @@ { { \xeCJK_make_node:n { default } } } } } - \str_if_eq:nnF {#1} { NormalSpace } - { \xeCJK_pre_inter_class_toks:nnn {#1} { CJK } { \CJKecglue } } + \xeCJK_pre_inter_class_toks:nnn {#1} { CJK } { \CJKecglue } + } +\xeCJK_inter_class_toks:nnn { Boundary } { NormalSpace } + { \xeCJK_Boundary_and_NormalSp: } +\cs_new_protected_nopar:Npn \xeCJK_Boundary_and_NormalSp: + { + \bool_if:nTF + { + \l__xeCJK_xecglue_bool && + \int_compare_p:nNn \etex_lastnodetype:D = \c_eleven && + \skip_if_eq_p:nn \tex_lastskip:D \c_xeCJK_space_skip_tl + } + { + \tex_unskip:D + \bool_if:nTF + { + \xeCJK_if_last_node_p:n { CJK } || + \xeCJK_if_last_node_p:n { CJK-space } + } + { \xeCJK_remove_node: \CJKecglue } { ~ } + } + { + \xeCJK_if_last_node:nT { CJK-space } + { \xeCJK_remove_node: \xeCJK_space_or_xecglue: } + } + } +\xeCJK_inter_class_toks:nnn { NormalSpace } { Boundary } + { + \int_gset_eq:NN \g__xeCJK_spacefactor_int \tex_spacefactor:D + \peek_meaning_remove:NTF \tex_italiccorrection:D + { \tex_italiccorrection:D { \xeCJK_make_node:n { normalspace } } } + { + \token_if_space:NTF \l_peek_token + { { \xeCJK_make_node:n { default-space } } } + { { \xeCJK_make_node:n { normalspace } } } + } } \xeCJK_inter_class_toks:nnn { Boundary } { CJK } { @@ -751,6 +793,7 @@ \xeCJK_def_node:nn { default } { 13 sp } \xeCJK_def_node:nn { default-space } { 14 sp } \xeCJK_def_node:nn { CJK-nobreak } { 15 sp } +\xeCJK_def_node:nn { normalspace } { 16 sp } \keys_define:nn { xeCJK / options } { CJKglue .code:n = @@ -947,15 +990,40 @@ { \int_case:nnn { \etex_lastnodetype:D } { - { \c_one } { \__xeCJK_zero_glue: \use_none:n } + { \c_one } + { + \box_set_to_last:N \l__xeCJK_tmp_box + \bool_if:nTF + { + \int_compare_p:nNn \etex_lastnodetype:D = \c_minus_one && + \dim_compare_p:nNn { \box_wd:N \l__xeCJK_tmp_box } = \tex_parindent:D + } + { \box_use_clear:N \l__xeCJK_tmp_box \use_none:n } + { \box_use_clear:N \l__xeCJK_tmp_box \use:n } + } { \c_minus_one } { \use_none:n } { \c_eleven } { - \bool_if:nF + \bool_if:nTF { ! ( \skip_if_finite_p:n { \tex_lastskip:D } ) || \skip_if_eq_p:nn { \tex_lastskip:D } { 1 sp } } + { \use_none:n } + { + \skip_if_eq:nnTF { \tex_lastskip:D } { \labelsep } + { + \tex_unskip:D + \bool_if:nTF + { + \int_compare_p:nNn \etex_lastnodetype:D = \c_thirteen && + \int_compare_p:nNn \tex_lastpenalty:D = \c_zero + } + { \skip_horizontal:n { \labelsep } \use_none:n } + { \skip_horizontal:n { \labelsep } \use:n } + } + { \use:n } + } } { \c_thirteen } { @@ -1421,16 +1489,25 @@ { \__xeCJK_switch_font:nn {#2} {#1} } } } -\__xeCJK_msg_new:nn { XeTeX-too-old } - { - \token_to_str:N \XeTeXglyphbounds \ is~not~defined.\\ - CJK~punctuation~kerning~will~not~be~available.\\\\ - You~have~to~update~XeTeX~to~the~version~0.9995.0~or~later. - } \cs_if_exist:NF \XeTeXglyphbounds { + \__xeCJK_msg_new:nn { XeTeX-too-old } + { + \token_to_str:N \XeTeXglyphbounds \ is~not~defined.\\ + CJK~punctuation~kerning~will~not~be~available.\\\\ + You~have~to~update~XeTeX~to~the~version~0.9995.0~or~later. + } \__xeCJK_error:n { XeTeX-too-old } - \__xeCJK_after_end_preamble:n { \xeCJKsetup { PunctStyle = plain } } + \AtEndOfPackage + { + \keys_define:nn { xeCJK / options } + { + PunctStyle / unknown .code:n = + { \__xeCJK_error:nx { punct-style-unknown } { \l_keys_value_tl } } + } + \seq_gclear:N \g__xeCJK_punct_style_seq + \xeCJKsetup { PunctStyle = plain } + } } \NewDocumentCommand \xeCJKsetwidth { m m } { \tl_map_inline:xn {#1} { \tl_gset:cn { g__xeCJK_punct_width/##1/tl } {#2} } } @@ -1525,10 +1602,10 @@ { \tl_use:c { \__xeCJK_punct_dim_csname:nn {#1} {#2} } } \cs_new_nopar:Npn \__xeCJK_use_punct_dim:nnn #1#2#3 { \tl_use:c { \__xeCJK_punct_dim_csname:nnn {#1} {#2} {#3} } } -\cs_new_protected_nopar:Npn \__xeCJK_gset_punct_dim:nnx #1#2#3 - { \tl_const:cx { \__xeCJK_punct_dim_csname:nn {#1} {#2} } {#3} } -\cs_new_protected_nopar:Npn \__xeCJK_gset_punct_dim:nnnx #1#2#3#4 - { \tl_const:cx { \__xeCJK_punct_dim_csname:nnn {#1} {#2} {#3} } {#4} } +\cs_new_protected_nopar:Npn \__xeCJK_save_punct_dim:nnn #1#2#3 + { \tl_const:cx { \__xeCJK_punct_dim_csname:nn {#1} {#2} } { \dim_eval:n {#3} } } +\cs_new_protected_nopar:Npn \__xeCJK_save_punct_dim:nnnn #1#2#3#4 + { \tl_const:cx { \__xeCJK_punct_dim_csname:nnn {#1} {#2} {#3} } { \dim_eval:n {#4} } } \DeclareObjectType { xeCJK / punctuation } { \c_three } \DeclareTemplateInterface { xeCJK / punctuation } { basic } { \c_three } { @@ -1629,7 +1706,7 @@ } } } - \__xeCJK_gset_punct_dim:nnnx { glue } {#1} {#2} + \__xeCJK_save_punct_dim:nnnn { glue } {#1} {#2} { \dim_max:nn { \l__xeCJK_margin_minimum_dim } @@ -1709,24 +1786,21 @@ } \cs_new_protected_nopar:Npn \xeCJK_punct_kerning_process:NN #1#2 { - \__xeCJK_gset_punct_dim:nnnx { kern } {#1} {#2} + \__xeCJK_save_punct_dim:nnnn { kern } {#1} {#2} { - \dim_eval:n + \bool_if:nTF { - \bool_if:nTF - { - \l__xeCJK_enabled_global_setting_bool && - \tl_if_exist_p:c { g__xeCJK_punct/kern/#1/#2/tl } - } - { \tl_use:c { g__xeCJK_punct/kern/#1/#2/tl } } - { - \bool_if:NTF \l__xeCJK_enabled_kerning_bool - { \__xeCJK_calc_kerning_margin:NN {#1} {#2} } - { \__xeCJK_original_kerning_margin:NN {#1} {#2} } - } - - ( \__xeCJK_use_punct_dim:nnn { bound } \c__xeCJK_right_tl {#1} ) - - ( \__xeCJK_use_punct_dim:nnn { bound } \c__xeCJK_left_tl {#2} ) + \l__xeCJK_enabled_global_setting_bool && + \tl_if_exist_p:c { g__xeCJK_punct/kern/#1/#2/tl } + } + { \tl_use:c { g__xeCJK_punct/kern/#1/#2/tl } } + { + \bool_if:NTF \l__xeCJK_enabled_kerning_bool + { \__xeCJK_calc_kerning_margin:NN {#1} {#2} } + { \__xeCJK_original_kerning_margin:NN {#1} {#2} } } + - ( \__xeCJK_use_punct_dim:nnn { bound } \c__xeCJK_right_tl {#1} ) + - ( \__xeCJK_use_punct_dim:nnn { bound } \c__xeCJK_left_tl {#2} ) } } \cs_new_nopar:Npn \__xeCJK_original_kerning_margin:NN #1#2 @@ -1829,14 +1903,14 @@ { \tl_if_eq:NNTF \l_xeCJK_punct_style_tl \c__xeCJK_punct_style_plain_tl { - \__xeCJK_gset_punct_dim:nnnx { glue } {#1} {#2} { \c_zero_dim } - \__xeCJK_gset_punct_dim:nnnx { bound } \c__xeCJK_left_tl {#2} { \c_zero_dim } - \__xeCJK_gset_punct_dim:nnnx { bound } \c__xeCJK_right_tl {#2} { \c_zero_dim } + \__xeCJK_save_punct_dim:nnnn { glue } {#1} {#2} { \c_zero_dim } + \__xeCJK_save_punct_dim:nnnn { bound } \c__xeCJK_left_tl {#2} { \c_zero_dim } + \__xeCJK_save_punct_dim:nnnn { bound } \c__xeCJK_right_tl {#2} { \c_zero_dim } } { { \xeCJK_select_font: \xeCJK_calc_punct_dimen:f {#2} } \__xeCJK_punct_if_long:NTF {#2} - { \__xeCJK_gset_punct_dim:nnnx { glue } {#1} {#2} { \c_zero_dim } } + { \__xeCJK_save_punct_dim:nnnn { glue } {#1} {#2} { \c_zero_dim } } { \UseInstance { xeCJK / punctuation } { \l_xeCJK_punct_style_tl } {#1} {#2} { } @@ -1846,22 +1920,22 @@ } \cs_new_protected_nopar:Npn \xeCJK_calc_punct_dimen:N #1 { - \__xeCJK_gset_punct_dim:nnnx { bound } \c__xeCJK_left_tl {#1} + \__xeCJK_save_punct_dim:nnnn { bound } \c__xeCJK_left_tl {#1} { \xeCJK_glyph_bounds:NN \c_one {#1} } - \__xeCJK_gset_punct_dim:nnnx { bound } \c__xeCJK_right_tl {#1} + \__xeCJK_save_punct_dim:nnnn { bound } \c__xeCJK_right_tl {#1} { \xeCJK_glyph_bounds:NN \c_three {#1} } \dim_set:Nn \l__xeCJK_tmp_dim { ( \__xeCJK_use_punct_dim:nnn { bound } \c__xeCJK_left_tl {#1} ) + ( \__xeCJK_use_punct_dim:nnn { bound } \c__xeCJK_right_tl {#1} ) } - \__xeCJK_gset_punct_dim:nnx { width } {#1} - { \dim_use:N \etex_fontcharwd:D \tex_font:D \xeCJK_token_value_charcode:N #1 } - \__xeCJK_gset_punct_dim:nnx { dimen } {#1} - { \dim_eval:n { \__xeCJK_use_punct_dim:nn { width } {#1} - \l__xeCJK_tmp_dim } } + \__xeCJK_save_punct_dim:nnn { width } {#1} + { \etex_fontcharwd:D \tex_font:D \xeCJK_token_value_charcode:N #1 } + \__xeCJK_save_punct_dim:nnn { dimen } {#1} + { \__xeCJK_use_punct_dim:nn { width } {#1} - \l__xeCJK_tmp_dim } \__xeCJK_punct_if_long:NT {#1} { - \__xeCJK_gset_punct_dim:nnnx { kern } {#1} {#1} + \__xeCJK_save_punct_dim:nnnn { kern } {#1} {#1} { \bool_if:nTF { @@ -1869,7 +1943,7 @@ \str_if_eq_p:nn {#1} { ^^^^2026 } } { \c_zero_dim } - { - \dim_use:N \l__xeCJK_tmp_dim } + { - \l__xeCJK_tmp_dim } } } } @@ -1884,7 +1958,7 @@ \tl_if_exist:cF { \__xeCJK_punct_dim_csname:nnn { kern } {#1} {#2} } { \tl_if_eq:NNTF \l_xeCJK_punct_style_tl \c__xeCJK_punct_style_plain_tl - { \__xeCJK_gset_punct_dim:nnnx { kern } {#1} {#2} { \c_zero_dim } } + { \__xeCJK_save_punct_dim:nnnn { kern } {#1} {#2} { \c_zero_dim } } { \UseInstance { xeCJK / punctuation } { \l_xeCJK_punct_style_tl } { } {#1} {#2} @@ -1921,8 +1995,8 @@ { \IfInstanceExistTF { xeCJK / punctuation } {#1} { \__xeCJK_warning:nx { punct-style-already-defined } {#1} } - { \seq_gput_right:Nn \g__xeCJK_punct_style_seq {#1} } - \DeclareInstance { xeCJK / punctuation } {#1} { basic } {#2} + { \seq_gput_right:Nx \g__xeCJK_punct_style_seq {#1} } + \exp_args:Nnx \DeclareInstance { xeCJK / punctuation } {#1} { basic } {#2} } \seq_new:N \g__xeCJK_punct_style_seq \__xeCJK_msg_new:nn { punct-style-already-defined } @@ -1934,7 +2008,7 @@ \NewDocumentCommand \xeCJKEditPunctStyle { > { \TrimSpaces } m m } { \IfInstanceExistTF { xeCJK / punctuation } {#1} - { \EditInstance { xeCJK / punctuation } {#1} {#2} } + { \exp_args:Nnx \EditInstance { xeCJK / punctuation } {#1} {#2} } { \__xeCJK_error:nx { punct-style-unknown } {#1} } } \@onlypreamble \xeCJKEditPunctStyle @@ -2005,11 +2079,9 @@ { \str_if_eq_x:nnTF { \CJKfamilydefault } { \l_xeCJK_family_tl } { - \use:x - { - \msg_warning:nnnnn { xeCJK } { missing-glyph } - { \l__xeCJK_fallback_family_tl } {#1} { \int_to_hexadecimal:n { `#1 } } - } + \__xeCJK_warning:nxxx { missing-glyph } + { \l__xeCJK_fallback_family_tl } {#1} + { \int_to_hexadecimal:n { `#1 } } \__xeCJK_fallback_save_CJKsymbol:N {#1} } { @@ -2506,7 +2578,7 @@ \prop_gput:Nxx \g__xeCJK_family_name_prop {#1} {#2} \cs_gset_protected_nopar:cpx { \__xeCJK_family_nfss_csname:n {#1} } { - \tl_set:Nx \exp_not:N \f@encoding { \c__xeCJK_encoding_tl } + \exp_not:N \fontencoding { \c__xeCJK_encoding_tl } \tl_set:Nx \exp_not:N \f@family {#2} \exp_not:N \selectfont } @@ -2842,35 +2914,36 @@ \int_incr:N \l__xeCJK_begin_int } } +\int_new:N \l__xeCJK_verb_case_int \keys_define:nn { xeCJK / options } { - Verb .choice: , - Verb / true .code:n = { \int_set_eq:NN \l__xeCJK_verb_case_int \c_zero } , - Verb / env .code:n = { \int_set_eq:NN \l__xeCJK_verb_case_int \c_one } , - Verb / env+ .code:n = { \int_set_eq:NN \l__xeCJK_verb_case_int \c_two } , - Verb / false .code:n = { \int_set_eq:NN \l__xeCJK_verb_case_int \c_three } , - Verb .default:n = { env } + Verb .choices:nn = + { true , env , env+ , false } + { \int_set_eq:NN \l__xeCJK_verb_case_int \l_keys_choice_int } , + Verb .default:n = { env } } -\int_new:N \l__xeCJK_verb_case_int -\__xeCJK_after_preamble:n +\cs_new_protected_nopar:Npn \__xeCJK_verb_font_hook: { - \tl_put_right:Nn \verbatim@font - { - \if_case:w \l__xeCJK_verb_case_int + \if_case:w \l__xeCJK_verb_case_int + \or: + \cs_set_eq:NN \CJKglue \__xeCJK_zero_glue: + \cs_set_eq:NN \CJKecglue \__xeCJK_zero_glue: + \or: + \int_compare:nNnTF \etex_currentgrouptype:D = \c_fourteen + { \xeCJKVerbAddon } + { \cs_set_eq:NN \CJKglue \__xeCJK_zero_glue: \cs_set_eq:NN \CJKecglue \__xeCJK_zero_glue: - \or: - \int_compare:nNnTF \etex_currentgrouptype:D = \c_fourteen - { \xeCJKVerbAddon } - { - \cs_set_eq:NN \CJKglue \__xeCJK_zero_glue: - \cs_set_eq:NN \CJKecglue \__xeCJK_zero_glue: - } - \or: - \int_compare:nNnT \etex_currentgrouptype:D = \c_fourteen - { \xeCJKVerbAddon } - \fi: - } + } + \or: + \int_compare:nNnT \etex_currentgrouptype:D = \c_fourteen + { \xeCJKVerbAddon } + \fi: + } +\__xeCJK_after_preamble:n + { + \cs_set_protected_nopar:Npx \verbatim@font + { \exp_not:o { \verbatim@font } \__xeCJK_verb_font_hook: } } \NewDocumentCommand \xeCJKVerbAddon { } { @@ -2906,7 +2979,6 @@ \__xeCJK_reset_char_class:n { HalfLeft } \__xeCJK_reset_char_class:n { HalfLeft } \__xeCJK_reset_char_class:n { NormalSpace } - \skip_set:Nn \tex_rightskip:D { \skip_use:N \tex_rightskip:D } \exp_not:c { bool_set_ \bool_if:NTF \l__xeCJK_xecglue_bool { true } { false } :N } \l__xeCJK_xecglue_bool @@ -2926,15 +2998,23 @@ \tex_the:D \tex_output:D } \xeCJKsetup { xCJKecglue = false } - \cs_set_protected_nopar:Npn \CJKglue - { \skip_horizontal:N \l__xeCJK_verb_exspace_skip } - \cs_set_protected_nopar:Npn \CJKecglue - { \skip_horizontal:n { 0.5 \l__xeCJK_verb_exspace_skip } } - \cs_set_eq:NN \xeCJK_check_for_glue: \CJKecglue - \cs_set_eq:NN \xeCJK_ignore_spaces:w \CJKecglue - \skip_set:Nn \tex_rightskip:D { \c_zero_dim plus 1 fil } } + \skip_if_eq:nnTF { \l__xeCJK_verb_exspace_skip } { \c_zero_skip } + { + \xeCJK_cs_clear:N \CJKglue + \xeCJK_cs_clear:N \CJKecglue + } + { + \cs_set_eq:NN \CJKglue \__xeCJK_verb_ccglue: + \cs_set_eq:NN \CJKecglue \__xeCJK_verb_ecglue: + } + \cs_set_eq:NN \xeCJK_check_for_glue: \CJKecglue + \cs_set_eq:NN \xeCJK_ignore_spaces:w \CJKecglue } +\cs_new_protected_nopar:Npn \__xeCJK_verb_ccglue: + { \xeCJK_no_break: \skip_horizontal:N \l__xeCJK_verb_exspace_skip } +\cs_new_protected_nopar:Npn \__xeCJK_verb_ecglue: + { \xeCJK_no_break: \skip_horizontal:n { 0.5 \l__xeCJK_verb_exspace_skip } } \cs_new_protected_nopar:Npn \__xeCJK_reset_char_class:n #1 { \int_set:Nn \l__xeCJK_tmp_int { \xeCJK_class_num:n {#1} } @@ -2989,8 +3069,8 @@ { \fp_set:Nn \l__xeCJK_scale_factor_fp { #1 / #2 } \__xeCJK_warning:nxx { scale-factor } - { \fp_eval:n { round - ( \l__xeCJK_scale_factor_fp , 2 ) } } - { \fp_eval:n { round + ( #2 / #1 , 2 ) } } + { \fp_eval:n { round - ( \l__xeCJK_scale_factor_fp , 4 ) } } + { \fp_eval:n { round + ( #2 / #1 , 4 ) } } \xeCJK_add_font_features:Nnx \c_true_bool { } { Scale = { \fp_use:N \l__xeCJK_scale_factor_fp } } \prop_gput:NVV \g__xeCJK_scale_family_prop @@ -3007,17 +3087,29 @@ } \fp_new:N \l__xeCJK_scale_factor_fp \prop_new:N \g__xeCJK_scale_family_prop +\cs_new_protected_nopar:Npn \xeCJK_visible_space: + { + \bool_if:NT \l__xeCJK_CJK_group_bool { \scan_stop: } + \xeCJK_glyph_if_exist:NTF { ^^^^2423 } + { ^^^^2423 } + { + \int_compare:nNnTF { \XeTeXfonttype \tex_font:D } = \c_zero + { + \str_if_eq_x:nnTF { \f@family } { \ttdefault } + { \c_catcode_other_space_tl } + { \textvisiblespace } + } + { \xeCJK_visible_space_fallback: } + } + } +\AtEndOfPackage + { \cs_gset_eq:NN \fontspec_visible_space: \xeCJK_visible_space: } \cs_new_protected_nopar:Npn \xeCJK_visible_space_fallback: { { \cs_if_exist_use:cF { xeCJK/space/\curr@fontshape/\f@size } { \xeCJK_set_visible_space_font: } - \textvisiblespace + ^^^^2423 } } -\AtEndOfPackage - { - \tl_put_left:Nn \fontspec_visible_space: { \scan_stop: } - \cs_gset_eq:NN \fontspec_visible_space_fallback: \xeCJK_visible_space_fallback: - } \cs_new_protected_nopar:Npn \xeCJK_set_visible_space_font: { \tl_set:Nx \l__xeCJK_current_coor_tl { xeCJK/space/\curr@fontshape/\f@size } @@ -3027,7 +3119,7 @@ } \cs_new_protected_nopar:Npn \__xeCJK_set_visible_space_size:n #1 { - \tl_set:Nx \f@encoding { \g_fontspec_encoding_tl } + \fontencoding { \g_fontspec_encoding_tl } \tl_set:Nx \f@family { lmtt } \selectfont \dim_compare:nNnF {#1} = { \tex_fontdimen:D \c_two \tex_font:D } @@ -3128,6 +3220,7 @@ \defaultCJKfontfeatures { Script = CJK } \ProcessKeysOptions { xeCJK / options } \RequirePackage { fontspec } [ 2011/09/13 ] +\RequirePackage { xunicode-addon } \tl_const:Nx \c__xeCJK_encoding_tl { \g_fontspec_encoding_tl } \bool_if:NT \g__xeCJK_indent_bool { \RequirePackage { indentfirst } } \keys_define:nn { xeCJK / options } @@ -3147,7 +3240,7 @@ \tl_if_exist:NF \CJKttdefault { \tl_gset:Nn \CJKttdefault { tt } } \tl_new:N \l__xeCJK_family_default_init_tl \cs_new_eq:NN \__xeCJK_family_default_wrap:n \use:n -\tl_gset:Nx \l__xeCJK_family_default_init_tl +\tl_set:Nx \l__xeCJK_family_default_init_tl { \exp_not:N \__xeCJK_family_default_wrap:n { @@ -3185,25 +3278,34 @@ \xeCJK_set_char_class:nnn {#1} {#2} {#3} \xeCJKResetPunctClass } -\cs_if_exist:cT { ? - \token_to_str:N \nobreakspace } +\cs_new_protected_nopar:Npn \__xeCJK_math_robust:N #1 + { \exp_args:NNc \__xeCJK_math_robust:NN #1 { \cs_to_str:N #1 ~ } } +\cs_new_protected_nopar:Npn \__xeCJK_math_robust:NN #1#2 { - \exp_args:NNv \ProvideTextCommandDefault \nobreakspace - { ? - \token_to_str:N \nobreakspace } + \bool_if:nT + { + \str_if_eq_x_p:nn + { \token_get_replacement_spec:N #1 } + { \exp_not:n { \x@protect #1 \protect #2 } } && + \exp_args:Nf \tl_if_empty_p:n { \token_get_arg_spec:N #2 } && + \exp_args:No \tl_if_head_eq_meaning_p:nN {#2} \scan_stop: + } + { \cs_gset_protected_nopar:Npx #1 { \scan_align_safe_stop: \tl_tail:N #2 } } } -\cs_new_nopar:Npn \xeCJK@text@composite #1#2#3 \@text@composite +\__xeCJK_math_robust:N \( +\__xeCJK_math_robust:N \) +\bool_if:nF { - \str_if_eq:nnTF {#3} { \@empty } - { \orig@text@composite #1#2#3 \@text@composite } - { \__xeCJK_text_composite:Nnw #1#2#3 } + \xeCJK_if_package_loaded_p:n { amsmath } || + \xeCJK_if_package_loaded_p:n { amsthm } } -\cs_new_nopar:Npn \__xeCJK_text_composite:Nnw #1#2 \@empty { - \tl_if_empty:nTF {#2} - { \orig@text@composite #1 \@empty \@text@composite } - { \cs_if_exist_use:cF { \token_to_str:N #1 - \token_to_str:N #2 } } + \__xeCJK_math_robust:N \[ + \__xeCJK_math_robust:N \] } -\cs_new_eq:NN \orig@text@composite \@text@composite -\cs_set_eq:NN \@text@composite \xeCJK@text@composite +\UndeclareTextCommand \nobreakspace { \UTFencname } +\RenewDocumentCommand \nobreakspace { } { \leavevmode \nobreak \ } +\AtBeginUTFCommand { \bool_if:NT \l__xeCJK_CJK_group_bool { \scan_stop: } } \__xeCJK_msg_new:nn { conflict-package } { The~`#1'~package~is~too~old. \\ @@ -3338,7 +3440,7 @@ \textquoteleft \textquoteright \textquotedblleft \textquotedblright } { - \cs_gset_nopar:Npx #1 + \cs_gset_protected_nopar:Npx #1 { \__xeCJK_group_begin: \makexeCJKinactive \exp_not:o {#1} \__xeCJK_group_end: } } \tl_put_left:Nn \tipaencoding { \makexeCJKinactive } @@ -3444,13 +3546,18 @@ { \g__xeCJK_config_name_tl } [ ] [ ] { \c__xeCJK_config_ext_tl } } %% -%% This package consists of the file xeCJK.dtx +%% This package consists of the file xeCJK.dtx, +%% full-stop.map, +%% fullwidth-stop.map, +%% han-simp.map, +%% han-trad.map, %% and the derived files xeCJK.pdf, %% xeCJK.sty, %% xeCJK.cfg, %% xeCJK.ins, %% xeCJKfntef.sty, %% xeCJK-listings.sty, +%% xunicode-addon.sty, %% xeCJK-example-autofake.tex, %% xeCJK-example-fallback.tex, %% xeCJK-example-subCJKblock.tex, @@ -3460,7 +3567,11 @@ %% xeCJK-example-punctstyle.tex, %% xeCJK-example-verbatim.tex, %% xeCJK-example-IVS.tex, -%% xeCJK-example-listings.tex, and +%% xeCJK-example-listings.tex, +%% full-stop.tec, +%% fullwidth-stop.tec, +%% han-simp.tec, +%% han-trad.tec, and %% README.txt. %% %% End of file `xeCJK.sty'. -- cgit v1.2.3