summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-05-14 22:12:26 +0000
committerKarl Berry <karl@freefriends.org>2016-05-14 22:12:26 +0000
commit018978bb05cad50aacc24f4aeda53453db5a07fe (patch)
tree6b5767033ccf07d23626f6d8a92af1a7f4572fe8 /Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
parenta250d691586dcb9dc789cd1c6b3a129ac4afc424 (diff)
xecjk (14may16)
git-svn-id: svn://tug.org/texlive/trunk@41129 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.sty717
1 files changed, 449 insertions, 268 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
index 18f0c54e2aa..ba88db7d131 100644
--- a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
+++ b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
@@ -6,36 +6,33 @@
%%
%% xeCJK.dtx (with options: `package')
%%
-%% -----------------------------------------------------------------
-%% Author:
-%% Wenchang Sun <sunwch@nankai.edu.cn>
-%% Current Maintainers:
-%% Leo Liu <leoliu.pku@gmail.com>
-%% Qing Lee <sobenlee@gmail.com>
+%% Copyright (C) 2007--2010 by Wenchang Sun <sunwch@nankai.edu.cn>
+%% Copyright (C) 2009--2016 by Leo Liu <leoliu.pku@gmail.com>
+%% Copyright (C) 2012--2016 by Qing Lee <sobenlee@gmail.com>
+%% ----------------------------------------------------------------------
%%
-%% Copyright (C) 2007--2010 Wenchang Sun
-%% (C) 2009--2016 Leo Liu
-%% (C) 2012--2016 Qing Lee
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3c of this license or (at your option) any later
+%% version. This version of this license is in
+%% http://www.latex-project.org/lppl/lppl-1-3c.txt
+%% and the latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2005/12/01 or later.
%%
-%% This file may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either version 1.3
-%% of this license or (at your option) any later version.
-%% The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of LaTeX
-%% version 2005/12/01 or later.
+%% This work has the LPPL maintenance status `maintained'.
%%
-%% This work has the LPPL maintenance status "maintained".
-%% The Current Maintainer of this work are Leo Liu and Qing Lee.
-%% -----------------------------------------------------------------
+%% The Current Maintainers of this work are Leo Liu and Qing Lee.
+%%
+%% ----------------------------------------------------------------------
%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\GetIdInfo$Id: xeCJK.dtx 8518191 2016-02-10 16:25:31 +0800 Qing Lee <sobenlee@gmail.com> $
+\GetIdInfo$Id: xeCJK.dtx 463fb57 2016-05-14 12:24:41 +0800 Qing Lee <sobenlee@gmail.com> $
{Typesetting CJK scripts with XeLaTeX}
-\ProvidesExplPackage
- {\ExplFileName}
- {\ExplFileDate}{3.3.4}{\ExplFileDescription}
+\ProvidesExplPackage{\ExplFileName}
+ {\ExplFileDate}{3.4.0}{\ExplFileDescription}
\msg_new:nnn { xeCJK } { Require-XeTeX }
{
The~xeCJK~package~requires~XeTeX~to~function.\\\\
@@ -550,15 +547,19 @@
\cs_new_nopar:Npn \xeCJK_class_num:n #1 { \use:c { \__xeCJK_class_csname:n {#1} } }
\NewDocumentCommand \xeCJKDeclareCharClass { s > { \TrimSpaces } m m }
{
- \xeCJK_declare_char_class:nx {#2} {#3}
+ \xeCJK_declare_char_class:nn {#2} {#3}
\IfBooleanT {#1} { \xeCJKResetPunctClass }
}
\cs_new_protected_nopar:Npn \xeCJK_declare_char_class:nn #1#2
{
- \clist_set:Nn \l__xeCJK_tmp_clist {#2}
+ \clist_set:Nx \l__xeCJK_tmp_clist {#2}
+ \xeCJK_declare_char_class:nN {#1} \l__xeCJK_tmp_clist
+ }
+\cs_new_protected_nopar:Npn \xeCJK_declare_char_class:nN #1#2
+ {
\clist_gconcat:ccN
- { g__xeCJK_#1_range_clist } { g__xeCJK_#1_range_clist } \l__xeCJK_tmp_clist
- \clist_map_inline:Nn \l__xeCJK_tmp_clist
+ { g__xeCJK_#1_range_clist } { g__xeCJK_#1_range_clist } #2
+ \clist_map_inline:Nn #2
{
\str_if_eq:nnF {##1} { -> }
{
@@ -571,7 +572,7 @@
\NewDocumentCommand \__xeCJK_set_char_class_aux:Nnw
{ m > { \SplitArgument { 1 } { -> } } m } { #1 #2 }
\cs_generate_variant:Nn \clist_gconcat:NNN { cc }
-\cs_generate_variant:Nn \xeCJK_declare_char_class:nn { nx , nV }
+\cs_generate_variant:Nn \xeCJK_declare_char_class:nn { nc }
\cs_new_protected_nopar:Npn \__xeCJK_check_num_range:nnNN #1#2#3#4
{
\bool_if:nTF { \xeCJK_if_blank_x_p:n {#1} || \xeCJK_if_blank_x_p:n {#2} }
@@ -617,17 +618,25 @@
}
\NewDocumentCommand \xeCJKResetPunctClass { }
{
- \xeCJK_declare_char_class:nV { HalfLeft } \c__xeCJK_HalfLeft_chars_clist
- \xeCJK_declare_char_class:nV { HalfRight } \c__xeCJK_HalfRight_chars_clist
- \xeCJK_declare_char_class:nV { FullLeft } \c__xeCJK_FullLeft_chars_clist
- \xeCJK_declare_char_class:nV { FullRight } \c__xeCJK_FullRight_chars_clist
+ \clist_gclear:N \g__xeCJK_HalfLeft_range_clist
+ \clist_gclear:N \g__xeCJK_HalfRight_range_clist
+ \clist_gclear:N \g__xeCJK_FullLeft_range_clist
+ \clist_gclear:N \g__xeCJK_FullRight_range_clist
+ \xeCJK_declare_char_class:nN { HalfLeft } \c__xeCJK_HalfLeft_chars_clist
+ \xeCJK_declare_char_class:nN { HalfRight } \c__xeCJK_HalfRight_chars_clist
+ \xeCJK_declare_char_class:nN { FullLeft } \c__xeCJK_FullLeft_chars_clist
+ \xeCJK_declare_char_class:nN { FullRight } \c__xeCJK_FullRight_chars_clist
}
\NewDocumentCommand \xeCJKResetCharClass { }
{
- \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 { CM } \c__xeCJK_CM_chars_clist
- \xeCJK_declare_char_class:nV { HangulJamo } \c__xeCJK_HangulJamo_chars_clist
+ \clist_gclear:N \g__xeCJK_CJK_range_clist
+ \clist_gclear:N \g__xeCJK_NormalSpace_range_clist
+ \clist_gclear:N \g__xeCJK_CM_range_clist
+ \clist_gclear:N \g__xeCJK_HangulJamo_range_clist
+ \xeCJK_declare_char_class:nN { CJK } \c__xeCJK_CJK_chars_clist
+ \xeCJK_declare_char_class:nN { NormalSpace } \c__xeCJK_NormalSpace_chars_clist
+ \xeCJK_declare_char_class:nN { CM } \c__xeCJK_CM_chars_clist
+ \xeCJK_declare_char_class:nN { HangulJamo } \c__xeCJK_HangulJamo_chars_clist
\xeCJKResetPunctClass
}
\xeCJKResetCharClass
@@ -727,21 +736,8 @@
{ \xeCJK_check_for_ecglue: }
\cs_new_protected_nopar:Npn \__xeCJK_check_for_xecglue:
{
- \bool_if:nTF
- {
- \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_space_glue: }
- }
+ \int_compare:nNnTF \etex_lastnodetype:D = \c_eleven
+ { \__xeCJK_replace_space: }
{ \__xeCJK_check_for_ecglue: }
}
\cs_new_protected_nopar:Npn \__xeCJK_check_for_ecglue:
@@ -758,6 +754,23 @@
}
}
\cs_new_eq:NN \xeCJK_check_for_ecglue: \__xeCJK_check_for_ecglue:
+\cs_new_protected_nopar:Npn \__xeCJK_replace_space:
+ {
+ \skip_set_eq:NN \l__xeCJK_last_skip \tex_lastskip:D
+ \tex_unskip:D
+ \xeCJK_if_last_node:nTF { CJK-space }
+ { \xeCJK_remove_node: \CJKecglue }
+ {
+ \xeCJK_if_last_node:nTF { CJK }
+ {
+ \skip_if_eq:nnTF { \l__xeCJK_last_skip } { \c_xeCJK_space_skip_tl }
+ { \xeCJK_remove_node: \CJKecglue }
+ { \skip_horizontal:N \l__xeCJK_last_skip }
+ }
+ { \skip_horizontal:N \l__xeCJK_last_skip }
+ }
+ }
+\skip_new:N \l__xeCJK_last_skip
\clist_map_inline:nn { Default , HalfRight }
{
\xeCJK_inter_class_toks:nnn {#1} { Boundary }
@@ -782,21 +795,8 @@
{ \xeCJK_check_for_ecglue_normalsp: }
\cs_new_protected_nopar:Npn \__xeCJK_check_for_xecglue_normalsp:
{
- \bool_if:nTF
- {
- \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_space_glue: }
- }
+ \int_compare:nNnTF \etex_lastnodetype:D = \c_eleven
+ { \__xeCJK_replace_space: }
{ \__xeCJK_check_for_ecglue_normalsp: }
}
\cs_new_protected_nopar:Npn \__xeCJK_check_for_ecglue_normalsp:
@@ -849,37 +849,39 @@
\cs_new_eq:NN \xeCJK_check_for_xglue: \prg_do_nothing:
\cs_new_protected_nopar:Npn \__xeCJK_check_for_xglue:
{
- \bool_if:nT
- {
- \int_compare_p:nNn \etex_lastnodetype:D = \c_eleven &&
- ( \skip_if_eq_p:nn \tex_lastskip:D \c_xeCJK_space_skip_tl ||
- \skip_if_eq_p:nn \tex_lastskip:D \l__xeCJK_ecglue_skip )
- }
+ \int_compare:nNnT \etex_lastnodetype:D = \c_eleven
{
+ \skip_set_eq:NN \l__xeCJK_last_skip \tex_lastskip:D
\tex_unskip:D
- \bool_if:nTF
+ \xeCJK_if_last_node:nTF { CJK-space }
+ { \xeCJK_remove_node: \__xeCJK_ccglue_or_space: }
{
- \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:nTF { default-space }
+ { \xeCJK_remove_node: \CJKecglue }
+ { \__xeCJK_check_for_xglue_aux: }
}
- { \xeCJK_remove_node: \CJKecglue }
+ }
+ }
+\cs_new_protected_nopar:Npn \__xeCJK_check_for_xglue_aux:
+ {
+ \skip_if_eq:nnTF { \l__xeCJK_last_skip } { \c_xeCJK_space_skip_tl }
+ {
+ \xeCJK_if_last_node:nTF { CJK }
+ { \xeCJK_remove_node: \__xeCJK_ccglue_or_space: }
{
- \bool_if:nTF
- {
- \xeCJK_if_last_node_p:n { CJK } ||
- \xeCJK_if_last_node_p:n { CJK-space }
- }
+ \xeCJK_if_last_node:nTF { default }
+ { \xeCJK_remove_node: \CJKecglue }
{
- \xeCJK_remove_node:
- \bool_if:NTF \l__xeCJK_reserve_space_bool
- { \xeCJK_space_glue: }
- { \CJKglue }
+ \int_compare:nNnTF \etex_lastnodetype:D = \c_ten
+ { \CJKecglue }
+ { \skip_horizontal:N \l__xeCJK_last_skip }
}
- { \xeCJK_space_glue: }
}
}
+ { \skip_horizontal:N \l__xeCJK_last_skip }
}
+\cs_new_protected_nopar:Npn \__xeCJK_ccglue_or_space:
+ { \CJKglue }
\prg_new_conditional:Npnn \xeCJK_if_last_node:n #1 { p , T , F , TF }
{
\if_dim:w \use:c { c__xeCJK_#1_node_dim } = \tex_lastkern:D
@@ -957,6 +959,10 @@
\xeCJK_glue_to_skip:nN {#1} \l__xeCJK_ecglue_skip
\cs_set_eq:NN \xeCJK_space_or_xecglue: \CJKecglue
\cs_set_eq:NN \xeCJK_check_for_xglue: \__xeCJK_check_for_xglue:
+ \cs_set_eq:NN \xeCJK_check_for_ecglue: \__xeCJK_check_for_xecglue:
+ \cs_set_eq:NN
+ \xeCJK_check_for_ecglue_normalsp:
+ \__xeCJK_check_for_xecglue_normalsp:
} ,
xCJKecglue .default:n = { true }
}
@@ -965,10 +971,26 @@
\bool_new:N \l__xeCJK_xecglue_bool
\keys_define:nn { xeCJK / options }
{
- CJKspace .bool_set:N = \l__xeCJK_reserve_space_bool ,
- space .meta:n = { CJKspace = true } ,
- nospace .meta:n = { CJKspace = false }
+ CJKspace .choice: ,
+ CJKspace / true .code:n =
+ {
+ \bool_set_true:N \l__xeCJK_reserve_space_bool
+ \cs_set_eq:NN \__xeCJK_maybe_reserve_space: \__xeCJK_reserve_space:
+ \cs_set_protected_nopar:Npn \__xeCJK_ccglue_or_space:
+ { \xeCJK_space_glue: }
+ } ,
+ CJKspace / false .code:n =
+ {
+ \bool_set_false:N \l__xeCJK_reserve_space_bool
+ \xeCJK_cs_clear:N \__xeCJK_maybe_reserve_space:
+ \cs_set_protected_nopar:Npn \__xeCJK_ccglue_or_space:
+ { \CJKglue }
+ } ,
+ CJKspace .default:n = { true } ,
+ space .meta:n = { CJKspace = true } ,
+ nospace .meta:n = { CJKspace = false }
}
+\bool_new:N \l__xeCJK_reserve_space_bool
\xeCJK_inter_class_toks:nnn { CJK } { Boundary } { \xeCJK_CJK_and_Boundary:w }
\cs_new_protected_nopar:Npn \xeCJK_CJK_and_Boundary:w
{
@@ -981,16 +1003,20 @@
{
\bool_if:NTF \l__xeCJK_peek_ignore_spaces_bool
{
- \bool_if:nTF
+ \group_align_safe_begin:
+ \token_if_macro:NTF \l_peek_token
{
- \token_if_macro_p:N \l_peek_token ||
- ( \l__xeCJK_reserve_space_bool && \token_if_letter_p:N \l_peek_token )
+ \group_align_safe_end:
+ \xeCJK_class_group_end:
+ { \xeCJK_make_node:n { CJK-space } }
+ \xeCJK_space_or_xecglue:
}
{
- \xeCJK_class_group_end: { \xeCJK_make_node:n { CJK-space } }
- \xeCJK_space_or_xecglue:
+ \group_align_safe_end:
+ \xeCJK_class_group_end:
+ { \xeCJK_make_node:n { CJK-space } }
+ \__xeCJK_maybe_reserve_space:
}
- { \xeCJK_class_group_end: { \xeCJK_make_node:n { CJK-space } } }
}
{
\token_if_eq_meaning:NNTF \l_peek_token \scan_stop:
@@ -1007,6 +1033,9 @@
\token_if_eq_meaning:NNTF #1 \scan_stop:
{#1} { \cs_set_eq:NN #1 \scan_stop: #1 }
}
+\cs_new_protected:Npn \__xeCJK_reserve_space:
+ { \token_if_letter:NT \l_peek_token { \xeCJK_space_or_xecglue: } }
+\cs_new_eq:NN \__xeCJK_maybe_reserve_space: \prg_do_nothing:
\cs_new_protected_nopar:Npn \xeCJK_ignore_spaces:w
{
\xeCJK_peek_catcode_ignore_spaces:NTF \c_math_toggle_token
@@ -1019,12 +1048,10 @@
{
\xeCJK_if_last_node:nT { CJK }
{ \xeCJK_remove_node: { \xeCJK_make_node:n { CJK-space } } }
- \bool_if:nT
- {
- \token_if_macro_p:N \l_peek_token ||
- ( \l__xeCJK_reserve_space_bool && \token_if_letter_p:N \l_peek_token )
- }
- { \xeCJK_space_or_xecglue: }
+ \group_align_safe_begin:
+ \token_if_macro:NTF \l_peek_token
+ { \group_align_safe_end: \xeCJK_space_or_xecglue: }
+ { \group_align_safe_end: \__xeCJK_maybe_reserve_space: }
}
}
}
@@ -1079,19 +1106,16 @@
{ \tex_kern:D #1 \exp_stop_f: }
}
\cs_new_protected_nopar:Npn \__xeCJK_punct_glue:NN #1#2
- { \__xeCJK_punct_hskip:n { \__xeCJK_punct_skip:nn {#1} {#2} } }
-\cs_new_eq:NN \__xeCJK_punct_hskip:n \skip_horizontal:n
-\cs_new_protected_nopar:Npn \__xeCJK_punct_rigid_skip:nn #1#2
- { \__xeCJK_use_punct_dim:nnn { glue } {#1} {#2} }
-\cs_new_protected_nopar:Npn \__xeCJK_punct_rubber_skip:nn #1#2
{
- \__xeCJK_use_punct_dim:nnn { glue } {#1} {#2}
- plus \__xeCJK_use_punct_dim:nnn { plus } {#1} {#2}
- minus \__xeCJK_use_punct_dim:nnn { minus } {#1} {#2}
+ \__xeCJK_punct_hskip:n
+ { \__xeCJK_use_dim_or_skip:nnn { glue } {#1} {#2} }
}
-\cs_new_eq:NN \__xeCJK_punct_skip:nn \__xeCJK_punct_rubber_skip:nn
+\cs_new_eq:NN \__xeCJK_punct_hskip:n \skip_horizontal:n
\cs_new_protected_nopar:Npn \__xeCJK_punct_kern:NN #1#2
- { \tex_kern:D \__xeCJK_use_punct_dim:nnn { kern } {#1} {#2} \exp_stop_f: }
+ {
+ \__xeCJK_nobreak_hskip:n
+ { \__xeCJK_use_dim_or_skip:nnn { kern } {#1} {#2} }
+ }
\tl_new:N \g__xeCJK_last_punct_tl
\cs_new_protected_nopar:Npn \xeCJK_FullLeft_and_CJK:
{
@@ -1306,7 +1330,7 @@
{
\__xeCJK_punct_rule:NN \c__xeCJK_right_tl #1
\__xeCJK_punct_breakable_kern:n
- { \__xeCJK_use_punct_dim:nnn { break_kern } {#1} {#2} }
+ { \__xeCJK_use_dim_or_skip:nnn { break_kern } {#1} {#2} }
\__xeCJK_punct_rule:NN \c__xeCJK_left_tl #2
}
\cs_new_eq:NN \__xeCJK_punct_breakable_kern:n \skip_horizontal:n
@@ -1598,9 +1622,9 @@
{ PlainEquation .bool_set:N = \l__xeCJK_plain_equation_bool }
\seq_new:N \g__xeCJK_CJK_sub_class_seq
\NewDocumentCommand \xeCJKDeclareSubCJKBlock
- { s > { \TrimSpaces } m > { \TrimSpaces } m }
+ { s > { \TrimSpaces } m m }
{
- \xeCJK_declare_sub_char_class:nxx { CJK } {#2} {#3}
+ \xeCJK_declare_sub_char_class:nxn { CJK } {#2} {#3}
\IfBooleanT {#1} { \xeCJKResetPunctClass }
}
\@onlypreamble \xeCJKDeclareSubCJKBlock
@@ -1629,9 +1653,9 @@
{
\int_if_exist:cTF { \__xeCJK_class_csname:n { CJK/##1 } }
{
- \xeCJK_declare_char_class:nx
+ \xeCJK_declare_char_class:nc
{ CJK \bool_if:NF \l__xeCJK_sub_cancel_bool { /##1 } }
- { \tl_use:c { g__xeCJK_CJK/##1_range_clist } }
+ { g__xeCJK_CJK/##1_range_clist }
}
{ \__xeCJK_error:nx { SubBlock-undefined } {##1} }
}
@@ -1653,7 +1677,7 @@
}
\xeCJK_declare_char_class:nn { #1/#2 } {#3}
}
-\cs_generate_variant:Nn \xeCJK_declare_sub_char_class:nnn { nxx }
+\cs_generate_variant:Nn \xeCJK_declare_sub_char_class:nnn { nx }
\cs_new_protected_nopar:Npn \__xeCJK_set_sub_class_toks:nn #1#2
{
\seq_map_inline:Nn \g__xeCJK_base_class_seq
@@ -1758,9 +1782,13 @@
RubberPunctSkip .choice: ,
RubberPunctSkip .default:n = { true } ,
RubberPunctSkip / true .code:n =
- { \cs_set_eq:NN \__xeCJK_punct_skip:nn \__xeCJK_punct_rubber_skip:nn } ,
+ { \cs_set_eq:NN \__xeCJK_use_dim_or_skip:nnn \__xeCJK_use_punct_skip:nnn } ,
+ RubberPunctSkip / plus .code:n =
+ { \cs_set_eq:NN \__xeCJK_use_dim_or_skip:nnn \__xeCJK_use_punct_skip_plus:nnn } ,
+ RubberPunctSkip / minus .code:n =
+ { \cs_set_eq:NN \__xeCJK_use_dim_or_skip:nnn \__xeCJK_use_punct_skip_minus:nnn } ,
RubberPunctSkip / false .code:n =
- { \cs_set_eq:NN \__xeCJK_punct_skip:nn \__xeCJK_punct_rigid_skip:nn }
+ { \cs_set_eq:NN \__xeCJK_use_dim_or_skip:nnn \__xeCJK_use_punct_dim:nnn }
}
\bool_new:N \l__xeCJK_punct_breakable_bool
\clist_new:N \g__xeCJK_special_punct_clist
@@ -1813,18 +1841,50 @@
\prg_return_true: \else: \prg_return_false: \fi:
}
}
-\cs_new_nopar:Npn \__xeCJK_punct_dim_csname:nn #1#2
- { c__\l_xeCJK_current_font_tl/\l_xeCJK_punct_style_tl/#1/#2/tl }
-\cs_new_nopar:Npn \__xeCJK_punct_dim_csname:nnn #1#2#3
- { c__\l_xeCJK_current_font_tl/\l_xeCJK_punct_style_tl/#1/#2/#3/tl }
-\cs_new_nopar:Npn \__xeCJK_use_punct_dim:nn #1#2
- { \use:c { \__xeCJK_punct_dim_csname:nn {#1} {#2} } }
-\cs_new_nopar:Npn \__xeCJK_use_punct_dim:nnn #1#2#3
- { \use:c { \__xeCJK_punct_dim_csname:nnn {#1} {#2} {#3} } }
-\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} } }
+\cs_new:Npn \__xeCJK_punct_csname:n #1
+ { c__xeCJK_\l_xeCJK_current_font_tl/\l_xeCJK_punct_style_tl/#1/tl }
+\cs_new:Npn \__xeCJK_use_punct_dim:nn #1#2
+ { \use:c { \__xeCJK_punct_csname:n { dim/#1/#2 } } }
+\cs_new:Npn \__xeCJK_use_punct_dim:nnn #1#2#3
+ { \use:c { \__xeCJK_punct_csname:n { dim/#1/#2/#3 } } }
+\cs_new:Npn \__xeCJK_use_punct_skip:nnn #1#2#3
+ { \use:c { \__xeCJK_punct_csname:n { skip/#1/#2/#3 } } }
+\cs_new:Npn \__xeCJK_use_punct_skip_plus:nnn #1#2#3
+ { \use:c { \__xeCJK_punct_csname:n { skip/plus/#1/#2/#3 } } }
+\cs_new:Npn \__xeCJK_use_punct_skip_minus:nnn #1#2#3
+ { \use:c { \__xeCJK_punct_csname:n { skip/minus/#1/#2/#3 } } }
+\cs_new_protected:Npn \__xeCJK_save_punct_dim:nnn #1#2
+ { \__xeCJK_save_punct_width_aux:nnn { dim } { #1/#2 } }
+\cs_new_protected:Npn \__xeCJK_save_punct_dim:nnnn #1#2#3
+ { \__xeCJK_save_punct_width_aux:nnn { dim } { #1/#2/#3 } }
+\cs_new_protected:Npn \__xeCJK_save_punct_skip:nnnn #1#2#3#4
+ {
+ \__xeCJK_save_punct_width_aux:nnn { skip } { #1/#2/#3 } {#4}
+ \__xeCJK_save_punct_width_aux:nnn { skip } { plus/#1/#2/#3 } {#4}
+ \__xeCJK_save_punct_width_aux:nnn { skip } { minus/#1/#2/#3 } {#4}
+ }
+\cs_new_protected:Npn \__xeCJK_save_punct_skip:nnnnnn #1#2#3#4#5#6
+ {
+ \use:x
+ {
+ \__xeCJK_save_punct_skip_aux:nnnn { #1/#2/#3 }
+ { \dim_eval:n {#4} }
+ { \dim_max:nn { \c_zero_dim } {#5} }
+ { \dim_max:nn { \c_zero_dim } {#6} }
+ }
+ }
+\cs_new_protected:Npn \__xeCJK_save_punct_skip_aux:nnnn #1#2#3#4
+ {
+ \__xeCJK_save_punct_width_aux:nnn { skip } {#1} { #2 ~ plus ~ #3 ~ minus ~ #4 ~ }
+ \__xeCJK_save_punct_width_aux:nnn { skip } { plus/#1 } { #2 ~ plus ~ #3 ~ }
+ \__xeCJK_save_punct_width_aux:nnn { skip } { minus/#1 } { #2 ~ minus ~ #4 ~ }
+ }
+\cs_new_protected:Npn \__xeCJK_save_punct_width_aux:nnn #1#2#3
+ {
+ \tl_const:cx { \__xeCJK_punct_csname:n { #1/#2 } }
+ { \use:c { #1_eval:n } {#3} }
+ }
+\cs_new_eq:NN \__xeCJK_use_dim_or_skip:nnn \__xeCJK_use_punct_skip:nnn
\DeclareObjectType { xeCJK / punctuation } { \c_zero }
\DeclareTemplateInterface { xeCJK / punctuation } { basic } { \c_zero }
{
@@ -1901,20 +1961,19 @@
{ \AssignTemplateKeys }
\cs_new_protected_nopar:Npn \xeCJK_get_punct_bounds:NN #1#2
{
- \tl_if_exist:cF { \__xeCJK_punct_dim_csname:nnn { glue } {#1} {#2} }
+ \tl_if_exist:cF { \__xeCJK_punct_csname:n { dim/glue/#1/#2 } }
{
\tl_if_eq:NNTF \l_xeCJK_punct_style_tl \c__xeCJK_punct_style_plain_tl
{
\__xeCJK_save_punct_dim:nnnn { rule } {#1} {#2} { \c_zero_dim }
\__xeCJK_save_punct_dim:nnnn { glue } {#1} {#2} { \c_zero_dim }
- \__xeCJK_save_punct_dim:nnnn { plus } {#1} {#2} { \c_zero_dim }
- \__xeCJK_save_punct_dim:nnnn { minus } {#1} {#2} { \c_zero_dim }
\__xeCJK_save_punct_dim:nnnn { offset } {#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_save_punct_skip:nnnn { glue } {#1} {#2} { \c_zero_skip }
}
{
- { \xeCJK_select_font: \xeCJK_calc_punct_dimen:f {#2} }
+ { \xeCJK_select_font: \xeCJK_calc_punct_dimen:o {#2} }
\dim_set:Nn \l__xeCJK_bound_dim
{ \__xeCJK_use_punct_dim:nnn { bound } {#1} {#2} }
\dim_set:Nn \l__xeCJK_reverse_bound_dim
@@ -1933,12 +1992,14 @@
\dim_new:N \l__xeCJK_reverse_bound_dim
\cs_new_protected_nopar:Npn \xeCJK_get_punct_kerning:NN #1#2
{
- \tl_if_exist:cF { \__xeCJK_punct_dim_csname:nnn { kern } {#1} {#2} }
+ \tl_if_exist:cF { \__xeCJK_punct_csname:n { dim/kern/#1/#2 } }
{
\tl_if_eq:NNTF \l_xeCJK_punct_style_tl \c__xeCJK_punct_style_plain_tl
{
\__xeCJK_save_punct_dim:nnnn { kern } {#1} {#2} { \c_zero_dim }
\__xeCJK_save_punct_dim:nnnn { break_kern } {#1} {#2} { \c_zero_dim }
+ \__xeCJK_save_punct_skip:nnnn { kern } {#1} {#2} { \c_zero_skip }
+ \__xeCJK_save_punct_skip:nnnn { break_kern } {#1} {#2} { \c_zero_skip }
}
{
\UseInstance { xeCJK / punctuation } { \l_xeCJK_punct_style_tl }
@@ -2024,27 +2085,21 @@
}
}
\__xeCJK_save_punct_dim:nnnn { glue } {#1} {#2} { \l__xeCJK_tmp_dim }
- \__xeCJK_save_punct_dim:nnnn { plus } {#1} {#2}
+ \__xeCJK_save_punct_skip:nnnnnn { glue } {#1} {#2}
+ { \l__xeCJK_tmp_dim }
{
- \dim_max:nn { \c_zero_dim }
+ \__xeCJK_punct_if_middle:NTF {#2}
{
- \__xeCJK_punct_if_middle:NTF {#2}
- {
- ( \__xeCJK_use_punct_dim:nn { width } {#2} -
- \__xeCJK_use_punct_dim:nn { dimen } {#2} ) / \c_two
- - \l__xeCJK_tmp_dim
- }
- { \l__xeCJK_bound_dim - \l__xeCJK_tmp_dim }
+ ( \__xeCJK_use_punct_dim:nn { width } {#2} -
+ \__xeCJK_use_punct_dim:nn { dimen } {#2} ) / \c_two
+ - \l__xeCJK_tmp_dim
}
+ { \l__xeCJK_bound_dim - \l__xeCJK_tmp_dim }
}
- \__xeCJK_save_punct_dim:nnnn { minus } {#1} {#2}
{
- \dim_max:nn { \c_zero_dim }
- {
- \__xeCJK_punct_if_middle:NTF {#2}
- { .5 \l__xeCJK_tmp_dim }
- { \l__xeCJK_tmp_dim - \l__xeCJK_reverse_bound_dim }
- }
+ \__xeCJK_punct_if_middle:NTF {#2}
+ { .5 \l__xeCJK_tmp_dim }
+ { \l__xeCJK_tmp_dim - \l__xeCJK_reverse_bound_dim }
}
}
\cs_new_protected_nopar:Npn \xeCJK_punct_offset_process:NN #1#2
@@ -2121,38 +2176,47 @@
}
\cs_new_protected_nopar:Npn \xeCJK_punct_kerning_process:NN #1#2
{
- \dim_set:Nn \l__xeCJK_tmp_dim
+ \dim_set:Nn \l__xeCJK_original_margin_dim
+ { \__xeCJK_original_kerning_margin:NN {#1} {#2} }
+ \dim_set:Nn \l__xeCJK_minimum_bound_dim
+ { \__xeCJK_punct_min_bound:NN {#1} {#2} }
+ \dim_set:Nn \l__xeCJK_kerning_margin_dim
{
\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 } }
+ { \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} }
+ { \l__xeCJK_original_margin_dim }
}
}
- \__xeCJK_save_punct_dim:nnnn { kern } {#1} {#2}
- {
- \l__xeCJK_tmp_dim
- - ( \__xeCJK_use_punct_dim:nnn { bound } \c__xeCJK_right_tl {#1} )
- - ( \__xeCJK_use_punct_dim:nnn { bound } \c__xeCJK_left_tl {#2} )
- }
+ \__xeCJK_save_kerning:nnNN { kern } { bound } {#1} {#2}
\__xeCJK_punct_if_right:NF {#2}
{
\__xeCJK_punct_if_right:NT {#1}
- {
- \__xeCJK_save_punct_dim:nnnn { break_kern } {#1} {#2}
- {
- \l__xeCJK_tmp_dim
- - ( \__xeCJK_use_punct_dim:nnn { offset } \c__xeCJK_right_tl {#1} )
- - ( \__xeCJK_use_punct_dim:nnn { offset } \c__xeCJK_left_tl {#2} )
- }
- }
+ { \__xeCJK_save_kerning:nnNN { break_kern } { offset } {#1} {#2} }
+ }
+ }
+\dim_new:N \l__xeCJK_minimum_bound_dim
+\dim_new:N \l__xeCJK_kerning_margin_dim
+\dim_new:N \l__xeCJK_original_margin_dim
+\cs_new_protected_nopar:Npn \__xeCJK_save_kerning:nnNN #1#2#3#4
+ {
+ \dim_set:Nn \l__xeCJK_tmp_dim
+ {
+ \l__xeCJK_kerning_margin_dim
+ - ( \__xeCJK_use_punct_dim:nnn {#2} \c__xeCJK_right_tl {#3} )
+ - ( \__xeCJK_use_punct_dim:nnn {#2} \c__xeCJK_left_tl {#4} )
}
+ \__xeCJK_save_punct_dim:nnnn {#1} {#3} {#4} { \l__xeCJK_tmp_dim }
+ \__xeCJK_save_punct_skip:nnnnnn {#1} {#3} {#4}
+ { \l__xeCJK_tmp_dim }
+ { \l__xeCJK_original_margin_dim - \l__xeCJK_kerning_margin_dim }
+ { \l__xeCJK_kerning_margin_dim - \l__xeCJK_minimum_bound_dim }
}
\cs_new_nopar:Npn \__xeCJK_original_kerning_margin:NN #1#2
{
@@ -2172,10 +2236,10 @@
{ \l__xeCJK_kerning_margin_minimum_dim }
{
\bool_if:NTF \l__xeCJK_min_bound_to_kerning_bool
- { \__xeCJK_punct_min_bound:NN {#1} {#2} }
+ { \l__xeCJK_minimum_bound_dim }
{
\bool_if:NTF \l__xeCJK_optimize_kerning_bool
- { \dim_max:nn { \__xeCJK_punct_min_bound:NN {#1} {#2} } }
+ { \dim_max:nn { \l__xeCJK_minimum_bound_dim } }
{ \use:n }
{
\dim_compare:nNnTF \l__xeCJK_kerning_total_width_dim < \c_max_dim
@@ -2215,7 +2279,7 @@
{ \fp_use:N \l__xeCJK_kerning_margin_ratio_fp \use:n }
}
{ \fp_use:c { l__xeCJK_#1_align_ratio_fp } \use:n }
- { \etex_dimexpr:D \__xeCJK_original_kerning_margin:NN {#2} {#3} \scan_stop: }
+ { \l__xeCJK_original_margin_dim }
}
}
\cs_new_nopar:Npn \__xeCJK_punct_min_bound:NN #1#2
@@ -2264,16 +2328,18 @@
{ \__xeCJK_use_punct_dim:nn { width } {#1} - \l__xeCJK_tmp_dim }
\__xeCJK_punct_if_long:NT {#1}
{
- \__xeCJK_save_punct_dim:nnnn { kern } {#1} {#1}
+ \dim_set:Nn \l__xeCJK_tmp_dim
{
\str_case:nnTF {#1}
{ { ^^^^2025 } { } { ^^^^2026 } { } }
{ \c_zero_dim }
{ - \l__xeCJK_tmp_dim }
}
+ \__xeCJK_save_punct_dim:nnnn { kern } {#1} {#1} { \l__xeCJK_tmp_dim }
+ \__xeCJK_save_punct_skip:nnnn { kern } {#1} {#1} { \l__xeCJK_tmp_dim }
}
}
-\cs_generate_variant:Nn \xeCJK_calc_punct_dimen:N { f }
+\cs_generate_variant:Nn \xeCJK_calc_punct_dimen:N { o }
\cs_new_nopar:Npn \xeCJK_glyph_bounds:NN #1#2
{
\dim_use:N \xetex_glyphbounds:D #1 ~
@@ -2746,7 +2812,8 @@
{ \__xeCJK_family_nfss_csname:n {#2} }
}
}
-\cs_generate_variant:Nn \__xeCJK_copy_family:nn { xx }
+\cs_new_protected_nopar:Npn \__xeCJK_copy_family:xx #1#2
+ { \use:x { \__xeCJK_copy_family:nn {#1} {#2} } }
\tl_new:N \l_xeCJK_current_font_tl
\tl_set:Nn \l_xeCJK_current_font_tl { \__xeCJK_font_csname:n { \CJK@family } }
\cs_new_nopar:Npn \__xeCJK_font_csname:n #1 { xeCJK/#1/\f@series/\f@shape/\f@size }
@@ -2767,28 +2834,32 @@
\__xeCJK_info:nxx { CJK-block } {#1} {#2}
\str_if_eq:nnTF {#2} { CJK }
{ \xeCJK_select_font: }
- { \__xeCJK_block_select_font:n {#2} }
+ { \xeCJK_select_font:n {#2} }
}
}
\__xeCJK_msg_new:nn { CJK-block } { Switch~from~block~`#1'~to~`#2'. }
-\cs_new_protected_nopar:Npn \__xeCJK_block_select_font:n #1
+\cs_new_protected_nopar:Npn \xeCJK_select_font:n #1
{
\exp_args:Nc \cs_if_exist_use:NF { \__xeCJK_font_csname:n { \CJK@family/#1 } }
{
- \xeCJK_family_if_exist:xF { \l_xeCJK_family_tl/#1 }
- {
- \__xeCJK_copy_family:xx { \l_xeCJK_family_tl/#1 }
- {
- \cs_if_exist:cTF
- { \__xeCJK_family_csname:n { \CJKfamilydefault/#1 } }
- { \CJKfamilydefault/#1 } { \l_xeCJK_family_tl }
- }
- }
+ \xeCJK_block_family:nn { \l_xeCJK_family_tl } {#1}
\__xeCJK_family_use:x { \l_xeCJK_family_tl/#1 }
\xeCJK_font_gset_to_current:c
{ \__xeCJK_font_csname:n { \CJK@family/#1 } }
}
}
+\cs_new_protected_nopar:Npn \xeCJK_block_family:nn #1#2
+ {
+ \xeCJK_family_if_exist:xF { #1/#2 }
+ {
+ \__xeCJK_copy_family:xx { #1/#2 }
+ {
+ \cs_if_exist:cTF
+ { \__xeCJK_family_csname:n { \CJKfamilydefault/#2 } }
+ { \CJKfamilydefault/#2 } {#1}
+ }
+ }
+ }
\cs_new_nopar:Npn \__xeCJK_family_csname:n #1 { xeCJK/family/#1 }
\cs_new_nopar:Npn \__xeCJK_family_nfss_csname:n #1 { xeCJK/family/nfss/#1 }
\cs_new_nopar:Npn \__xeCJK_family_use:x #1 { \use:c { \__xeCJK_family_nfss_csname:n {#1} } }
@@ -3075,37 +3146,35 @@
{
\__xeCJK_warning:n { fandol }
\__xeCJK_load_fandol:
- \use:n
- }
- {
- \__xeCJK_warning:nx { no-CJKfamily } { \CJKfamilydefault }
- \use_none:n
+ \xeCJK_ensure_default_family:
}
+ { \__xeCJK_warning:nx { no-CJKfamily } { \CJKfamilydefault } }
}
- { \use:n }
+ { \xeCJK_ensure_default_family: }
+ }
+\cs_new_protected_nopar:Npn \xeCJK_ensure_default_family:
+ {
+ \xeCJK_family_if_exist:xF { \CJKfamilydefault }
{
- \xeCJK_family_if_exist:xF { \CJKfamilydefault }
+ \tl_set_eq:NN \l__xeCJK_tmp_tl \CJKfamilydefault
+ \str_if_eq_x:nnTF { \CJKfamilydefault } { \CJKrmdefault }
+ { \use:n }
{
- \tl_set_eq:NN \l__xeCJK_tmp_tl \CJKfamilydefault
- \str_if_eq_x:nnTF { \CJKfamilydefault } { \CJKrmdefault }
- { \use:n }
- {
- \xeCJK_family_if_exist:xTF { \CJKrmdefault }
- { \tl_gset:Nn \CJKfamilydefault { \CJKrmdefault } }
- }
+ \xeCJK_family_if_exist:xTF { \CJKrmdefault }
+ { \tl_gset:Nn \CJKfamilydefault { \CJKrmdefault } }
+ }
+ {
+ \prop_map_inline:Nn \g__xeCJK_family_font_name_prop
{
- \prop_map_inline:Nn \g__xeCJK_family_font_name_prop
- {
- \prop_map_break:n
- { \tl_gset_rescan:Nnn \CJKfamilydefault { } {#1} }
- }
+ \prop_map_break:n
+ { \tl_gset_rescan:Nnn \CJKfamilydefault { } { ##1 } }
}
- \__xeCJK_warning:nxx { CJKfamilydefault-undefined }
- { \l__xeCJK_tmp_tl } { \CJKfamilydefault }
}
- \xeCJK_switch_family:n { \CJKfamilydefault }
- \bool_if:NT \g__xeCJK_math_bool { \xeCJK_set_mathfont: }
+ \__xeCJK_warning:nxx { CJKfamilydefault-undefined }
+ { \l__xeCJK_tmp_tl } { \CJKfamilydefault }
}
+ \xeCJK_switch_family:n { \CJKfamilydefault }
+ \bool_if:NT \g__xeCJK_math_bool { \xeCJK_set_mathfont: }
}
\__xeCJK_msg_new:nn { no-CJKfamily }
{
@@ -3132,43 +3201,130 @@
\cs_new_protected_nopar:Npn \xeCJK_set_mathfont:
{
\xeCJK_family_if_exist:xTF { \c__xeCJK_math_tl }
- { \use:n }
- {
- \xeCJK_family_if_exist:xTF { \CJKfamilydefault }
- { \use:n } { \use_none:n }
- }
+ { \__xeCJK_set_mathfont_aux: }
{
- \tl_const:Nx \c__xeCJK_math_family_tl { \l__xeCJK_fontspec_family_tl }
- \DeclareSymbolFont { \c__xeCJK_math_tl } { \c__xeCJK_encoding_tl }
- { \c__xeCJK_math_family_tl } { \mddefault } { \shapedefault }
- \cs_if_free:cF
- { \c__xeCJK_encoding_tl/\c__xeCJK_math_family_tl/\bfdefault/\shapedefault }
+ \xeCJK_family_if_exist:xT { \CJKfamilydefault }
{
- \SetSymbolFont { \c__xeCJK_math_tl } { bold } { \c__xeCJK_encoding_tl }
- { \c__xeCJK_math_family_tl } { \bfdefault } { \shapedefault }
+ \__xeCJK_copy_family:xx { \c__xeCJK_math_tl } { \CJKfamilydefault }
+ \__xeCJK_set_mathfont_aux:
}
- \int_const:Nn \c_xeCJK_math_fam_int { \use:c { sym \c__xeCJK_math_tl } }
- \clist_concat:NNN \l__xeCJK_tmp_clist
- \c__xeCJK_CJK_chars_clist \c__xeCJK_FullLeft_chars_clist
- \clist_concat:NNN \l__xeCJK_tmp_clist
- \l__xeCJK_tmp_clist \c__xeCJK_FullRight_chars_clist
- \clist_map_inline:Nn \l__xeCJK_tmp_clist
+ }
+ }
+\cs_new_protected_nopar:Npn \__xeCJK_set_mathfont_aux:
+ {
+ \tl_const:Nx \c__xeCJK_math_family_tl { \l__xeCJK_fontspec_family_tl }
+ \xeCJK_declare_mathfont:nn { \c__xeCJK_math_tl } { \c__xeCJK_math_family_tl }
+ \int_const:Nn \c_xeCJK_math_fam_int { \use:c { sym \c__xeCJK_math_tl } }
+ \clist_concat:NNN \g__xeCJK_math_chars_clist
+ \g__xeCJK_CJK_range_clist \g__xeCJK_FullLeft_range_clist
+ \clist_concat:NNN \g__xeCJK_math_chars_clist
+ \g__xeCJK_math_chars_clist \g__xeCJK_FullRight_range_clist
+ \xeCJK_gset_mathcode:Nn \g__xeCJK_math_chars_clist { \c_xeCJK_math_fam_int }
+ \xeCJK_set_mathfont_block:
+ }
+\clist_new:N \g__xeCJK_math_chars_clist
+\prop_new:N \g__xeCJK_fam_prop
+\cs_new_protected_nopar:Npn \xeCJK_set_mathfont_block:
+ {
+ \seq_if_empty:NF \g__xeCJK_CJK_sub_class_seq
+ {
+ \seq_map_function:NN
+ \g__xeCJK_CJK_sub_class_seq
+ \xeCJK_set_mathfont_block:n
+ }
+ }
+\cs_new_protected_nopar:Npn \xeCJK_set_mathfont_block:n #1
+ {
+ \xeCJK_block_family:nn { \c__xeCJK_math_tl } {#1}
+ \prop_get:NoNTF \g__xeCJK_fam_prop
+ { \l__xeCJK_fontspec_family_tl } \l__xeCJK_tmp_tl
+ { \int_set:Nn \l__xeCJK_fam_int { \l__xeCJK_tmp_tl } }
+ {
+ \xeCJK_declare_mathfont:nn
+ { \c__xeCJK_math_tl / #1 } { \l__xeCJK_fontspec_family_tl }
+ \__xeCJK_set_mathfont_block_aux:cn { sym \c__xeCJK_math_tl / #1 } {#1}
+ }
+ \xeCJK_gset_mathcode:cn { g__xeCJK_CJK/#1_range_clist } { \l__xeCJK_fam_int }
+ }
+\cs_new_protected_nopar:Npn \__xeCJK_set_mathfont_block_aux:Nn #1#2
+ {
+ \int_set_eq:NN \l__xeCJK_fam_int #1
+ \prop_gput:Nnn \g__xeCJK_block_fam_prop {#2} {#1}
+ }
+\int_new:N \l__xeCJK_fam_int
+\prop_new:N \g__xeCJK_block_fam_prop
+\cs_generate_variant:Nn \__xeCJK_set_mathfont_block_aux:Nn { c }
+\cs_new_protected_nopar:Npn \xeCJK_declare_mathfont:nn #1#2
+ {
+ \xeCJK_declare_symbol_font:nnnnn {#1} { \c__xeCJK_encoding_tl }
+ {#2} { \mddefault } { \updefault }
+ \cs_if_free:cF
+ { \c__xeCJK_encoding_tl/#2/\bfdefault/\updefault }
+ {
+ \SetSymbolFont {#1} { bold } { \c__xeCJK_encoding_tl }
+ {#2} { \bfdefault } { \updefault }
+ }
+ \prop_gput:Nxx \g__xeCJK_fam_prop {#2} { \exp_not:c { sym #1 } }
+ }
+\cs_new_protected:Npn \xeCJK_declare_symbol_font:nnnnn #1
+ { \__xeCJK_declare_symbol_font:cnnnn { sym #1 } }
+\cs_new_protected:Npn \__xeCJK_declare_symbol_font:Nnnnn #1
+ {
+ \xeCJK_new_fam:N #1
+ \xeCJK_new_symbol_font:Nnnnn #1
+ }
+\cs_generate_variant:Nn \__xeCJK_declare_symbol_font:Nnnnn { c }
+\cs_new_protected:Npn \xeCJK_new_fam:N #1
+ {
+ \int_compare:nNnTF
+ { \g__xeCJK_fam_allocation_int } > { \g__xeCJK_fam_bottom_int }
+ {
+ \int_set_eq:NN \allocationnumber \g__xeCJK_fam_allocation_int
+ \int_const:Nn #1 { \allocationnumber }
+ \iow_log:x
{
- \__xeCJK_set_char_class_aux:Nnw \xeCJK_gset_mathcode:nnnn {##1}
- { \c_zero } { \c_xeCJK_math_fam_int }
+ \token_to_str:N #1 =
+ \token_to_str:N \mathgroup \int_use:N \allocationnumber
}
+ \int_gdecr:N \g__xeCJK_fam_allocation_int
+ }
+ { \__xeCJK_error:n { fam-exhausted } }
+ }
+\tex_countdef:D \g__xeCJK_fam_bottom_int = 18 ~
+\int_new:N \g__xeCJK_fam_allocation_int
+\int_gset_eq:NN \g__xeCJK_fam_allocation_int \c_two_hundred_fifty_five
+\__xeCJK_msg_new:nn { fam-exhausted }
+ { No~room~for~a~new~fam. }
+\cs_new_protected:Npn \xeCJK_new_symbol_font:Nnnnn #1#2#3#4#5
+ { \__xeCJK_new_symbol_font:Nc #1 { #2/#3/#4/#5 } }
+\cs_new_protected:Npn \__xeCJK_new_symbol_font:NN #1#2
+ {
+ \tl_put_right:Nn \group@list { \group@elt #1 #2 }
+ \cs_set_nopar:Npn \version@elt ##1
+ { \tl_put_right:Nn ##1 { \getanddefine@fonts #1 #2 } }
+ \version@list
+ }
+\cs_generate_variant:Nn \__xeCJK_new_symbol_font:NN { Nc }
+\cs_new_protected_nopar:Npn \xeCJK_gset_mathcode:Nn #1#2
+ {
+ \clist_map_inline:Nn #1
+ {
+ \__xeCJK_set_char_class_aux:Nnw \xeCJK_gset_mathcode:nnnn { ##1 }
+ { \c_zero } {#2}
}
}
+\cs_generate_variant:Nn \xeCJK_gset_mathcode:Nn { c }
\cs_new_protected_nopar:Npn \xeCJK_gset_mathcode:nnnn #1#2#3#4
{
\__xeCJK_check_num_range:nnNN {#1} {#2} \l__xeCJK_begin_int \l__xeCJK_end_int
\xeCJK_int_until_do:nn { \l__xeCJK_begin_int > \l__xeCJK_end_int }
{
- \tex_global:D \utex_mathcode:D
- \l__xeCJK_begin_int = #3 ~ #4 \l__xeCJK_begin_int
+ \xeCJK_gset_mathcode:Nnn \l__xeCJK_begin_int {#3} {#4}
\int_incr:N \l__xeCJK_begin_int
}
}
+\cs_new_protected_nopar:Npn \xeCJK_gset_mathcode:Nnn #1#2#3
+ { \tex_global:D \utex_mathcode:D #1 = #2 ~ #3 ~ #1 }
\int_new:N \l__xeCJK_verb_case_int
\keys_define:nn { xeCJK / options }
{
@@ -3636,16 +3792,40 @@
}
}
{ \AtBeginDocument { \xeCJK_fix_hbar: } }
-\cs_new_protected_nopar:Npn \__xeCJK_update_url_font:
+\cs_new_protected_nopar:Npn \xeCJK@update@fam
+ {
+ \addto@hook \everymath
+ {
+ \__xeCJK_update_main_fam:
+ \__xeCJK_update_block_fam:
+ }
+ }
+\cs_new_protected_nopar:Npn \__xeCJK_update_main_fam:
{
\group_begin: \xeCJK_select_font: \exp_after:wN \group_end:
- \exp_after:wN \tex_textfont:D \exp_after:wN \c_xeCJK_math_fam_int
- \tex_the:D \tex_font:D
+ \exp_after:wN \tex_textfont:D \exp_after:wN \c_xeCJK_math_fam_int
+ \tex_the:D \tex_font:D
+ }
+\cs_new_protected_nopar:Npn \__xeCJK_update_block_fam:
+ {
+ \prop_if_empty:NF \g__xeCJK_block_fam_prop
+ {
+ \prop_map_function:NN
+ \g__xeCJK_block_fam_prop
+ \__xeCJK_update_block_fam:nn
+ }
+ }
+\cs_new_protected_nopar:Npn \__xeCJK_update_block_fam:nn #1#2
+ {
+ \int_set:Nn \l__xeCJK_fam_int {#2}
+ \group_begin: \xeCJK_select_font:n {#1} \exp_after:wN \group_end:
+ \exp_after:wN \tex_textfont:D \exp_after:wN \l__xeCJK_fam_int
+ \tex_the:D \tex_font:D
}
\__xeCJK_after_end_preamble:n
{
\bool_if:nT { \g__xeCJK_math_bool && \cs_if_exist_p:N \Url@MathSetup }
- { \tl_put_right:Nn \Url@MathSetup { \__xeCJK_update_url_font: } }
+ { \tl_put_right:Nn \Url@MathSetup { \xeCJK@update@fam } }
}
\@ifpackagelater { fontspec } { 2014/06/21 } { }
{
@@ -4031,37 +4211,38 @@
\ExplSyntaxOn
}
%%
-%% 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,
-%% xunicode-extra.def,
-%% xeCJK-example-autofake.tex,
-%% xeCJK-example-fallback.tex,
-%% xeCJK-example-subCJKblock.tex,
-%% xeCJK-example-CJKecglue.tex,
-%% xeCJK-example-checksingle.tex,
-%% xeCJK-example-CJKfntef.tex,
-%% xeCJK-example-punctstyle.tex,
-%% xeCJK-example-verbatim.tex,
-%% xeCJK-example-CM.tex,
-%% xeCJK-example-listings.tex,
-%% xunicode-symbols.tex,
-%% xunicode-commands.tex,
-%% xunicode-combine-marks.tex,
-%% xunicode-symbols.pdf,
-%% full-stop.tec,
-%% fullwidth-stop.tec,
-%% han-simp.tec,
-%% han-trad.tec, and
-%% README.txt.
+%% This package consists of the files 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,
+%% xunicode-extra.def,
+%% xeCJK-example-autofake.tex,
+%% xeCJK-example-fallback.tex,
+%% xeCJK-example-subCJKblock.tex,
+%% xeCJK-example-CJKecglue.tex,
+%% xeCJK-example-checksingle.tex,
+%% xeCJK-example-CJKfntef.tex,
+%% xeCJK-example-punctstyle.tex,
+%% xeCJK-example-verbatim.tex,
+%% xeCJK-example-CM.tex,
+%% xeCJK-example-listings.tex,
+%% xeCJK-example-mathblock.tex,
+%% xunicode-symbols.tex,
+%% xunicode-commands.tex,
+%% xunicode-combine-marks.tex,
+%% xunicode-symbols.pdf,
+%% full-stop.tec,
+%% fullwidth-stop.tec,
+%% han-simp.tec,
+%% han-trad.tec, and
+%% README.md.
%%
%% End of file `xeCJK.sty'.