summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-05-15 21:47:05 +0000
committerKarl Berry <karl@freefriends.org>2015-05-15 21:47:05 +0000
commitff006c2d366e4f0f3503a131959ab1ae04ea5e5f (patch)
tree5bd1fb5973b570c58af7743d199882d28b2a17fd /Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
parentda5eaf8777934443b5a33ff8ed1d8c195c1e3034 (diff)
xecjk (15may15)
git-svn-id: svn://tug.org/texlive/trunk@37409 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty')
-rw-r--r--Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty182
1 files changed, 112 insertions, 70 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
index 95567ec2e8f..565ad48c4e2 100644
--- a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
+++ b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
@@ -6,8 +6,6 @@
%%
%% xeCJK.dtx (with options: `package')
%%
-%% $Id: xeCJK.dtx 750 2014-12-26 08:13:35Z sobenlee@gmail.com $
-%% $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
%% -----------------------------------------------------------------
%% Author:
%% Wenchang Sun <sunwch@nankai.edu.cn>
@@ -15,9 +13,9 @@
%% Leo Liu <leoliu.pku@gmail.com>
%% Qing Lee <sobenlee@gmail.com>
%%
-%% Copyright (C) 2007--2014 Wenchang Sun
-%% (C) 2009--2014 Leo Liu
-%% (C) 2012--2014 Qing Lee
+%% Copyright (C) 2007--2015 Wenchang Sun
+%% (C) 2009--2015 Leo Liu
+%% (C) 2012--2015 Qing Lee
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -33,11 +31,11 @@
%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\GetIdInfo$Id: xeCJK.dtx 750 2014-12-26 08:13:35Z sobenlee@gmail.com $
+\GetIdInfo$Id: xeCJK.dtx 7321d12 2015-05-15 23:07:58 +0800 Qing Lee <sobenlee@gmail.com> $
{Typesetting CJK scripts with XeLaTeX}
\ProvidesExplPackage
{\ExplFileName}
- {\ExplFileDate}{3.3.0}{\ExplFileDescription}
+ {\ExplFileDate}{3.3.2}{\ExplFileDescription}
\msg_new:nnn { xeCJK } { Require-XeTeX }
{
The~xeCJK~package~requires~XeTeX~to~function.\\\\
@@ -328,25 +326,39 @@
\cs_new_nopar:Npn \xeCJK_token_value_class:N #1
{ \XeTeXcharclass \xeCJK_token_value_charcode:N #1 }
\cs_new_nopar:Npn \xeCJK_token_value_charcode:N #1
- { \exp_after:wN \__xeCJK_token_value_charcode:w \token_to_meaning:N #1 \q_stop }
-\fp_compare:nNnTF { \int_use:N \xetex_XeTeXversion:D \XeTeXrevision } > { 0.9998 }
- {
- \cs_new_nopar:Npn \__xeCJK_token_value_charcode:w #1 ~ #2 ~ #3#4 \q_stop
- {
- \int_eval:n
- {
- \tl_if_empty:nTF {#4}
- { `#3 }
- { ( `#3 - "D800 ) * "400 + ( `#4 - "DC00 ) + "10000 }
- }
- }
- \cs_new_eq:NN \xeCJK_xetex_mathcode:w \Umathcode
- }
- {
- \cs_new_nopar:Npn \__xeCJK_token_value_charcode:w #1 ~ #2 ~ #3#4 \q_stop
- { \int_eval:n { \tl_if_empty:nTF {#4} { `#3 } { "20000 } } }
- \cs_new_eq:NN \xeCJK_xetex_mathcode:w \XeTeXmathcode
- }
+ { \exp_after:wN \__xeCJK_get_charcode:w \token_to_meaning:N #1 \q_stop }
+\group_begin:
+ \cs_set:Npn \__xeCJK_tmp:w #1 ~ #2 ~ #3#4#5 \q_stop
+ {
+ \tl_if_empty:nTF { #4#5 }
+ {
+ \cs_new_nopar:Npn \__xeCJK_get_charcode:w ##1 ~ ##2 ~ ##3 \q_stop
+ { \int_eval:n { `##3 } }
+ \cs_new_eq:NN \xeCJK_xetex_mathcode:w \Umathcode
+ }
+ {
+ \tl_if_empty:nTF {#5}
+ {
+ \cs_new_nopar:Npn \__xeCJK_get_charcode:w ##1 ~ ##2 ~ ##3##4 \q_stop
+ {
+ \int_eval:n
+ {
+ \tl_if_empty:nTF { ##4 }
+ { `##3 }
+ { ( `##3 - "D800 ) * "400 + ( `##4 - "DC00 ) + "10000 }
+ }
+ }
+ \cs_new_eq:NN \xeCJK_xetex_mathcode:w \Umathcode
+ }
+ {
+ \cs_new_nopar:Npn \__xeCJK_get_charcode:w ##1 ~ ##2 ~ ##3##4 \q_stop
+ { \int_eval:n { \tl_if_empty:nTF { ##4 } { `##3 } { "20000 } } }
+ \cs_new_eq:NN \xeCJK_xetex_mathcode:w \XeTeXmathcode
+ }
+ }
+ }
+ \exp_after:wN \__xeCJK_tmp:w \token_to_meaning:N ^^^^^20000 { } \q_stop
+\group_end:
\prg_new_conditional:Npnn \xeCJK_if_CJK_class:N #1 { p , T , F , TF }
{
\if_cs_exist:w \__xeCJK_CJK_class_tl:n { \xeCJK_token_value_class:N #1 } \cs_end:
@@ -409,7 +421,7 @@
\xeCJK_new_class:n { HalfLeft }
\xeCJK_new_class:n { HalfRight }
\xeCJK_new_class:n { NormalSpace }
-\xeCJK_new_class:n { IVS }
+\xeCJK_new_class:n { CM }
\xeCJK_new_class:n { HangulJamo }
\clist_const:Nn \c__xeCJK_HalfLeft_chars_clist
{ "28 , "5B , "60 , "7B , "2329 }
@@ -497,8 +509,9 @@
"2B740 -> "2B81F ,
"2F800 -> "2FA1F
}
-\clist_const:Nn \c__xeCJK_IVS_chars_clist
+\clist_const:Nn \c__xeCJK_CM_chars_clist
{
+ "302A -> "302F ,
"3099 -> "309A ,
"FE00 -> "FE0F ,
"E0100 -> "E01EF
@@ -521,7 +534,7 @@
\tl_const:cn { \__xeCJK_CJK_class_tl:c { \__xeCJK_class_csname:n {#1} } } {#1}
}
\clist_map_function:nN
- { CJK , FullLeft , FullRight , IVS , HangulJamo } \__xeCJK_save_CJK_class:n
+ { CJK , FullLeft , FullRight , CM , HangulJamo } \__xeCJK_save_CJK_class:n
\cs_new_nopar:Npn \xeCJK_class_num:n #1 { \use:c { \__xeCJK_class_csname:n {#1} } }
\NewDocumentCommand \xeCJKDeclareCharClass { s > { \TrimSpaces } m m }
{
@@ -541,7 +554,7 @@
{ \xeCJK_class_num:n {#1} }
}
}
- \xeCJK_set_char_class:nnn { "3099 } { "309A } { \xeCJK_class_num:n { IVS } }
+ \xeCJK_set_char_class:nnn { "3099 } { "309A } { \xeCJK_class_num:n { CM } }
}
\NewDocumentCommand \__xeCJK_set_char_class_aux:Nnw
{ m > { \SplitArgument { 1 } { -> } } m } { #1 #2 }
@@ -598,7 +611,7 @@
{
\xeCJK_declare_char_class:nV { CJK } \c__xeCJK_CJK_chars_clist
\xeCJK_declare_char_class:nV { NormalSpace } \c__xeCJK_NormalSpace_chars_clist
- \xeCJK_declare_char_class:nV { IVS } \c__xeCJK_IVS_chars_clist
+ \xeCJK_declare_char_class:nV { CM } \c__xeCJK_CM_chars_clist
\xeCJK_declare_char_class:nV { HangulJamo } \c__xeCJK_HangulJamo_chars_clist
\xeCJKResetPunctClass
}
@@ -625,8 +638,13 @@
\cs_new_protected_nopar:Npn \xeCJK_copy_inter_class_toks:nnnn #1#2#3#4
{
\tl_set:Nx \l__xeCJK_tmp_tl { \xeCJK_get_inter_class_toks:nn {#3} {#4} }
- \tl_if_empty:NF \l__xeCJK_tmp_tl
- { \xeCJK_inter_class_toks:nnx {#1} {#2} { \exp_not:V \l__xeCJK_tmp_tl } }
+ \tl_if_empty:NTF \l__xeCJK_tmp_tl
+ {
+ \tl_set:Nx \l__xeCJK_tmp_tl { \xeCJK_get_inter_class_toks:nn {#1} {#2} }
+ \tl_if_empty:NF \l__xeCJK_tmp_tl
+ { \xeCJK_clear_inter_class_toks:nn {#1} {#2} }
+ }
+ { \xeCJK_inter_class_toks:nnx {#1} {#2} { \exp_not:o \l__xeCJK_tmp_tl } }
}
\cs_new_protected_nopar:Npn \xeCJK_replace_inter_class_toks:nnnn #1#2#3#4
{
@@ -634,7 +652,7 @@
\tl_if_empty:NF \l__xeCJK_tmp_tl
{
\tl_replace_all:Nnn \l__xeCJK_tmp_tl {#3} {#4}
- \xeCJK_inter_class_toks:nnx {#1} {#2} { \exp_not:V \l__xeCJK_tmp_tl }
+ \xeCJK_inter_class_toks:nnx {#1} {#2} { \exp_not:o \l__xeCJK_tmp_tl }
}
}
\cs_new_protected_nopar:Npn \xeCJK_clear_Boundary_and_CJK_toks:
@@ -653,12 +671,12 @@
{
\seq_map_inline:Nn \g__xeCJK_class_seq
{
- \str_if_eq:nnTF {#1} { IVS }
- { \xeCJK_copy_inter_class_toks:nnnn { IVS } {#1} { CJK } { CJK } }
+ \str_if_eq:nnTF {#1} { CM }
+ { \xeCJK_copy_inter_class_toks:nnnn { CM } {#1} { CJK } { CJK } }
{
- \xeCJK_copy_inter_class_toks:nnnn { IVS } {#1} { CJK } {#1}
+ \xeCJK_copy_inter_class_toks:nnnn { CM } {#1} { CJK } {#1}
\str_if_eq:nnF {#1} { CJK }
- { \xeCJK_copy_inter_class_toks:nnnn {#1} { IVS } {#1} { CJK } }
+ { \xeCJK_copy_inter_class_toks:nnnn {#1} { CM } {#1} { CJK } }
}
}
}
@@ -716,7 +734,7 @@
\bool_if:nTF
{
\xeCJK_if_last_node_p:n { CJK } ||
- \xeCJK_if_last_node_p:n { CJK-nobreak }
+ \xeCJK_if_last_node_p:n { CJK-widow }
}
{ \xeCJK_remove_node: \CJKecglue }
{
@@ -800,8 +818,8 @@
{ \xeCJK_if_last_node_p:n { CJK } || \xeCJK_if_last_node_p:n { CJK-space } }
{ \xeCJK_remove_node: \CJKglue }
{
- \xeCJK_if_last_node:nTF { CJK-nobreak }
- { \xeCJK_remove_node: \xeCJK_no_break: \CJKglue }
+ \xeCJK_if_last_node:nTF { CJK-widow }
+ { \xeCJK_remove_node: \xeCJK_widow_penalty: \CJKglue }
{
\bool_if:nTF
{
@@ -878,7 +896,7 @@
\xeCJK_declare_node:n { CJK-space }
\xeCJK_declare_node:n { default }
\xeCJK_declare_node:n { default-space }
-\xeCJK_declare_node:n { CJK-nobreak }
+\xeCJK_declare_node:n { CJK-widow }
\xeCJK_declare_node:n { normalspace }
\keys_define:nn { xeCJK / options }
{
@@ -1393,6 +1411,13 @@
CheckSingle .default:n = { true } ,
CJKchecksingle .meta:n = { CheckSingle = true }
}
+\keys_define:nn { xeCJK / options }
+ {
+ WidowPenalty .int_set:N = \l__xeCJK_widow_penalty_int ,
+ WidowPenalty .default:n = { \c_ten_thousand }
+ }
+\cs_new_protected_nopar:Npn \xeCJK_widow_penalty:
+ { \tex_penalty:D \l__xeCJK_widow_penalty_int }
\cs_new_protected_nopar:Npn \xeCJK_check_single:Nw #1
{
\peek_catcode:NTF \c_catcode_letter_token
@@ -1479,8 +1504,8 @@
{
\peek_catcode:NTF \c_math_toggle_token
{
- \xeCJK_no_break: \__xeCJK_check_single_save:N #1
- \xeCJK_make_node:n { CJK-nobreak } #2 #4
+ \xeCJK_widow_penalty: \__xeCJK_check_single_save:N #1
+ \xeCJK_make_node:n { CJK-widow } #2 #4
}
{ \__xeCJK_check_single_save:N #1 #2#3#4 }
}
@@ -1492,8 +1517,8 @@
{ \group_align_safe_end: \use_iii:nnn }
{ \xeCJK_check_single_env:nnNn }
{
- \xeCJK_no_break: \__xeCJK_check_single_save:N #1
- \xeCJK_make_node:n { CJK-nobreak } #2
+ \xeCJK_widow_penalty: \__xeCJK_check_single_save:N #1
+ \xeCJK_make_node:n { CJK-widow } #2#3
}
{ \__xeCJK_check_single_save:N #1 #2#3 }
}
@@ -3006,9 +3031,10 @@
\cs_new_protected_nopar:Npn \__xeCJK_load_fandol:
{
\setCJKmainfont
- [ BoldFont = FandolSong-Bold , ItalicFont = FandolKai ] { FandolSong-Regular }
- \setCJKsansfont [ BoldFont = FandolHei-Bold ] { FandolHei-Regular }
- \setCJKmonofont { FandolFang }
+ [ Extension = .otf , BoldFont = FandolSong-Bold , ItalicFont = FandolKai-Regular ]
+ { FandolSong-Regular }
+ \setCJKsansfont [ Extension = .otf , BoldFont = FandolHei-Bold ] { FandolHei-Regular }
+ \setCJKmonofont [ Extension = .otf ] { FandolFang-Regular }
}
\__xeCJK_at_end_preamble:n
{
@@ -3501,6 +3527,7 @@
PunctStyle = quanjiao ,
NewLineCS = { \par \[ } ,
EnvCS = { \begin \end } ,
+ WidowPenalty = \c_ten_thousand ,
NoBreakCS = { \footnote \footnotemark \nobreak } ,
KaiMingPunct = { ^^^^3002 ^^^^ff0e ^^^^ff1f ^^^^ff01 } ,
LongPunct = { ^^^^2014 ^^^^2015 ^^^^2500 ^^^^2025 ^^^^2026 } ,
@@ -3664,20 +3691,25 @@
The~current~meaning~of~`#1'~is:\\
\iow_indent:n {#2}
}
-\__xeCJK_math_robust:N \(
-\__xeCJK_math_robust:N \)
-\__xeCJK_math_robust:N \math
-\__xeCJK_math_robust:N \endmath
-\__xeCJK_math_robust:N \ensuremath
-\bool_if:nF
+\cs_if_eq:NNTF \( \math
+ {
+ \__xeCJK_math_robust:N \(
+ \cs_set_eq:NN \math \(
+ }
{
- \xeCJK_if_package_loaded_p:n { amsmath } ||
- \xeCJK_if_package_loaded_p:n { amsthm }
+ \__xeCJK_math_robust:N \(
+ \__xeCJK_math_robust:N \math
}
+\cs_if_eq:NNTF \) \endmath
{
- \__xeCJK_math_robust:N \[
- \__xeCJK_math_robust:N \]
+ \__xeCJK_math_robust:N \)
+ \cs_set_eq:NN \endmath \)
}
+ {
+ \__xeCJK_math_robust:N \)
+ \__xeCJK_math_robust:N \endmath
+ }
+\__xeCJK_math_robust:N \ensuremath
\UndeclareTextCommand \nobreakspace { \UTFencname }
\RenewDocumentCommand \nobreakspace { } { \leavevmode \nobreak \ }
\AtBeginUTFCommand { \bool_if:NT \l__xeCJK_CJK_group_bool { \scan_stop: } }
@@ -3764,12 +3796,14 @@
}
{ \@@italiccorr }
}
+\cs_new_eq:NN \g__xeCJK_xetex_allocator_int \xe@alloc@intercharclass
\__xeCJK_after_end_preamble:n
{
\int_compare:nNnF
- { \c_three + \seq_count:N \g__xeCJK_new_class_seq } = \xe@alloc@intercharclass
+ { \c_three + \seq_count:N \g__xeCJK_new_class_seq } =
+ { \g__xeCJK_xetex_allocator_int }
{
- \int_step_inline:nnnn \c_four \c_one \xe@alloc@intercharclass
+ \int_step_inline:nnnn \c_four \c_one \g__xeCJK_xetex_allocator_int
{
\seq_if_in:NnF \g__xeCJK_new_class_seq {#1}
{ \__xeCJK_set_others_toks:n {#1} }
@@ -3946,14 +3980,22 @@
{ \cs_new_eq:NN \Unicode \xeCJK_unicode_char:nn }
}
}
-\cs_new_protected_nopar:Npn \xeCJK_char_from_charcode:Nn #1#2
+\str_if_eq_x:nnTF
+ { \token_to_str:N \Ucharcat } { \token_to_meaning:N \Ucharcat }
{
- \group_begin:
- \char_set_lccode:nn { "4E00 } {#2}
- \tl_to_lowercase:n
+ \cs_new_protected_nopar:Npn \xeCJK_char_from_charcode:Nn #1#2
+ { \tl_const:Nx #1 { \Ucharcat \int_eval:n {#2} ~ \c_eleven } }
+ }
+ {
+ \cs_new_protected_nopar:Npn \xeCJK_char_from_charcode:Nn #1#2
{
- \group_end:
- \tl_const:Nn #1 { ^^^^4e00 }
+ \group_begin:
+ \char_set_lccode:nn { "4E00 } {#2}
+ \tex_lowercase:D
+ {
+ \group_end:
+ \tl_const:Nn #1 { ^^^^4e00 }
+ }
}
}
\cs_new_nopar:Npn \__xeCJK_calc_unicode:nn #1#2
@@ -3962,9 +4004,9 @@
{ \tex_char:D \etex_numexpr:D \__xeCJK_calc_unicode:nn {#1} {#2} \scan_stop: }
\bool_if:NT \g__xeCJK_config_bool
{
- \@pushfilename
+ \ExplSyntaxOff
\file_input:n { \g__xeCJK_config_name_tl .cfg }
- \@popfilename
+ \ExplSyntaxOn
}
%%
%% This package consists of the file xeCJK.dtx,
@@ -3988,7 +4030,7 @@
%% xeCJK-example-CJKfntef.tex,
%% xeCJK-example-punctstyle.tex,
%% xeCJK-example-verbatim.tex,
-%% xeCJK-example-IVS.tex,
+%% xeCJK-example-CM.tex,
%% xeCJK-example-listings.tex,
%% xunicode-symbols.tex,
%% xunicode-commands.tex,