summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-07-08 22:01:34 +0000
committerKarl Berry <karl@freefriends.org>2013-07-08 22:01:34 +0000
commitb077ab9cacab5e6fa2f644a13ecf8d76297f4875 (patch)
treef4ed5128a7b1a0eeb9c27033a9d765da470c6d78 /Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx
parent604ab2b8e6483eed86c3262618436714f6a721cb (diff)
xecjk (8jul13)
git-svn-id: svn://tug.org/texlive/trunk@31138 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx')
-rw-r--r--Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx1427
1 files changed, 935 insertions, 492 deletions
diff --git a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx
index 162675ef190..9c6b13540ef 100644
--- a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx
+++ b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx
@@ -81,7 +81,7 @@ CJK scripts fonts (TrueType or OpenType).
\askforoverwritefalse
\preamble
-$Id: xeCJK.dtx 438 2013-06-11 14:17:42Z sobenlee $
+$Id: xeCJK.dtx 465 2013-07-06 10:30:24Z sobenlee $
$URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
-----------------------------------------------------------------
Author:
@@ -170,7 +170,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
%</!config>
-\GetIdInfo$Id: xeCJK.dtx 438 2013-06-11 14:17:42Z sobenlee $
+\GetIdInfo$Id: xeCJK.dtx 465 2013-07-06 10:30:24Z sobenlee $
%<*driver|package>
{Typesetting CJK scripts with XeLaTeX}
%</driver|package>
@@ -188,9 +188,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
%<package> {\ExplFileName}
%<fntef> {xeCJKfntef}
%<listings> {xeCJK-listings}
- {\ExplFileDate}{3.2.3}{\ExplFileDescription}
+ {\ExplFileDate}{3.2.4}{\ExplFileDescription}
%<*driver>
-\def\xeCJKversion{3.2.3}
+\def\xeCJKversion{3.2.4}
\let\xeCJKdate\ExplFileDate
\let\xeCJKrevnum\ExplFileVersion
\ExplSyntaxOff
@@ -198,7 +198,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
%</driver|package|config|fntef|listings>
%
%<*driver>
-\expandafter\let\csname ver@thumbpdf.sty\endcsname\empty
+\expandafter\let\csname ver@thumbpdf.sty\endcsname\fmtversion
\documentclass[numbered,a4paper,full]{l3doc}
\hypersetup{pdfstartview=FitH}
\usepackage{xeCJK}
@@ -212,7 +212,6 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\setlist[optiondesc]{font=\mdseries\ttfamily,align=right,labelsep=.5em,leftmargin=4.5em}
\def\PSKeyVal#1#2{\item[#1]\makebox[4em][l]{\meta{#2}}\ignorespaces}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
-\setmonofont{Inconsolata}
\setCJKmainfont[BoldFont=Adobe Heiti Std,ItalicFont=Adobe Kaiti Std]{Adobe Song Std}
\setCJKmonofont{Adobe Kaiti Std}
\xeCJKDeclareSubCJKBlock{HKMD} { "FF65 }
@@ -252,7 +251,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\CJKfontspec{Microsoft~YaHei}
\int_gzero:N \g_tmpa_int
\int_set:Nn \l_tmpa_int { \clist_count:c { c__xeCJK_#2_chars_clist } }
- \mbox{}\hfill
+ \noindent\hfill
\begin{tabular}{|*{#1}{>{\footnotesize\ttfamily U+}c|c|}}
\clist_map_inline:cn { c__xeCJK_#2_chars_clist }
{
@@ -279,12 +278,12 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\patchcmd\@wrglossary{hdpindex}{hdclindex{\the\c@HD@hypercount}}{}{}
\let\orig@meta\meta
\def\meta#1{%
- \orig@meta{\mbox{\normalfont\itshape\xeCJKsetup{PunctStyle=plain,CJKecglue}#1}}}
+ \orig@meta{\mbox{\itshape\xeCJKsetup{PunctStyle=plain,CJKecglue}#1}}}
\def\TF{true\orvar{}false}
\def\TTF{\defaultvar{true}\orvar{}false}
\def\TFF{true\orvar\defaultvar{false}}
-\chardef\orvar`\|
-\let\defaultvar\textbf
+\def\orvar{\textup{\textbar}}
+\def\defaultvar#1{\textbf{\textup{#1}}}
\@addtoreset{CodelineNo}{section}
\def\tokslink#1{\hyperlink{#1}{\ding{51}}}
\makeatother
@@ -301,16 +300,16 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\DocInput{\jobname.dtx}
\newgeometry{margin=15mm,footskip=7mm}
\PrintChanges
- \clearpage
\PrintIndex
\end{document}
%</driver>
% \fi
%
-% \CheckSum{4400}
+% \CheckSum{4803}
% \changes{v3.1.0}{2012/11/13}{放弃对 \cs{outer} 宏的特殊处理。}
% \changes{v3.1.1}{2012/12/07}{不再依赖 \pkg{xpatch} 宏包。}
% \changes{v3.2.3}{2013/06/07}{提供四个 TECkit 映射文件用于句号转换和简繁互换。}
+% \changes{v3.2.4}{2013/07/02}{遵循 \hologo{LaTeX3} 变量需要预先声明的原则。}
%
%
% \title{\bfseries\pkg{xeCJK} 宏包}
@@ -337,9 +336,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \pkg{xeCJK} 使用了 \XeTeX 的一些最新特性,需要 \XeTeX{} |0.9995.0 [2009/06/29]| 以
% 后的版本。\pkg{xeCJK} 依赖 \hologo{LaTeX3} 项目的宏包套件 \package{l3kernel} 和
% \package{l3packages}。\pkg{xeCJK} 还需要通过 \package{fontspec} 宏包来调用系统字
-% 体。将在 \ref{subsec:opts}~节介绍的功能选项 |CJKnumber| 需要 \package{CJK} 宏包套
-% 件中的 \pkg{CJKnumb} 的支持;|indentfirst| 选项需要 \package{indentfirst} 宏包。
-% \pkg{xeCJK} 会自动根据需要载入这些宏包。
+% 体。将在 \ref{subsec:opts}~节介绍的功能选项 |indentfirst| 选项需要
+% \package{indentfirst} 宏包的支持。\pkg{xeCJK} 会自动根据需要载入这些宏包。
%
% \pkg{xeCJK} 的原始作者是孙文昌,2009 年 5 月起宏包被收入 \ctexkit\ 项目进行
% 维护,目前主要维护者是刘海洋\footnote{\email{leoliu.pku@gmail.com}} 和
@@ -427,14 +425,6 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% 最后还需要在命令行下执行 |mktexlsr|,刷新文件名数据库以便 \TeX 系统能够找到它。
% \end{function}
%
-% \begin{function}[EXP]{CJKnumber}
-% \begin{syntax}
-% CJKnumber = \meta{\TFF}
-% \end{syntax}
-% 为了与 \pkg{CJKnumb} 宏包兼容,\pkg{xeCJK} 作了一些特别处理。因此,如果需要使用
-% 到 \pkg{CJKnumb},请通过这个选项调用它。
-% \end{function}
-%
% \begin{function}[EXP,updated=2012-11-22]{indentfirst}
% \begin{syntax}
% indentfirst = \meta{\TTF}
@@ -442,8 +432,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% 是否使用 \pkg{indentfirst} 宏包,使得跟在章节标题后面的第一段首行也缩进。\bigskip
% \end{function}
%
-% 请注意,\pkg{xeCJK} 宏包中只有上述 |LocalConfig|、|CJKnumber| 和 |indentfirst|
-% 这三个选项需要在调用 \pkg{xeCJK} 时设置,而不能通过 \cs{xeCJKsetup} 来设置。
+% 请注意,\pkg{xeCJK} 宏包中只有上述 |LocalConfig|、和 |indentfirst| 这两个选项需要
+% 在调用 \pkg{xeCJK} 时设置,而不能通过 \cs{xeCJKsetup} 来设置。
%
% \begin{function}{xeCJKactive}
% \begin{syntax}
@@ -496,7 +486,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% 入的 CJK 文字与西文之间的空格。
% \end{function}
%
-% \begin{function}[updated=2012-12-06]{CheckSingle}
+% \begin{function}[updated=2013-06-26]{CheckSingle}
% \begin{syntax}
% CheckSingle = \meta{\TFF}
% \end{syntax}
@@ -587,7 +577,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \item[banjiao] 半角式:所有标点占半个汉字宽度;
% \item[kaiming] 开明式:句末点号用全角,其他半角;
% \item[hangmobanjiao] 行末半角式:所有标点占一个汉字宽度,行首行末对齐;
-% \item[CCT] CCT 格式;
+% \item[CCT] CCT 格式:所有标点符号的宽度略小于一个汉字宽度;
% \item[plain] 原样(不调整标点间距)。
% \end{description}
% 可以使用 \ref{subsec:punctstyle} 中介绍的 \cs{xeCJKDeclarePunctStyle} 定义新的标点
@@ -777,15 +767,20 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{verbatim}
% \end{function}
%
-% \begin{function}{\addCJKfontfeatures}
+% \begin{function}[updated=2013-06-30]{\addCJKfontfeatures}
% \begin{syntax}
-% \cs{addCJKfontfeatures} \Arg{font features}
+% \cs{addCJKfontfeatures} \Arg{font features}
+% \cs{addCJKfontfeatures} * \Arg{font features}
+% \cs{addCJKfontfeatures} \oarg{block_1, block_2, ...} \Arg{font features}
+% \cs{addCJKfontfeatures} * \oarg{block_1, block_2, ...} \Arg{font features}
% \end{syntax}
-% 临时增加当前使用的 CJK 字体的选项。例如,使用
+% 临时增加当前使用的 CJK 字体的选项。第一条命令,仅对当前 CJK 主分区字体有效;
+% 第二条对主分区和其它分区的字体都有效;第三条仅对可选参数中指定的分区有效;
+% 第四条对主分区和可选参数中指定的分区有效。例如,使用
% \begin{verbatim}
% \addCJKfontfeatures{Scale=1.1}
% \end{verbatim}
-% 可以将文档中当前使用的 CJK 字体放大为 |1.1|。
+% 可以将文档中当前使用的 CJK 主分区字体放大为 |1.1|。
% \end{function}
%
% \begin{function}{\CJKrmdefault}
@@ -853,7 +848,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{verbatim}
% \end{function}
%
-% \begin{function}[EXP]{\setCJKfallbackfamilyfont}
+% \begin{function}[EXP,updated=2013-06-30]{\setCJKfallbackfamilyfont}
% \begin{syntax}
% \cs{setCJKfallbackfamilyfont} \Arg{family} \oarg{common font features}
% \ \{
@@ -870,7 +865,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% [AutoFakeBold] {SimSun-ExtB} }
% \end{verbatim}
% 之后,就设置了 |SimSun| 是 |KaiTi_GB2312| 的备用字体,而 |SimSun-ExtB| 是
-% |SimSun| 的备用字体。
+% |SimSun| 的备用字体。若当前字体族缺字,并没有备用字体,则尝试使用
+% \cs{CJKfamilydefault} 的备用字体。
% \end{function}
%
% \subsubsection{\XeTeX 的字体名查找}
@@ -1020,16 +1016,10 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{function}
%
% \begin{function}[EXP]{\xeCJKResetCharClass}
-% \begin{syntax}
-% \cs{xeCJKResetCharClass}
-% \end{syntax}
% 用于恢复 \pkg{xeCJK} 对各个字符类别的初始化设置。
% \end{function}
%
% \begin{function}[EXP]{\xeCJKResetPunctClass}
-% \begin{syntax}
-% \cs{xeCJKResetPunctClass}
-% \end{syntax}
% 用于重置标点符号所属的字符类。
% \end{function}
%
@@ -1177,13 +1167,13 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \PSKeyVal{kerning-total-ratio}{real}
% 设置两个标点的总共输出宽度与实际宽度的比例。默认值是 |0.75|。
% \PSKeyVal{same-align-margin}{length}
-% 当前后两个标点位于同侧时,它们之间的空白宽度。默认值是 \cs{maxdimen}。
+% 前后两个标点位于同侧时,它们之间的空白宽度。默认值是 \cs{maxdimen}。
% \PSKeyVal{same-align-ratio}{real}
-% 当前后两个标点位于同侧时,它们之间的空白宽度与实际输出宽度的比例。默认值是 |0|。
+% 前后两个标点位于同侧时,它们之间的空白宽度与实际输出宽度的比例。默认值是 |0|。
% \PSKeyVal{different-align-margin}{length}
-% 当前后两个标点位于异侧时,它们之间的空白宽度。默认值是 \cs{maxdimen}。
+% 前后两个标点位于异侧时,它们之间的空白宽度。默认值是 \cs{maxdimen}。
% \PSKeyVal{different-align-ratio}{real}
-% 当前后两个标点位于异侧时,它们之间的空白宽度与实际输出宽度的比例。默认值是 |0|。
+% 前后两个标点位于异侧时,它们之间的空白宽度与实际输出宽度的比例。默认值是 |0|。
% \PSKeyVal{kerning-margin-width}{length}
% 设置前后两个标点之间的空白宽度。默认值是 \cs{maxdimen}。
% \PSKeyVal{kerning-margin-ratio}{real}
@@ -1235,12 +1225,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \subsection{其它}
% \label{subsec:others}
%
-% \begin{function}[updated=2013-06-04]{\xeCJKVerbAddon,\xeCJKOffVerbAddon}
-% \begin{syntax}
-% \cs{xeCJKVerbAddon}
-% \cs{xeCJKOffVerbAddon}
-% \end{syntax}
-% 调整文字间距以便于让 CJK 字符占的宽度等于西文等宽字体中两个空格的宽度。这有利于
+% \begin{function}[updated=2013-06-29]{\xeCJKVerbAddon,\xeCJKOffVerbAddon}
+% 调整文字间距以便于让 CJK 字符占的宽度等于西文等宽字体中两个空格的宽度。如果这两
+% 个空格的宽度小于当前 CJK 正常文字的宽度,将对 CJK 字体进行适当地缩小。这有利于
% 等宽字体的代码对齐等情形。需要注意的是,\cs{xeCJKVerbAddon} 对 \pkg{xeCJK} 的内
% 部进行了比较大的修改,使用它之后,关于标点符号的禁则将会丢失。所以不能单独使用,^^A
% 应该放在分组里限制其作用域,否则是无效的。当然它可以和其它关于代码抄录的宏包配
@@ -1269,6 +1256,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \pkg{xeCJK} 使用并重新定义了 \pkg{CJK} 宏包的部分宏命令,如 \cs{CJKfamily}、
% \cs{CJKsymbol} 和 \cs{CJKglue} 等。需要指出,\pkg{xeCJK} 不需要 \pkg{CJK}
% 的支持,并且 \pkg{xeCJK} 自动禁止在它之后载入 \pkg{CJK} 宏包。
+% 可以在 \pkg{xeCJK} 之\emph{后}载入 \pkg{CJKnumb} 宏包,实现数字的中文化。
%
% \CJKunderline{\pkg{xeCJK} 包含有一个子宏包 \pkg{xeCJKfntef},可以用它来实现%
% \CJKunderdot{汉字加点}和可断行的下划线等。它是 \pkg{CJKfntef} 宏包在 \XeLaTeX
@@ -1335,6 +1323,32 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\xetex_if_engine:F { \msg_critical:nn { xeCJK } { Require-XeTeX } }
% \end{macrocode}
%
+% 下面这些 \pkg{CJK} 系列宏包不应该被使用。
+% \begin{macrocode}
+\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. }
+ }
+\clist_map_inline:nn { CJKnumb , CJKulem , CJKvert , CJKpunct , CJKutf8 , CJK }
+ {
+ \@ifpackageloaded {#1}
+ { \msg_error:nnn { xeCJK } { incompatible-package } {#1} }
+ { }
+ }
+% \end{macrocode}
+%
+% 禁止在 \pkg{xeCJK} 宏包后再载入 \pkg{CJK} 宏包,并使得
+% \pkg{CJKnumb} 和 \pkg{CJKfntef} 宏包可以使用。
+% \begin{macrocode}
+\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 }
+% \end{macrocode}
+%
% 应该使用较新版本的 \pkg{expl3} 宏包。
% \begin{macrocode}
\msg_new:nnn { xeCJK } { l3-too-old }
@@ -1365,17 +1379,13 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
%
% 分配临时变量。
% \begin{macrocode}
-\tl_new:N \l_@@_tmpa_tl
-\tl_new:N \l_@@_tmpb_tl
-\int_new:N \l_@@_tmpa_int
-\int_new:N \l_@@_tmpb_int
-\int_new:N \l_@@_tmpc_int
+\tl_new:N \l_@@_tmp_tl
+\int_new:N \l_@@_tmp_int
\box_new:N \l_@@_tmp_box
\dim_new:N \l_@@_tmp_dim
+\bool_new:N \l_@@_tmp_bool
\skip_new:N \l_@@_tmp_skip
-\prop_new:N \l_@@_tmp_prop
-\clist_new:N \l_@@_tmpa_clist
-\clist_new:N \l_@@_tmpb_clist
+\clist_new:N \l_@@_tmp_clist
% \end{macrocode}
%
% \begin{macro}[internal]
@@ -1456,17 +1466,21 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macro}
%
% \begin{macro}[internal]
-% {\xeCJK_tl_remove_outer_braces:N,\xeCJK_tl_remove_outer_braces:n}
+% {\xeCJK_tl_remove_outer_braces:N,\xeCJK_tl_remove_outer_braces:n}
+% \changes{v3.2.4}{2013/07/02}{去掉外层分组括号时,移除空格,避免死循环。}
% 去掉 |#1| 外层的分组括号。
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_tl_remove_outer_braces:N #1
{ \tl_set:Nx #1 { \exp_args:NV \xeCJK_tl_remove_outer_braces:n #1 } }
\cs_new:Npn \xeCJK_tl_remove_outer_braces:n #1
- { \@@_tl_remove_outer_braces:w #1 \q_stop }
-\cs_new:Npn \@@_tl_remove_outer_braces:w #1 \q_stop
{
- \bool_if:nTF { \tl_if_single_p:n {#1} && \tl_if_head_is_group_p:n {#1} }
- { \@@_tl_remove_outer_braces:w #1 \q_stop }
+ \exp_last_unbraced:Nf
+ \@@_tl_remove_outer_braces:w { \tl_trim_spaces:n {#1} } \s__stop
+ }
+\cs_new:Npn \@@_tl_remove_outer_braces:w #1 \s__stop
+ {
+ \bool_if:nTF { \tl_if_single_p:n {#1} && ! ( \tl_if_head_is_N_type_p:n {#1} ) }
+ { \xeCJK_tl_remove_outer_braces:n {#1} }
{ \tl_trim_spaces:n {#1} }
}
% \end{macrocode}
@@ -1475,8 +1489,10 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macro}[internal]{\xeCJK_cs_clear:N,\xeCJK_cs_gclear:N}
% 让控制序列的意义为空。
% \begin{macrocode}
-\cs_new_eq:NN \xeCJK_cs_clear:N \tl_clear:N
-\cs_new_eq:NN \xeCJK_cs_gclear:N \tl_gclear:N
+\cs_new_protected:Npn \xeCJK_cs_clear:N #1
+ { \cs_set_eq:NN #1 \prg_do_nothing: }
+\cs_new_protected:Npn \xeCJK_cs_gclear:N #1
+ { \cs_gset_eq:NN #1 \prg_do_nothing: }
% \end{macrocode}
% \end{macro}
%
@@ -1617,6 +1633,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{ \@@_int_until_do:wn \use_none:n { \reverse_if:N \if_int_compare:w #1#2 } }
\cs_new_protected:Npn \@@_int_until_do:wn \use_none:n #1
{ #1 \exp_after:wN \@@_int_until_do:wn \fi: \use_none:n {#1} }
+\int_new:N \l_@@_begin_int
+\int_new:N \l_@@_end_int
% \end{macrocode}
%
% \end{macro}
@@ -1653,6 +1671,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\fi:
\fi:
}
+\tl_new:N \@@_peek_catcode_true:w
+\tl_new:N \@@_peek_catcode_false:w
\bool_new:N \l_@@_peek_ignore_spaces_bool
% \end{macrocode}
% \end{macro}
@@ -1689,24 +1709,33 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macro}
%
% \begin{macro}[internal]{\xeCJK_token_value_charcode:N}
-% \changes{v3.1.2}{2013/01/08}{考虑 \texttt{charcode} 大于等于 \texttt{0x10000} 的情况。}
+% \changes{v3.2.4}{2013/06/30}{考虑 \texttt{charcode} 超出 BMP 的情况。}
% 当记号 |#1| 的 \texttt{charcode} 大于等于 \texttt{0x10000} 时,\XeTeX\
% \texttt{0.9999.0} 版以前的 \cs{meaning} 的返回结果比较特殊\footnote{参见
% \url{http://tug.org/pipermail/xetex/2013-January/023967.html} 和
% \url{http://tex.stackexchange.com/a/64848}。},需要特别处理。同时使用较新版本中
-% 提供的原语设置 \texttt{mathcode}。
+% 提供的原语设置 \texttt{mathcode}。目前,\texttt{0.9999.0} 版以后的 \XeTeX 的
+% \cs{meaning} 对于超出 BMP 的字符,会返回两个字符,分别对应于其 UTF-16 编码的
+% 首尾代理。\footnote{参见 \url{http://tug.org/pipermail/xetex/2013-June/024543.html}。}
% \begin{macrocode}
\cs_new_nopar:Npn \xeCJK_token_value_charcode:N #1
{ \exp_after:wN \@@_token_value_charcode:w \token_to_meaning:N #1 \q_stop }
-\str_if_eq_x:nnTF { \token_to_str:N \Umathcode } { \token_to_meaning:N \Umathcode }
+\fp_compare:nNnTF { \int_use:N \xetex_XeTeXversion:D \XeTeXrevision } > { 0.9998 }
{
- \cs_new_nopar:Npn \@@_token_value_charcode:w #1 ~ #2 ~ #3 \q_stop
- { `#3 }
+ \cs_new_nopar:Npn \@@_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 \@@_token_value_charcode:w #1 ~ #2 ~ #3#4 \q_stop
- { \tl_if_empty:nTF {#4} { `#3 } { "20000 } }
+ { \int_eval:n { \tl_if_empty:nTF {#4} { `#3 } { "20000 } } }
\cs_new_eq:NN \xeCJK_xetex_mathcode:w \XeTeXmathcode
}
% \end{macrocode}
@@ -1814,7 +1843,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% 字符类名称对应的控制序列名字。
% \begin{macrocode}
\cs_new_nopar:Npn \@@_class_csname:n #1 { c_@@_#1_class_int }
-\cs_new_eq:cN { \@@_class_csname:n { Others } } \l_@@_tmpa_int
+\cs_new_eq:cN { \@@_class_csname:n { Others } } \l_@@_tmp_int
\@@_msg_new:nn { class-already-defined }
{
XeTeX~character~class~`#1'~has~been~already~defined.\\\\
@@ -1902,11 +1931,12 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[var,internal]{\c_@@_PO_chars_clist}
-% Postfix Numeric (PO)
-% \PrintPunctList{PO}{Postfix Numeric}
+% \begin{macro}[var,internal]{\c_@@_PR_chars_clist}
+% Prefix Numeric (PR)
+% \PrintPunctList{PR}{Prefix Numeric}
% \begin{macrocode}
-\clist_const:Nn \c_@@_PO_chars_clist { "FE6A , "FF05 , "FFE0 }
+\clist_const:Nn \c_@@_PR_chars_clist
+ { "20A9 , "FE69 , "FF04 , "FFE1 , "FFE5 , "FFE6 }
% \end{macrocode}
% \end{macro}
%
@@ -1916,7 +1946,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\clist_const:Nx \c_@@_FullLeft_chars_clist
{
\c_@@_OP_chars_clist ,
- \c_@@_PO_chars_clist
+ \c_@@_PR_chars_clist
}
% \end{macrocode}
% \end{macro}
@@ -1982,12 +2012,11 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[var,internal]{\c_@@_PR_chars_clist}
-% Prefix Numeric (PR)
-% \PrintPunctList{PR}{Prefix Numeric}
+% \begin{macro}[var,internal]{\c_@@_PO_chars_clist}
+% Postfix Numeric (PO)
+% \PrintPunctList{PO}{Postfix Numeric}
% \begin{macrocode}
-\clist_const:Nn \c_@@_PR_chars_clist
- { "20A9 , "FE69 , "FF04 , "FFE1 , "FFE5 , "FFE6 }
+\clist_const:Nn \c_@@_PO_chars_clist { "FE6A , "FF05 , "FFE0 }
% \end{macrocode}
% \end{macro}
%
@@ -2001,7 +2030,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\c_@@_EX_chars_clist ,
\c_@@_IS_chars_clist ,
\c_@@_CJ_chars_clist ,
- \c_@@_PR_chars_clist
+ \c_@@_PO_chars_clist
}
% \end{macrocode}
% \end{macro}
@@ -2219,10 +2248,10 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_declare_char_class:nn #1#2
{
- \clist_set:Nn \l_@@_tmpa_clist {#2}
+ \clist_set:Nn \l_@@_tmp_clist {#2}
\clist_gconcat:ccN
- { g_@@_#1_range_clist } { g_@@_#1_range_clist } \l_@@_tmpa_clist
- \clist_map_inline:Nn \l_@@_tmpa_clist
+ { g_@@_#1_range_clist } { g_@@_#1_range_clist } \l_@@_tmp_clist
+ \clist_map_inline:Nn \l_@@_tmp_clist
{
\str_if_eq:nnF {##1} { -> }
{
@@ -2264,12 +2293,12 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_set_char_class:nnn #1#2#3
{
- \@@_check_num_range:nnNN {#1} {#2} \l_@@_tmpa_int \l_@@_tmpb_int
- \int_set:Nn \l_@@_tmpc_int {#3}
- \xeCJK_int_until_do:nn { \l_@@_tmpa_int > \l_@@_tmpb_int }
+ \@@_check_num_range:nnNN {#1} {#2} \l_@@_begin_int \l_@@_end_int
+ \int_set:Nn \l_@@_tmp_int {#3}
+ \xeCJK_int_until_do:nn { \l_@@_begin_int > \l_@@_end_int }
{
- \XeTeXcharclass \l_@@_tmpa_int = \l_@@_tmpc_int
- \int_incr:N \l_@@_tmpa_int
+ \XeTeXcharclass \l_@@_begin_int = \l_@@_tmp_int
+ \int_incr:N \l_@@_begin_int
}
}
% \end{macrocode}
@@ -2282,9 +2311,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_set_char_class_eq:nn #1#2
{
- \int_set:Nn \l_@@_tmpa_int { \xeCJK_class_num:n {#2} }
+ \int_set:Nn \l_@@_tmp_int { \xeCJK_class_num:n {#2} }
\clist_map_inline:cn { c_@@_#1_chars_clist }
- { \XeTeXcharclass ##1 = \l_@@_tmpa_int }
+ { \XeTeXcharclass ##1 = \l_@@_tmp_int }
}
% \end{macrocode}
% \end{macro}
@@ -2386,9 +2415,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_copy_inter_class_toks:nnnn #1#2#3#4
{
- \tl_set:Nx \l_@@_tmpa_tl { \xeCJK_get_inter_class_toks:nn {#3} {#4} }
- \tl_if_empty:NF \l_@@_tmpa_tl
- { \xeCJK_inter_class_toks:nnx {#1} {#2} { \exp_not:V \l_@@_tmpa_tl } }
+ \tl_set:Nx \l_@@_tmp_tl { \xeCJK_get_inter_class_toks:nn {#3} {#4} }
+ \tl_if_empty:NF \l_@@_tmp_tl
+ { \xeCJK_inter_class_toks:nnx {#1} {#2} { \exp_not:V \l_@@_tmp_tl } }
}
% \end{macrocode}
% \end{macro}
@@ -2398,11 +2427,11 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_replace_inter_class_toks:nnnn #1#2#3#4
{
- \tl_set:Nx \l_@@_tmpa_tl { \xeCJK_get_inter_class_toks:nn {#1} {#2} }
- \tl_if_empty:NF \l_@@_tmpa_tl
+ \tl_set:Nx \l_@@_tmp_tl { \xeCJK_get_inter_class_toks:nn {#1} {#2} }
+ \tl_if_empty:NF \l_@@_tmp_tl
{
- \tl_replace_all:Nnn \l_@@_tmpa_tl {#3} {#4}
- \xeCJK_inter_class_toks:nnx {#1} {#2} { \exp_not:V \l_@@_tmpa_tl }
+ \tl_replace_all:Nnn \l_@@_tmp_tl {#3} {#4}
+ \xeCJK_inter_class_toks:nnx {#1} {#2} { \exp_not:V \l_@@_tmp_tl }
}
}
% \end{macrocode}
@@ -2564,32 +2593,46 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\clist_map_inline:nn { Default , HalfLeft , NormalSpace }
{
- \xeCJK_inter_class_toks:nnn { Boundary } {#1}
+ \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 } }
+ }
+% \end{macrocode}
+%
+% \begin{macro}[internal]{\xeCJK_Boundary_and_Default:}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \xeCJK_Boundary_and_Default:
+ {
+ \bool_if:nTF
{
+ \l_@@_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
{
- \l_@@_xecglue_bool &&
- \int_compare_p:nNn \etex_lastnodetype:D = \c_eleven &&
- \skip_if_eq_p:nn \tex_lastskip:D \c_xeCJK_space_skip_tl
+ \xeCJK_if_last_node_p:n { CJK } ||
+ \xeCJK_if_last_node_p:n { CJK-space }
}
+ { \xeCJK_remove_node: \CJKecglue } { ~ }
+ }
+ {
+ \bool_if:nTF
{
- \tex_unskip:D
- \bool_if:nTF
- {
- \xeCJK_if_last_node_p:n { CJK } ||
- \xeCJK_if_last_node_p:n { CJK-space }
- }
- { \CJKecglue } { ~ }
+ \xeCJK_if_last_node_p:n { CJK } ||
+ \xeCJK_if_last_node_p:n { CJK-nobreak }
}
+ { \xeCJK_remove_node: \CJKecglue }
{
- \xeCJK_if_last_node:nTF { CJK } { \CJKecglue }
- { \xeCJK_if_last_node:nT { CJK-space } { \@@_space_or_xecglue: } }
+ \xeCJK_if_last_node:nT { CJK-space }
+ { \xeCJK_remove_node: \xeCJK_space_or_xecglue: }
}
}
- \str_if_eq:nnF {#1} { NormalSpace }
- { \xeCJK_app_inter_class_toks:nnn { CJK } {#1} { \CJKecglue } }
}
% \end{macrocode}
+% \end{macro}
%
% \hypertarget{def-bound}{}
% \begin{macrocode}
@@ -2629,39 +2672,47 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\bool_if:nTF
{ \xeCJK_if_last_node_p:n { CJK } || \xeCJK_if_last_node_p:n { CJK-space } }
- { \CJKglue }
+ { \xeCJK_remove_node: \CJKglue }
{
- \bool_if:nTF
- {
- \xeCJK_if_last_node_p:n { default } ||
- \int_compare_p:nNn \etex_lastnodetype:D = \c_ten
- }
- { \CJKecglue }
+ \xeCJK_if_last_node:nTF { CJK-nobreak }
+ { \xeCJK_remove_node: \xeCJK_no_break: \CJKglue }
{
- \bool_if:nT
+ \bool_if:nTF
{
- \l_@@_xecglue_bool &&
- \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_@@_ecglue_skip )
+ \xeCJK_if_last_node_p:n { default } ||
+ \int_compare_p:nNn \etex_lastnodetype:D = \c_ten
}
+ { \xeCJK_remove_node: \CJKecglue }
{
- \tex_unskip:D
- \bool_if:nTF
+ \bool_if:nT
{
- \xeCJK_if_last_node_p:n { default-space } ||
- \int_compare_p:nNn \etex_lastnodetype:D = \c_ten ||
- \xeCJK_if_last_node_p:n { default }
+ \l_@@_xecglue_bool &&
+ \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_@@_ecglue_skip )
}
- { \CJKecglue }
{
+ \tex_unskip:D
\bool_if:nTF
{
- \xeCJK_if_last_node_p:n { CJK } ||
- \xeCJK_if_last_node_p:n { CJK-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_remove_node: \CJKecglue }
+ {
+ \bool_if:nTF
+ {
+ \xeCJK_if_last_node_p:n { CJK } ||
+ \xeCJK_if_last_node_p:n { CJK-space }
+ }
+ {
+ \xeCJK_remove_node:
+ \bool_if:NTF \l_@@_reserve_space_bool
+ { ~ } { \CJKglue }
+ }
+ { ~ }
}
- { \bool_if:NTF \l_@@_reserve_space_bool { ~ } { \CJKglue } }
- { ~ }
}
}
}
@@ -2681,6 +2732,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macro}
%
% \changes{v3.1.0}{2012/11/14}{删除多余的 \texttt{default-itcorr} 结点。}
+% \changes{v3.2.4}{2013/07/03}{尽量移除用作判断标志的 \cs{kern}。}
%
% \begin{macro}[internal]{\xeCJK_def_node:nn,\xeCJK_make_node:n}
% 用于判断插入的各种 |kern|。
@@ -2696,10 +2748,13 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\tex_kern:D - \use:c { c_@@_#1_node_dim }
\tex_kern:D \use:c { c_@@_#1_node_dim }
}
+\cs_new_protected_nopar:Npn \xeCJK_remove_node:
+ { \tex_unkern:D \tex_unkern:D }
\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 { CJK-nobreak } { 15 sp }
% \end{macrocode}
% \end{macro}
%
@@ -2732,19 +2787,19 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
xCJKecglue / true .code:n =
{
\bool_set_true:N \l_@@_xecglue_bool
- \cs_set_eq:NN \@@_space_or_xecglue: \CJKecglue
+ \cs_set_eq:NN \xeCJK_space_or_xecglue: \CJKecglue
} ,
xCJKecglue / false .code:n =
{
\bool_set_false:N \l_@@_xecglue_bool
- \cs_set_eq:NN \@@_space_or_xecglue: \c_space_tl
+ \cs_set_eq:NN \xeCJK_space_or_xecglue: \c_space_tl
} ,
xCJKecglue / unknown .code:n =
{
\bool_set_true:N \l_@@_xecglue_bool
\cs_set_protected_nopar:Npn \CJKecglue {#1}
\xeCJK_glue_to_skip:nN {#1} \l_@@_ecglue_skip
- \cs_set_eq:NN \@@_space_or_xecglue: \CJKecglue
+ \cs_set_eq:NN \xeCJK_space_or_xecglue: \CJKecglue
} ,
xCJKecglue .default:n = { true }
}
@@ -2782,24 +2837,26 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\xeCJK_peek_catcode_ignore_spaces:NTF \c_math_toggle_token
{
\bool_if:NTF \l_@@_peek_ignore_spaces_bool
- { \@@_space_or_xecglue: } { \CJKecglue }
+ { \xeCJK_space_or_xecglue: } { \CJKecglue }
}
{
\bool_if:NTF \l_@@_peek_ignore_spaces_bool
{
- \tex_unkern:D \tex_unkern:D
+ \xeCJK_remove_node:
{ \xeCJK_make_node:n { CJK-space } }
\bool_if:nT
{
\token_if_macro_p:N \l_peek_token ||
( \l_@@_reserve_space_bool &&
- \token_if_other_p:N \l_peek_token )
+ \token_if_letter_p:N \l_peek_token )
}
- { \@@_space_or_xecglue: }
+ { \xeCJK_space_or_xecglue: }
}
- { \cs_if_exist:NF \l_peek_token \exp_not:N }
+ { \@@_CJK_and_Boundary_aux: }
}
}
+\cs_new_protected_nopar:Npn \@@_CJK_and_Boundary_aux:
+ { \cs_if_exist:NF \l_peek_token \exp_not:N }
% \end{macrocode}
% \end{macro}
%
@@ -2997,8 +3054,6 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macro}
%
% \begin{macro}[internal]{\xeCJK_Boundary_and_FullLeft:N}
-% \changes{v3.2.0}{2013/05/22}{当全角左标点前面是 \texttt{hlist}、\texttt{none}、
-% \texttt{glue} 和 \texttt{penalty} 等节点时,压缩其左空白。}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_Boundary_and_FullLeft:N #1
{
@@ -3011,15 +3066,52 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\@@_punct_rule:NN \c_@@_left_tl {#1}
\CJKpunctsymbol {#1}
}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\@@_Boundary_and_FullLeft_glue:N}
+% \changes{v3.2.0}{2013/05/22}{当全角左标点前面是 \texttt{hlist}、\texttt{none}、
+% \texttt{glue} 和 \texttt{penalty} 等节点时,压缩其左空白。}
+% \changes{v3.2.4}{2013/07/03}{细化边界与全角左标点之间是否压缩空白的判断。}
+% \cs{etex_lastnodetype:D} 为 $1$ 表示 hlist node,在这里用来判断是否位于段首。基于
+% 正常情况下,\TeX 会在段落开头插入宽度为 \cs{parindent} 的水平盒子用于缩进。
+% $-1$ 表示 empty list,常出现在盒子的起始位置,在段落前使用 \cs{noindent} 就
+% 是这种情况。$11$ 表示 glue node,这里判断的目的是当全角左标点出现在 \LaTeX 表格
+% 的非 \texttt{p} 列行首时,能够对齐到单元格的边界。判断基于标准 \LaTeX 表格的
+% 列格式(\cs{@tabclassz})定义中,在 \texttt{l} 列和 \texttt{r} 列前为了防止
+% \cs{tabcolsep} 被无意 \cs{unskip} 掉,都加了 |\hskip1sp|,而 \texttt{c} 列前
+% 则有 \cs{hfil}。$13$ 表示 penalty node,这里判断的目的是全角左标点出现在 \LaTeX
+% 列表环境的 \cs{item} 后面时,能对齐到边界。判断基于 \cs{item} 的内部定义
+% \cs{@item} 对 \cs{everypar} 进行了修改,在这里起到影响作用的是
+% |\box\@labels \penalty\z@|。以上判断都比较粗略,暂时也没有想起更好的办法。
+% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_Boundary_and_FullLeft_glue:N #1
{
\int_case:nnn { \etex_lastnodetype:D }
{
- { \c_one } { \@@_zero_glue: }
- { \c_minus_one } { }
- { \c_eleven } { }
- { \c_thirteen } { }
+ { \c_one } { \@@_zero_glue: \use_none:n }
+ { \c_minus_one } { \use_none:n }
+ { \c_eleven }
+ {
+ \bool_if:nF
+ {
+ ! ( \skip_if_finite_p:n { \tex_lastskip:D } ) ||
+ \skip_if_eq_p:nn { \tex_lastskip:D } { 1 sp }
+ }
+ }
+ { \c_thirteen }
+ {
+ \int_compare:nNnTF \tex_lastpenalty:D = \c_zero
+ {
+ \tex_unpenalty:D
+ \int_compare:nNnTF \etex_lastnodetype:D = \c_one
+ { \tex_penalty:D \c_zero \use_none:n }
+ { \tex_penalty:D \c_zero \use:n }
+ }
+ { \use:n }
+ }
}
+ { \use:n }
{ \@@_punct_glue:NN \c_@@_left_tl {#1} }
}
% \end{macrocode}
@@ -3082,9 +3174,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\@@_punct_if_long:NTF {#1}
{ \CJKglue }
{
- \@@_punct_if_middle:NTF {#1}
- { \xeCJK_no_break: \@@_punct_glue:NN \c_@@_right_tl {#1} }
- { \xeCJK_no_break: \@@_zero_glue: }
+ \xeCJK_no_break:
+ \@@_punct_if_middle:NT {#1}
+ { \@@_punct_glue:NN \c_@@_right_tl {#1} }
}
}
\cs_new_eq:NN \@@_Default_and_FullRight_glue:N \@@_CJK_and_FullRight_glue:N
@@ -3126,14 +3218,43 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\xeCJK_get_punct_bounds:NN \c_@@_left_tl {#1}
\xeCJK_get_punct_kerning:oN \g_@@_last_punct_tl {#1}
- \@@_punct_kern:NN \g_@@_last_punct_tl {#1}
+ \xeCJK_punct_kern:NN \g_@@_last_punct_tl {#1}
\tl_gset:Nx \g_@@_last_punct_tl {#1}
- \@@_punct_break:
\CJKpunctsymbol {#1}
}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[internal]{\@@_punct_nobreak_kern:NN}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_punct_nobreak_kern:NN #1#2
+ {
+ \@@_punct_kern:NN #1#2
+ \xeCJK_no_break:
+ }
+\cs_new_eq:NN \xeCJK_punct_kern:NN \@@_punct_nobreak_kern:NN
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{v3.2.4}{2013/07/06}
+% {使用 \texttt{AllowBreakBetweenPuncts} 时,相应标点符号仍能与边界对齐。}
+%
+% \begin{macro}[internal]{\@@_punct_breakable_kern:NN}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_punct_breakable_kern:NN #1#2
+ {
+ \@@_punct_rule:NN \c_@@_right_tl #1
+ \@@_punct_hskip:n
+ {
+ \@@_use_punct_dim:nnn { kern } {#1} {#2} +
+ \@@_use_punct_dim:nnn { bound } { \c_@@_right_tl } {#1} +
+ \@@_use_punct_dim:nnn { bound } { \c_@@_left_tl } {#2}
+ }
+ \@@_punct_rule:NN \c_@@_left_tl #2
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}[internal]{\xeCJK_FullRight_and_FullRight:N}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_FullRight_and_FullRight:N #1
@@ -3256,20 +3377,19 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\NewDocumentCommand \xeCJKnobreak { }
{
- \int_zero:N \l_@@_tmpa_int
+ \bool_set_true:N \l_@@_tmp_bool
\int_while_do:nNnn \etex_lastnodetype:D = \c_eleven
{
- \int_if_even:nTF \l_@@_tmpa_int
+ \bool_if:NTF \l_@@_tmp_bool
{
- \int_incr:N \l_@@_tmpa_int
+ \bool_set_false:N \l_@@_tmp_bool
\skip_set_eq:NN \l_@@_tmp_skip \tex_lastskip:D
}
{ \skip_add:Nn \l_@@_tmp_skip \tex_lastskip:D }
\tex_unskip:D
}
\xeCJK_no_break:
- \int_if_even:nF \l_@@_tmpa_int
- { \skip_horizontal:N \l_@@_tmp_skip }
+ \bool_if:NF \l_@@_tmp_bool { \skip_horizontal:N \l_@@_tmp_skip }
}
% \end{macrocode}
% \end{macro}
@@ -3406,7 +3526,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\peek_catcode:NTF \c_math_toggle_token
{
\xeCJK_no_break: \@@_check_single_save:N #1
- \xeCJK_no_break: #2 #4
+ \xeCJK_make_node:n { CJK-nobreak } #2 #4
}
{ \@@_check_single_save:N #1 #2#3#4 }
}
@@ -3415,6 +3535,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
%
% \changes{v3.2.3}{2013/06/11}
% {解决 \texttt{CheckSingle} 选项与 \pkg{tablists} 宏包的冲突。}
+% \changes{v3.2.4}{2013/06/26}
+% {解决使用 \texttt{CheckSingle} 时,某些 \cs{CJKglue} 不能被正确加入的问题。}
%
% \begin{macro}[internal]{\xeCJK_check_single_cs:NNn}
% 在使用 \texttt{CheckSingle} 选项时,在 \package{tablists} 宏包定义的
@@ -3439,7 +3561,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{ \xeCJK_check_single_env:nnNn }
{
\xeCJK_no_break: \@@_check_single_save:N #1
- \xeCJK_no_break: #2
+ \xeCJK_make_node:n { CJK-nobreak } #2
}
{ \@@_check_single_save:N #1 #2#3 }
}
@@ -3716,9 +3838,15 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
AllowBreakBetweenPuncts .choice: ,
AllowBreakBetweenPuncts / true .code:n =
- { \cs_set_eq:NN \@@_punct_break: \xeCJK_allow_break: } ,
+ {
+ \bool_set_true:N \l_@@_punct_breakable_bool
+ \cs_set_eq:NN \xeCJK_punct_kern:NN \@@_punct_breakable_kern:NN
+ } ,
AllowBreakBetweenPuncts / false .code:n =
- { \cs_set_eq:NN \@@_punct_break: \xeCJK_no_break: } ,
+ {
+ \bool_set_false:N \l_@@_punct_breakable_bool
+ \cs_set_eq:NN \xeCJK_punct_kern:NN \@@_punct_nobreak_kern:NN
+ } ,
AllowBreakBetweenPuncts .default:n = { true } ,
KaiMingPunct .code:n = { \@@_set_special_punct:nn { mixed_width } {#1} } ,
KaiMingPunct+ .code:n = { \@@_add_special_punct:nn { mixed_width } {#1} } ,
@@ -3731,12 +3859,11 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
MiddlePunct- .code:n = { \@@_sub_special_punct:nn { middle } {#1} } ,
PunctWidth .tl_gset:N = \g_@@_punct_width_tl
}
+\bool_new:N \l_@@_punct_breakable_bool
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]
-% {\g_@@_special_punct_clist,\@@_set_special_punct:nn,
-% \@@_add_special_punct:nn, \@@_sub_special_punct:nn}
+% 相关选项定义的辅助函数。
% \begin{macrocode}
\clist_new:N \g_@@_special_punct_clist
\clist_gset:Nn \g_@@_special_punct_clist { mixed_width , long , middle }
@@ -3775,11 +3902,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
}
% \end{macrocode}
-% \end{macro}
%
-% \begin{macro}[pTF,internal]
-% {\@@_punct_if_right:N,\@@_punct_if_long:N,
-% \@@_punct_if_middle:N,\@@_punct_if_mixed_width:N}
+% 判断一个标点符号是否为全角右标点和长标点符号。
% \begin{macrocode}
\prg_new_conditional:Npnn \@@_punct_if_right:N #1 { p , T , F , TF }
{
@@ -3796,32 +3920,24 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
}
% \end{macrocode}
-% \end{macro}
%
-% \begin{macro}[internal]
-% {\@@_punct_dim_csname:nn,\@@_punct_dim_csname:nnn,\@@_punct_dim_csname:nnnn,
-% \@@_use_punct_dim:nnn,\@@_use_punct_dim:nn,
-% \@@_gset_punct_dim:nnx,\@@_gset_punct_dim:nnnx,\@@_gset_punct_dim:nnnnx}
% 一些用于记录的辅助函数。
% \begin{macrocode}
\cs_new_nopar:Npn \@@_punct_dim_csname:nn #1#2
- { g__\l_xeCJK_current_font_tl/\l_xeCJK_punct_style_tl/#1/#2/tl }
+ { c__\l_xeCJK_current_font_tl/\l_xeCJK_punct_style_tl/#1/#2/tl }
\cs_new_nopar:Npn \@@_punct_dim_csname:nnn
{ \@@_punct_dim_csname:nnnn { \l_xeCJK_punct_style_tl } }
\cs_new_nopar:Npn \@@_punct_dim_csname:nnnn #1#2#3#4
- { g__\l_xeCJK_current_font_tl/#1/#2/#3/#4/tl }
+ { c__\l_xeCJK_current_font_tl/#1/#2/#3/#4/tl }
\cs_new_nopar:Npn \@@_use_punct_dim:nn #1#2
{ \tl_use:c { \@@_punct_dim_csname:nn {#1} {#2} } }
\cs_new_nopar:Npn \@@_use_punct_dim:nnn #1#2#3
{ \tl_use:c { \@@_punct_dim_csname:nnn {#1} {#2} {#3} } }
\cs_new_protected_nopar:Npn \@@_gset_punct_dim:nnx #1#2#3
- { \tl_gset:cx { \@@_punct_dim_csname:nn {#1} {#2} } {#3} }
+ { \tl_const:cx { \@@_punct_dim_csname:nn {#1} {#2} } {#3} }
\cs_new_protected_nopar:Npn \@@_gset_punct_dim:nnnx #1#2#3#4
- { \tl_gset:cx { \@@_punct_dim_csname:nnn {#1} {#2} {#3} } {#4} }
-\cs_new_protected_nopar:Npn \@@_gset_punct_dim:nnnnx #1#2#3#4#5
- { \tl_gset:cx { \@@_punct_dim_csname:nnnn {#1} {#2} {#3} {#4} } {#5} }
+ { \tl_const:cx { \@@_punct_dim_csname:nnn {#1} {#2} {#3} } {#4} }
% \end{macrocode}
-% \end{macro}
%
% \changes{v3.1.0}{2012/11/14}{使用 \pkg{xtemplate} 宏包的机制来组织标点符号的处理。}
%
@@ -3908,8 +4024,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_punct_margin_process:NN #1#2
{
- \tl_set:Nx \l_@@_tmpa_tl { \@@_use_punct_dim:nnn { bound } {#1} {#2} }
- \tl_set:Nx \l_@@_tmpb_tl
+ \dim_set:Nn \l_@@_bound_dim { \@@_use_punct_dim:nnn { bound } {#1} {#2} }
+ \dim_set:Nn \l_@@_reverse_bound_dim
{
\@@_use_punct_dim:nnn { bound }
{ \xeCJK_reverse:nnn {#1} \c_@@_left_tl \c_@@_right_tl } {#2}
@@ -3952,17 +4068,20 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
{
\bool_if:NTF \l_@@_optimize_margin_bool
- { \dim_max:nn { \dim_min:nn \l_@@_tmpa_tl \l_@@_tmpb_tl } }
+ {
+ \dim_max:nn
+ { \dim_min:nn \l_@@_bound_dim \l_@@_reverse_bound_dim }
+ }
{ \use:n }
{
- \l_@@_tmp_dim - ( \l_@@_tmpb_tl )
+ \l_@@_tmp_dim - \l_@@_reverse_bound_dim
- ( \@@_use_punct_dim:nn { dimen } {#2} )
}
}
}
{
\bool_if:NTF \l_@@_optimize_margin_bool
- { \dim_min:nn { \l_@@_tmpa_tl } }
+ { \dim_min:nn { \l_@@_bound_dim } }
{ \use:n }
{
\@@_punct_if_middle:NTF {#2}
@@ -3972,7 +4091,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\fp_use:N \l_@@_middle_margin_ratio_fp
\etex_dimexpr:D
- ( \l_@@_tmpa_tl + \l_@@_tmpb_tl ) / \c_two
+ ( \l_@@_bound_dim + \l_@@_reverse_bound_dim ) / \c_two
\scan_stop:
}
}
@@ -3986,6 +4105,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
}
}
+\dim_new:N \l_@@_bound_dim
+\dim_new:N \l_@@_reverse_bound_dim
% \end{macrocode}
% \end{macro}
%
@@ -4015,10 +4136,10 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{ \use:c { l_@@_#1_margin_width_dim } }
{
\fp_use:c { l_@@_#1_margin_ratio_fp }
- \etex_dimexpr:D \l_@@_tmpa_tl \scan_stop:
+ \etex_dimexpr:D \l_@@_bound_dim \scan_stop:
}
\bool_if:NT \l_@@_add_min_bound_to_margin_bool
- { + \dim_min:nn \l_@@_tmpa_tl \l_@@_tmpb_tl }
+ { + \dim_min:nn \l_@@_bound_dim \l_@@_reverse_bound_dim }
}
% \end{macrocode}
% \end{macro}
@@ -4219,18 +4340,15 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{ \dim_eval:n { \@@_use_punct_dim:nn { width } {#1} - \l_@@_tmp_dim } }
\@@_punct_if_long:NT {#1}
{
- \seq_map_inline:Nn \g_@@_punct_style_seq
+ \@@_gset_punct_dim:nnnx { kern } {#1} {#1}
{
- \@@_gset_punct_dim:nnnnx {##1} { kern } {#1} {#1}
+ \bool_if:nTF
{
- \bool_if:nTF
- {
- \str_if_eq_p:nn {#1} { ^^^^2025 } ||
- \str_if_eq_p:nn {#1} { ^^^^2026 }
- }
- { \c_zero_dim }
- { - \dim_use:N \l_@@_tmp_dim }
+ \str_if_eq_p:nn {#1} { ^^^^2025 } ||
+ \str_if_eq_p:nn {#1} { ^^^^2026 }
}
+ { \c_zero_dim }
+ { - \dim_use:N \l_@@_tmp_dim }
}
}
}
@@ -4287,6 +4405,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{ \@@_error:nx { punct-style-unknown } { \l_keys_value_tl } }
}
}
+\tl_new:N \l_xeCJK_punct_style_tl
\tl_const:Nn \c_@@_punct_style_plain_tl { plain }
\@@_msg_new:nn { punct-style-unknown }
{
@@ -4404,77 +4523,85 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\xeCJK_glyph_if_exist:NTF {#1}
{ \@@_fallback_save_CJKsymbol:N {#1} }
- { { \xeCJK_fallback_loop:Nn {#1} { \l_xeCJK_family_tl/FallBack } } }
+ {
+ \xeCJK_class_group_begin:
+ \tl_set_eq:NN \l_@@_fallback_family_tl \l_xeCJK_family_tl
+ \xeCJK_fallback_loop:Nn {#1} { \l_@@_fallback_family_tl/FallBack }
+ \xeCJK_class_group_end:
+ }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}[internal]{\xeCJK_fallback_loop:Nn}
% \changes{v3.1.0}{2012/11/19}{调整备用字体的循环方式。}
-% \changes{v3.1.1}{2012/12/02}{修正备用字体的不正确警告。}
+% \changes{v3.2.4}{2013/06/30}
+% {使 \cs{CJKfamilydefault} 的 \texttt{FallBack} 设置全局可用。}
% 循环测试后备字体是否包含字符 |#1|。若后备字体中存在该字符或者再没有后备字体,则
-% 结束循环。
+% 结束循环。当前字体族没有备用字体时,使用 \cs{CJKfamilydefault} 的设置。
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_fallback_loop:Nn #1#2
{
\xeCJK_family_if_exist:xTF {#2}
{
\xeCJK_select_font:x {#2}
+ \tl_set:Nx \l_@@_fallback_family_tl {#2}
\xeCJK_glyph_if_exist:NTF {#1}
{ \@@_fallback_save_CJKsymbol:N {#1} }
- { \xeCJK_fallback_loop:Nn {#1} { #2/FallBack } }
+ { \xeCJK_fallback_loop:Nn {#1} { \l_@@_fallback_family_tl/FallBack } }
}
{
- \xeCJK_family_if_exist:xT { \l_xeCJK_family_tl/FallBack }
- { \@@_warning:nxx { fallback } {#1} {#2} }
- \@@_fallback_save_CJKsymbol:N {#1}
+ \str_if_eq_x:nnTF { \CJKfamilydefault } { \l_xeCJK_family_tl }
+ {
+ \use:x
+ {
+ \msg_warning:nnnnn { xeCJK } { missing-glyph }
+ { \l_@@_fallback_family_tl } {#1} { \int_to_hexadecimal:n { `#1 } }
+ }
+ \@@_fallback_save_CJKsymbol:N {#1}
+ }
+ {
+ \tl_set:Nx \l_xeCJK_family_tl { \CJKfamilydefault }
+ \xeCJK_fallback_loop:Nn {#1} { \l_xeCJK_family_tl }
+ }
}
}
-\@@_msg_new:nn { fallback }
+\@@_msg_new:nn { missing-glyph }
{
- CJKfamily~`#2'~
- ( \prop_get:No \g_@@_family_font_name_prop {#2} )~
- does~not~contain~glyph~`#1'~(U+\int_to_hexadecimal:n {`#1}).\\
+ CJKfamily~`\@@_msg_family_map:n {#1}'~
+ ( \prop_get:Nn \g_@@_family_font_name_prop {#1} )~
+ does~not~contain~glyph~`#2'~(U+#3).\\
}
-\bool_new:N \l_@@_fallback_first_bool
-\cs_generate_variant:Nn \prop_get:Nn { No }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setCJKfallbackfamilyfont}
% \begin{macrocode}
-\NewDocumentCommand \setCJKfallbackfamilyfont { m O{} m }
- {
- \clist_set:Nx \l_@@_tmpa_clist {#3}
- \int_compare:nNnTF { \clist_count:N \l_@@_tmpa_clist } > \c_one
- { \xeCJK_set_family_fallback:xxN {#1} {#2} \l_@@_tmpa_clist }
- { \xeCJK_set_family:xxx { #1/FallBack } {#2} {#3} }
- }
+\NewDocumentCommand \setCJKfallbackfamilyfont { m O { } m }
+ { \use:x { \xeCJK_set_family_fallback:nnn {#1} {#2} {#3} } }
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]{\xeCJK_set_family_fallback:nnN}
+% \begin{macro}[internal]{\xeCJK_set_family_fallback:nnn}
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \xeCJK_set_family_fallback:nnN #1#2#3
+\cs_new_protected_nopar:Npn \xeCJK_set_family_fallback:nnn #1#2#3
{
\group_begin:
\tl_set:Nn \l_@@_fallback_family_tl {#1}
\prop_get:NVNF \g_@@_family_font_name_prop
\l_@@_fallback_family_tl \l_@@_font_name_tl
{ \tl_clear:N \l_@@_font_name_tl }
- \clist_map_inline:Nn #3
+ \clist_map_inline:nn {#3}
{
\tl_put_right:Nn \l_@@_fallback_family_tl { /FallBack }
\@@_get_sub_features:Vn \l_@@_fallback_family_tl {##1}
- \clist_put_left:cn
- { l_@@_ \l_@@_fallback_family_tl _font_options_clist } {#2}
- \xeCJK_set_family:Vvv \l_@@_fallback_family_tl
- { l_@@_ \l_@@_fallback_family_tl _font_options_clist }
- { l_@@_ \l_@@_fallback_family_tl _font_name_tl }
+ \clist_put_left:Nn \l_@@_sub_font_options_clist {#2}
+ \xeCJK_set_family:VVV \l_@@_fallback_family_tl
+ \l_@@_sub_font_options_clist \l_@@_sub_font_name_tl
}
\group_end:
}
-\cs_generate_variant:Nn \xeCJK_set_family_fallback:nnN { xx }
+\tl_new:N \l_@@_fallback_family_tl
% \end{macrocode}
% \end{macro}
%
@@ -4519,6 +4646,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macrocode}
% \end{macro}
%
+% \changes{v3.2.4}{2013/07/02}{内部调整分区字体的设置方法。}
+%
% \begin{macro}[internal]{\xeCJK_new_sub_key:n,\g_@@_sub_key_seq}
% 用于定义 CJK 子区字体和备用字体的选项。
% \begin{macrocode}
@@ -4532,22 +4661,14 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\tl_if_blank:nTF {##1}
{
- \bool_set_false:c { l_@@_copy_#1_bool }
- \bool_set_false:c { l_@@_add_#1_bool }
+ \prop_clear:N \l_@@_sub_key_prop
\tl_put_right:Nn \l_@@_family_name_tl { /#1 }
+ \clist_remove_all:Nn \l_@@_font_options_clist {#1}
}
{
- \seq_put_right:Nn \l_@@_sub_key_seq {#1}
\str_if_eq:nnTF {##1} { * }
- {
- \bool_set_true:c { l_@@_copy_#1_bool }
- \bool_set_false:c { l_@@_add_#1_bool }
- }
- {
- \bool_set_false:c { l_@@_copy_#1_bool }
- \bool_set_true:c { l_@@_add_#1_bool }
- \@@_get_sub_features:nn {#1} {##1}
- }
+ { \prop_put:Nnn \l_@@_sub_key_prop {#1} { \q_no_value } }
+ { \@@_get_sub_features:nn {#1} {##1} }
}
} ,
#1 .default:n = { }
@@ -4556,37 +4677,41 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]{\@@_get_sub_features:nn,\@@_get_sub_features:wn}
+% \changes{v3.2.4}{2013/07/02}{改进获取分区字体属性的办法。}
+%
+% \begin{macro}[internal]{\@@_get_sub_features:nn,\@@_get_sub_features:w}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_get_sub_features:nn #1#2
{
- \tl_set:Nx \l_@@_tmpa_tl { \xeCJK_tl_remove_outer_braces:n {#2} }
+ \tl_set:Nx \l_@@_tmp_tl { \xeCJK_tl_remove_outer_braces:n {#2} }
\clist_clear:N \l_@@_sub_font_options_clist
- \tl_if_head_eq_meaning:VNTF \l_@@_tmpa_tl [ % ]
- {
- \exp_after:wN \@@_get_sub_features:wn \l_@@_tmpa_tl \c_empty_tl
- \tl_if_blank:VT \l_@@_sub_font_name_tl
- {
- \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_tmpa_tl
- \clist_clear:N \l_@@_sub_font_options_clist
- }
- }
- { \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_tmpa_tl }
- \tl_if_blank:VTF \l_@@_sub_font_name_tl
+ \exp_after:wN \@@_get_sub_features:w \l_@@_tmp_tl
+ \q_mark [ \q_nil ] \q_mark \q_stop
+ \tl_if_empty:NTF \l_@@_sub_font_name_tl
{ \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_font_name_tl }
{ \tl_replace_all:NnV \l_@@_sub_font_name_tl { * } \l_@@_font_name_tl }
- \clist_set_eq:cN { l_@@_#1_font_options_clist } \l_@@_sub_font_options_clist
- \tl_set_eq:cN { l_@@_#1_font_name_tl } \l_@@_sub_font_name_tl
+ \prop_put:Nnx \l_@@_sub_key_prop {#1}
+ {
+ { \exp_not:V \l_@@_sub_font_options_clist }
+ { \exp_not:V \l_@@_sub_font_name_tl }
+ }
}
-\cs_new_protected_nopar:Npn \@@_get_sub_features:wn [#1] #2
+\cs_new_protected_nopar:Npn \@@_get_sub_features:w #1 [#2] #3 \q_mark #4 \q_stop
{
- \clist_set:Nn \l_@@_sub_font_options_clist {#1}
- \str_if_eq:nnTF {#2} { \c_empty_tl }
- { \tl_set_eq:NN \l_@@_sub_font_name_tl \c_empty_tl }
- { \tl_set:Nn \l_@@_sub_font_name_tl {#2} }
+ \quark_if_nil:nTF {#2}
+ { \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_tmp_tl }
+ {
+ \tl_set:Nx \l_@@_sub_font_name_tl
+ { \xeCJK_tl_remove_outer_braces:n {#3} }
+ \tl_if_empty:NTF \l_@@_sub_font_name_tl
+ { \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_tmp_tl }
+ { \clist_set:Nn \l_@@_sub_font_options_clist {#2} }
+ }
}
+\tl_new:N \l_@@_sub_family_name_tl
+\tl_new:N \l_@@_sub_font_name_tl
+\clist_new:N \l_@@_sub_font_options_clist
\cs_generate_variant:Nn \@@_get_sub_features:nn { V }
-\cs_generate_variant:Nn \tl_if_head_eq_meaning:nNTF { V }
\cs_generate_variant:Nn \tl_replace_all:Nnn { NnV }
% \end{macrocode}
% \end{macro}
@@ -4652,24 +4777,26 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\int_gincr:N \g_@@_family_int
\prop_clear:N \l_@@_add_font_prop
+ \prop_clear:N \l_@@_sub_key_prop
\prop_map_inline:Nn \g_@@_features_id_prop
{
\tl_clear:c { l_@@_font_name_##1_tl }
\clist_clear:c { l_@@_font_feat_##1_clist }
}
\clist_clear:N \l_@@_fontspec_options_clist
- \seq_clear:N \l_@@_sub_key_seq
- \seq_map_inline:Nn \g_@@_sub_key_seq
- {
- \bool_set_false:c { l_@@_copy_##1_bool }
- \bool_set_false:c { l_@@_add_##1_bool }
- }
\bool_set_eq:NN \l_@@_auto_fake_bold_bool \g_@@_auto_fake_bold_bool
\bool_set_eq:NN \l_@@_auto_fake_slant_bool \g_@@_auto_fake_slant_bool
\fp_set_eq:NN \l_@@_embolden_factor_fp \g_@@_embolden_factor_fp
\fp_set_eq:NN \l_@@_slant_factor_fp \g_@@_slant_factor_fp
}
\int_new:N \g_@@_family_int
+\prop_new:N \l_@@_add_font_prop
+\prop_new:N \l_@@_sub_key_prop
+\clist_new:N \l_@@_fontspec_options_clist
+\bool_new:N \l_@@_auto_fake_bold_bool
+\bool_new:N \l_@@_auto_fake_slant_bool
+\fp_new:N \l_@@_embolden_factor_fp
+\fp_new:N \l_@@_slant_factor_fp
% \end{macrocode}
% \end{macro}
%
@@ -4683,11 +4810,11 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\tl_set:Nn \l_@@_family_name_tl {#1}
\clist_set:Nn \l_@@_font_options_clist {#2}
\tl_set:Nn \l_@@_font_name_tl {#3}
- \clist_concat:NNN \l_@@_font_features_clist
+ \clist_concat:NNN \l_@@_font_options_clist
\g_@@_default_features_clist \l_@@_font_options_clist
- \@@_remove_duplicate_keys:N \l_@@_font_features_clist
+ \@@_remove_duplicate_keys:N \l_@@_font_options_clist
\keys_set_known:nVN { xeCJK / features }
- \l_@@_font_features_clist \l_@@_fontspec_options_clist
+ \l_@@_font_options_clist \l_@@_fontspec_options_clist
\@@_parse_features:
\@@_pass_features:
\@@_check_family:V \l_@@_family_name_tl
@@ -4696,7 +4823,12 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\@@_set_sub_block_family:
\group_end:
}
-\cs_generate_variant:Nn \xeCJK_set_family:nnn { Vnn , xxx , Vvv }
+\tl_new:N \l_@@_family_name_tl
+\tl_new:N \l_@@_font_name_tl
+\clist_new:N \l_@@_font_options_clist
+\cs_generate_variant:Nn \xeCJK_set_family:nnn { Vnn , VVV , Voo }
+\cs_new_protected_nopar:Npn \xeCJK_set_family:xxx #1#2#3
+ { \use:x { \xeCJK_set_family:nnn {#1} {#2} {#3} } }
% \end{macrocode}
% \end{macro}
%
@@ -4704,21 +4836,26 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_remove_duplicate_keys:N #1
{
- \prop_clear:N \l_@@_tmp_prop
+ \prop_clear:N \l_@@_font_options_prop
\keyval_parse:NNV \@@_prop_put_aux:n \@@_prop_put_aux:nn #1
\clist_clear:N #1
- \prop_map_inline:Nn \l_@@_tmp_prop
+ \prop_map_inline:Nn \l_@@_font_options_prop
{
- \tl_if_blank:nTF {##2}
- { \clist_put_right:Nn #1 {##1} }
- { \clist_put_right:Nn #1 { ##1 = {##2} } }
+ \tl_set:No \l_@@_tmp_tl { \use_ii:nn ##2 }
+ \tl_if_blank:VTF \l_@@_tmp_tl
+ { \clist_put_right:No #1 { \use_i:nn ##2 } }
+ {
+ \clist_put_right:Nx #1
+ { \exp_not:o { \use_i:nn ##2 } = { \exp_not:V \l_@@_tmp_tl } }
+ }
}
}
+\prop_new:N \l_@@_font_options_prop
\cs_generate_variant:Nn \keyval_parse:NNn { NNV }
\cs_new_protected_nopar:Npn \@@_prop_put_aux:n #1
- { \prop_put:Nnn \l_@@_tmp_prop {#1} { } }
+ { \prop_put:Nnn \l_@@_font_options_prop {#1} { {#1} { } } }
\cs_new_protected_nopar:Npn \@@_prop_put_aux:nn #1#2
- { \prop_put:Nnn \l_@@_tmp_prop {#1} {#2} }
+ { \prop_put:Nnn \l_@@_font_options_prop {#1} { {#1} {#2} } }
% \end{macrocode}
% \end{macro}
%
@@ -4737,6 +4874,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\group_end:
}
}
+\tl_new:N \l_@@_fontspec_family_tl
% \end{macrocode}
% \end{macro}
%
@@ -4744,11 +4882,11 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_check_family:n #1
{
- \prop_get:NnNT \g_@@_family_font_name_prop {#1} \l_@@_tmpa_tl
+ \prop_get:NnNT \g_@@_family_font_name_prop {#1} \l_@@_tmp_tl
{
- \prop_gpop:NnNT \g_@@_family_name_prop {#1} \l_@@_tmpa_tl
+ \prop_gpop:NnNT \g_@@_family_name_prop {#1} \l_@@_tmp_tl
{ \cs_undefine:c { \@@_family_nfss_csname:n {#1} } }
- \@@_warning:nxx { CJKfamily-redef } {#1} { \l_@@_tmpa_tl }
+ \@@_warning:nxx { CJKfamily-redef } {#1} { \l_@@_tmp_tl }
}
}
\cs_generate_variant:Nn \@@_check_family:n { V }
@@ -4923,8 +5061,6 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\cs_new_protected_nopar:Npn \@@_save_family_info:
{
\group_begin:
- \seq_map_inline:Nn \g_@@_CJK_sub_class_seq
- { \clist_remove_all:Nn \l_@@_font_options_clist {##1} }
\prop_gput:NVV \g_@@_family_font_name_prop
\l_@@_family_name_tl \l_@@_font_name_tl
\prop_gput:NVV \g_@@_family_font_options_prop
@@ -4938,42 +5074,44 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_set_sub_block_family:
{
- \seq_map_inline:Nn \l_@@_sub_key_seq
+ \prop_map_inline:Nn \l_@@_sub_key_prop
{
- \tl_set:Nx \l_@@_sub_family_tl { \l_@@_family_name_tl/##1 }
- \bool_if:cT { l_@@_copy_##1_bool } { \@@_copy_sub_family:n {##1} }
- \bool_if:cT { l_@@_add_##1_bool }
+ \tl_set:Nx \l_@@_sub_family_name_tl { \l_@@_family_name_tl/##1 }
+ \quark_if_no_value:nTF {##2}
+ { \@@_copy_sub_family:n {##1} }
{
- \xeCJK_set_family:Vvv \l_@@_sub_family_tl
- { l_@@_##1_font_options_clist } { l_@@_##1_font_name_tl }
+ \xeCJK_set_family:Voo \l_@@_sub_family_name_tl
+ { \use_i:nn ##2 } { \use_ii:nn ##2 }
}
}
}
\cs_new_protected_nopar:Npn \@@_copy_sub_family:n #1
{
- \@@_check_family:V \l_@@_sub_family_tl
+ \@@_check_family:V \l_@@_sub_family_name_tl
\prop_get:NVNT \g_@@_family_font_name_prop
- \l_@@_family_name_tl \l_@@_tmpa_tl
+ \l_@@_family_name_tl \l_@@_sub_font_name_tl
{
\prop_gput:NVV \g_@@_family_font_name_prop
- \l_@@_sub_family_tl \l_@@_tmpa_tl
+ \l_@@_sub_family_name_tl \l_@@_sub_font_name_tl
}
\prop_get:NVNT \g_@@_family_font_options_prop
- \l_@@_family_name_tl \l_@@_tmpa_clist
+ \l_@@_family_name_tl \l_@@_sub_font_options_clist
{
- \clist_remove_all:Nn \l_@@_tmpa_clist { #1 = * }
+ \clist_remove_all:Nn \l_@@_sub_font_options_clist { #1 = * }
\prop_gput:NVV \g_@@_family_font_options_prop
- \l_@@_sub_family_tl \l_@@_tmpa_clist
+ \l_@@_sub_family_name_tl \l_@@_sub_font_options_clist
}
- \cs_gset_protected_nopar:cpx { \@@_family_csname:n { \l_@@_sub_family_tl } }
+ \cs_gset_protected_nopar:cpx
+ { \@@_family_csname:n { \l_@@_sub_family_name_tl } }
{
\xeCJK_family_if_exist:xT { \l_@@_family_name_tl }
{
\prop_get:NnNT \exp_not:N \g_@@_family_name_prop
- { \l_@@_family_name_tl } \exp_not:N \l_@@_tmpa_tl
+ { \l_@@_family_name_tl } \exp_not:N \l_@@_fontspec_family_tl
{
\@@_gset_family_nfss_cs:xx
- { \l_@@_sub_family_tl } { \exp_not:N \l_@@_tmpa_tl }
+ { \l_@@_sub_family_name_tl }
+ { \exp_not:N \l_@@_fontspec_family_tl }
}
}
}
@@ -4994,8 +5132,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\g_@@_family_font_options_prop
}
{
- \prop_get:NnNT ##1 {#2} \l_@@_tmpa_tl
- { \prop_gput:NnV ##1 {#1} \l_@@_tmpa_tl }
+ \prop_get:NnNT ##1 {#2} \l_@@_tmp_tl
+ { \prop_gput:NnV ##1 {#1} \l_@@_tmp_tl }
}
\cs_gset_eq:cc
{ \@@_family_nfss_csname:n {#1} }
@@ -5032,6 +5170,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\xeCJK_font_gset_to_current:c { \l_@@_current_coor_tl }
}
}
+\tl_new:N \l_@@_current_coor_tl
\cs_new_eq:NN \xeCJK@setfont \xeCJK_select_font:
% \end{macrocode}
% \end{macro}
@@ -5138,6 +5277,15 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
\tex_ignorespaces:D
}
+\cs_new_protected_nopar:Npn \xeCJK_switch_family:n #1
+ {
+ \xeCJK_family_if_exist:xTF {#1}
+ {
+ \tl_set:Nx \l_xeCJK_family_tl {#1}
+ \tl_set_eq:NN \xeCJK@family \l_xeCJK_family_tl
+ }
+ { \@@_family_unknown_warning:x {#1} }
+ }
% \end{macrocode}
% \end{macro}
%
@@ -5218,18 +5366,18 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% 设置文档的 CJK 普通字体、无衬线和等宽字体。
% \changes{v3.2.0}{2013/04/14}{定义中加入 \cs{normalfont}。}
% \begin{macrocode}
-\NewDocumentCommand \setCJKmainfont { O{} m }
+\NewDocumentCommand \setCJKmainfont { O { } m }
{
\xeCJK_set_family:xxx { \CJKrmdefault } {#1} {#2}
\normalfont
}
\cs_new_eq:NN \setCJKromanfont \setCJKmainfont
-\NewDocumentCommand \setCJKsansfont { O{} m }
+\NewDocumentCommand \setCJKsansfont { O { } m }
{
\xeCJK_set_family:xxx { \CJKsfdefault } {#1} {#2}
\normalfont
}
-\NewDocumentCommand \setCJKmonofont { O{} m }
+\NewDocumentCommand \setCJKmonofont { O { } m }
{
\xeCJK_set_family:xxx { \CJKttdefault } {#1} {#2}
\normalfont
@@ -5248,17 +5396,17 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macro}{\setCJKfamilyfont, \newCJKfontfamily, \CJKfontspec}
% 分别用于预声明 CJK 字体和随机调用 CJK 字体。
% \begin{macrocode}
-\NewDocumentCommand \setCJKfamilyfont { m O{} m }
+\NewDocumentCommand \setCJKfamilyfont { m O { } m }
{ \xeCJK_set_family:xxx {#1} {#2} {#3} }
-\NewDocumentCommand \newCJKfontfamily { o m O{} m }
+\NewDocumentCommand \newCJKfontfamily { o m O { } m }
{
- \tl_set:Nx \l_@@_tmpa_tl { \IfNoValueTF {#1} { \cs_to_str:N #2 } {#1} }
- \cs_new_protected_nopar:Npx #2 { \CJKfamily { \l_@@_tmpa_tl } }
- \xeCJK_set_family:xxx { \l_@@_tmpa_tl } {#3} {#4}
+ \tl_set:Nx \l_@@_tmp_tl { \IfNoValueTF {#1} { \cs_to_str:N #2 } {#1} }
+ \cs_new_protected_nopar:Npx #2 { \xeCJK_switch_family:n { \l_@@_tmp_tl } }
+ \xeCJK_set_family:xxx { \l_@@_tmp_tl } {#3} {#4}
}
-\NewDocumentCommand \CJKfontspec { O{} m }
+\NewDocumentCommand \CJKfontspec { O { } m }
{
- \xeCJK_fontspec:xx {#1} {#2}
+ \use:x { \xeCJK_fontspec:nn {#1} {#2} }
\tex_ignorespaces:D
}
% \end{macrocode}
@@ -5268,56 +5416,89 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_fontspec:nn #1#2
{
- \tl_set:Nx \l_@@_tmpa_tl { \tl_to_str:n { CJKfontspec/#1/#2/id } }
- \tl_if_exist:cF { \l_@@_tmpa_tl }
+ \prop_get:NnNTF \g_@@_fontspec_prop
+ { CJKfontspec/#1/#2/id } \l_xeCJK_family_tl
+ { \tl_set_eq:NN \xeCJK@family \l_xeCJK_family_tl }
{
- \tl_set:Nx \l_@@_tmpb_tl
+ \@@_fontspec:xnn
{ CJKfontspec ( \int_eval:n { \g_@@_family_int + \c_one } ) }
- \tl_gset_eq:cN { \l_@@_tmpa_tl } \l_@@_tmpb_tl
- \xeCJK_set_family:Vnn \l_@@_tmpb_tl {#1} {#2}
+ {#1} {#2}
}
- \exp_args:Nc \CJKfamily { \l_@@_tmpa_tl }
}
-\cs_generate_variant:Nn \xeCJK_fontspec:nn { VV , xx }
+\cs_new_protected_nopar:Npn \@@_fontspec:nnn #1#2#3
+ {
+ \prop_gput:Nnn \g_@@_fontspec_prop { CJKfontspec/#2/#3/id } {#1}
+ \xeCJK_set_family:nnn {#1} {#2} {#3}
+ \xeCJK_switch_family:n {#1}
+ }
+\cs_generate_variant:Nn \xeCJK_fontspec:nn { VV }
+\cs_generate_variant:Nn \@@_fontspec:nnn { x }
+\prop_new:N \g_@@_fontspec_prop
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\defaultCJKfontfeatures, \addCJKfontfeatures}
+% \changes{v3.2.4}{2013/06/30}{可以单独增加当前各个分区字体的属性。}
% 分别用于设置 CJK 字体的默认属性和增加当前 CJK 字体的属性。
% \begin{macrocode}
\clist_new:N \g_@@_default_features_clist
\NewDocumentCommand \defaultCJKfontfeatures { m }
{ \clist_gset:Nn \g_@@_default_features_clist {#1} }
\@onlypreamble \defaultCJKfontfeatures
-\NewDocumentCommand \addCJKfontfeatures { m }
+\NewDocumentCommand \addCJKfontfeatures { s O { } m }
{
- \xeCJK_add_font_features:x {#1}
+ \xeCJK_add_font_features:Nxx #1 {#2} {#3}
\tex_ignorespaces:D
}
\cs_new_eq:NN \addCJKfontfeature \addCJKfontfeatures
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]{\xeCJK_add_font_features:n}
+% \begin{macro}[internal]{\xeCJK_add_font_features:Nnn}
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \xeCJK_add_font_features:n #1
+\cs_new_protected_nopar:Npn \xeCJK_add_font_features:Nnn #1#2#3
{
- \prop_get:NVNTF \g_@@_family_font_name_prop \l_xeCJK_family_tl \l_@@_tmpa_tl
+ \prop_get:NVNTF \g_@@_family_font_name_prop
+ \l_xeCJK_family_tl \l_@@_font_name_tl
{
- \clist_set:Nn \l_@@_tmpa_clist {#1}
- \seq_map_function:NN
- \g_@@_CJK_sub_class_seq \@@_parse_sub_class_features:n
+ \clist_set:Nn \l_@@_add_font_features_clist {#3}
+ \seq_map_inline:Nn \g_@@_sub_key_seq
+ { \clist_remove_all:Nn \l_@@_add_font_features_clist {##1} }
+ \seq_clear:N \l_@@_sub_key_seq
+ \clist_clear:N \l_@@_add_block_features_clist
+ \clist_map_inline:nn {#2}
+ {
+ \seq_if_in:NnTF \g_@@_sub_key_seq {##1}
+ {
+ \seq_put_right:Nn \l_@@_sub_key_seq {##1}
+ \@@_add_sub_class_features:n {##1}
+ }
+ { \@@_warning:nx { SubBlock-undefined } {##1} }
+ }
+ \bool_if:nT { #1 && \seq_if_empty_p:N \l_@@_sub_key_seq }
+ {
+ \seq_map_function:NN
+ \g_@@_sub_key_seq \@@_add_sub_class_features:n
+ }
\prop_get:NVNT \g_@@_family_font_options_prop
- \l_xeCJK_family_tl \l_@@_tmpb_clist
+ \l_xeCJK_family_tl \l_@@_font_options_clist
{
- \clist_concat:NNN
- \l_@@_tmpa_clist \l_@@_tmpb_clist \l_@@_tmpa_clist
+ \bool_if:nT
+ { \seq_if_empty_p:N \l_@@_sub_key_seq || #1 }
+ {
+ \clist_concat:NNN \l_@@_font_options_clist
+ \l_@@_font_options_clist \l_@@_add_font_features_clist
+ }
+ \clist_concat:NNN \l_@@_font_options_clist
+ \l_@@_font_options_clist \l_@@_add_block_features_clist
}
- \xeCJK_fontspec:VV \l_@@_tmpa_clist \l_@@_tmpa_tl
+ \xeCJK_fontspec:VV \l_@@_font_options_clist \l_@@_font_name_tl
}
{ \@@_warning:n { addCJKfontfeature-ignored } }
}
-\cs_generate_variant:Nn \xeCJK_add_font_features:n { x }
+\clist_new:N \l_@@_add_font_features_clist
+\clist_new:N \l_@@_add_block_features_clist
+\cs_generate_variant:Nn \xeCJK_add_font_features:Nnn { Nxx , Nnx }
\@@_msg_new:nn { addCJKfontfeature-ignored }
{
\token_to_str:N \addCJKfontfeature (s)~ignored.\\\\
@@ -5326,26 +5507,42 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]{\@@_parse_sub_class_features:n}
+% \begin{macro}[internal]{\@@_add_sub_class_features:n}
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_parse_sub_class_features:n #1
+\cs_new_protected_nopar:Npn \@@_add_sub_class_features:n #1
{
- \clist_if_in:NnT \l_@@_tmpa_clist {#1}
+ \prop_get:NoNTF \g_@@_family_font_name_prop
+ { \l_xeCJK_family_tl/#1 } \l_@@_sub_font_name_tl
+ {
+ \prop_get:NoN \g_@@_family_font_options_prop
+ { \l_xeCJK_family_tl/#1 } \l_@@_sub_font_options_clist
+ }
+ {
+ \prop_get:NxNTF \g_@@_family_font_name_prop
+ { \CJKfamilydefault/#1 } \l_@@_sub_font_name_tl
+ {
+ \prop_get:NxN \g_@@_family_font_options_prop
+ { \CJKfamilydefault/#1 } \l_@@_sub_font_options_clist
+ }
+ {
+ \prop_get:NVN \g_@@_family_font_options_prop
+ \l_xeCJK_family_tl \l_@@_sub_font_options_clist
+ \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_font_name_tl
+ }
+ }
+ \clist_concat:NNN \l_@@_sub_font_options_clist
+ \l_@@_sub_font_options_clist \l_@@_add_font_features_clist
+ \clist_put_right:Nx \l_@@_add_block_features_clist
{
- \clist_remove_all:Nn \l_@@_tmpa_clist {#1}
- \prop_get:NoNF \g_@@_family_font_name_prop
- { \l_xeCJK_family_tl/#1 } \l_@@_tmpb_tl
+ #1 =
{
- \prop_get:NxNF \g_@@_family_font_name_prop
- { \CJKfamilydefault/#1 } \l_@@_tmpb_tl
- { \tl_set_eq:NN \l_@@_tmpb_tl \l_@@_tmpa_tl }
+ [ \exp_not:V \l_@@_sub_font_options_clist ]
+ { \exp_not:V \l_@@_sub_font_name_tl }
}
- \clist_set:Nx \l_@@_tmpa_clist
- { #1 = { [ \exp_not:V \l_@@_tmpa_clist ] { \exp_not:V \l_@@_tmpb_tl } } }
- \clist_map_break:
}
}
-\cs_generate_variant:Nn \prop_get:NnNF { Nx }
+\cs_generate_variant:Nn \prop_get:NnN { Nx }
+\cs_generate_variant:Nn \prop_get:NnNTF { Nx }
% \end{macrocode}
% \end{macro}
%
@@ -5379,7 +5576,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\xeCJK_family_if_exist:xF { \CJKfamilydefault }
{
- \tl_set_eq:NN \l_@@_tmpa_tl \CJKfamilydefault
+ \tl_set_eq:NN \l_@@_tmp_tl \CJKfamilydefault
\str_if_eq_x:nnTF { \CJKfamilydefault } { \CJKrmdefault }
{ \use:n }
{
@@ -5388,12 +5585,15 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
{
\prop_map_inline:Nn \g_@@_family_font_name_prop
- { \prop_map_break:n { \tl_gset:Nn \CJKfamilydefault {#1} } }
+ {
+ \prop_map_break:n
+ { \tl_gset_rescan:Nnn \CJKfamilydefault { } {#1} }
+ }
}
\@@_warning:nxx { CJKfamilydefault-undefined }
- { \l_@@_tmpa_tl } { \CJKfamilydefault }
+ { \l_@@_tmp_tl } { \CJKfamilydefault }
}
- \CJKfamily { \CJKfamilydefault }
+ \xeCJK_switch_family:n { \CJKfamilydefault }
\bool_if:NT \g_@@_math_bool { \xeCJK_set_mathfont: }
}
}
@@ -5424,7 +5624,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macro}{\setCJKmathfont}
% 设置 CJK 数学字体。
% \begin{macrocode}
-\NewDocumentCommand \setCJKmathfont { O{} m }
+\NewDocumentCommand \setCJKmathfont { O { } m }
{ \xeCJK_set_family:xxx { \c_@@_math_tl } {#1} {#2} }
\tl_const:Nn \c_@@_math_tl { CJKmath }
% \end{macrocode}
@@ -5436,25 +5636,25 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\cs_new_protected_nopar:Npn \xeCJK_set_mathfont:
{
\xeCJK_family_if_exist:xTF { \c_@@_math_tl }
- { \tl_set:Nx \l_@@_tmpa_tl { \c_@@_math_tl } }
+ { \tl_set:Nx \l_@@_tmp_tl { \c_@@_math_tl } }
{
\xeCJK_family_if_exist:xTF { \CJKfamilydefault }
- { \tl_set:Nx \l_@@_tmpa_tl { \CJKfamilydefault } }
+ { \tl_set:Nx \l_@@_tmp_tl { \CJKfamilydefault } }
{ \use_none:nnnnn }
}
- \prop_get:NVNT \g_@@_family_name_prop \l_@@_tmpa_tl \l_@@_tmpb_tl
+ \prop_get:NVNT \g_@@_family_name_prop \l_@@_tmp_tl \l_@@_tmp_tl
{
- \tl_const:Nx \c_@@_math_family_tl { \l_@@_tmpb_tl }
+ \tl_const:Nx \c_@@_math_family_tl { \l_@@_tmp_tl }
\DeclareSymbolFont \c_@@_math_tl
\c_@@_encoding_tl \c_@@_math_family_tl \mddefault \shapedefault
\SetSymbolFont \c_@@_math_tl { bold }
\c_@@_encoding_tl \c_@@_math_family_tl \bfdefault \shapedefault
\int_const:Nn \c_xeCJK_math_fam_int { \use:c { sym \c_@@_math_tl } }
- \clist_concat:NNN
- \l_@@_tmpa_clist \c_@@_CJK_chars_clist \c_@@_FullLeft_chars_clist
- \clist_concat:NNN
- \l_@@_tmpa_clist \l_@@_tmpa_clist \c_@@_FullRight_chars_clist
- \clist_map_inline:Nn \l_@@_tmpa_clist
+ \clist_concat:NNN \l_@@_tmp_clist
+ \c_@@_CJK_chars_clist \c_@@_FullLeft_chars_clist
+ \clist_concat:NNN \l_@@_tmp_clist
+ \l_@@_tmp_clist \c_@@_FullRight_chars_clist
+ \clist_map_inline:Nn \l_@@_tmp_clist
{
\@@_set_char_class_aux:Nnw \xeCJK_gset_mathcode:nnnn {##1}
{ \c_seven } { \c_xeCJK_math_fam_int }
@@ -5468,12 +5668,12 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xeCJK_gset_mathcode:nnnn #1#2#3#4
{
- \@@_check_num_range:nnNN {#1} {#2} \l_@@_tmpa_int \l_@@_tmpb_int
- \xeCJK_int_until_do:nn { \l_@@_tmpa_int > \l_@@_tmpb_int }
+ \@@_check_num_range:nnNN {#1} {#2} \l_@@_begin_int \l_@@_end_int
+ \xeCJK_int_until_do:nn { \l_@@_begin_int > \l_@@_end_int }
{
\tex_global:D \xeCJK_xetex_mathcode:w
- \l_@@_tmpa_int = #3 ~ #4 \l_@@_tmpa_int
- \int_incr:N \l_@@_tmpa_int
+ \l_@@_begin_int = #3 ~ #4 \l_@@_begin_int
+ \int_incr:N \l_@@_begin_int
}
}
% \end{macrocode}
@@ -5499,7 +5699,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
Verb / true .code:n = { \int_set_eq:NN \l_@@_verb_case_int \c_zero } ,
Verb / env .code:n = { \int_set_eq:NN \l_@@_verb_case_int \c_one } ,
Verb / env+ .code:n = { \int_set_eq:NN \l_@@_verb_case_int \c_two } ,
- Verb / false .code:n = { \int_set_eq:NN \l_@@_verb_case_int \c_three }
+ Verb / false .code:n = { \int_set_eq:NN \l_@@_verb_case_int \c_three } ,
+ Verb .default:n = { env }
}
\int_new:N \l_@@_verb_case_int
\@@_after_preamble:n
@@ -5589,9 +5790,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
\xeCJKsetup { xCJKecglue = false }
\cs_set_protected_nopar:Npn \CJKglue
- { \skip_horizontal:N \g_@@_verb_exspace_skip }
+ { \skip_horizontal:N \l_@@_verb_exspace_skip }
\cs_set_protected_nopar:Npn \CJKecglue
- { \skip_horizontal:n { 0.5 \g_@@_verb_exspace_skip } }
+ { \skip_horizontal:n { 0.5 \l_@@_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 }
@@ -5599,9 +5800,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
\cs_new_protected_nopar:Npn \@@_reset_char_class:n #1
{
- \int_set:Nn \l_@@_tmpa_int { \xeCJK_class_num:n {#1} }
+ \int_set:Nn \l_@@_tmp_int { \xeCJK_class_num:n {#1} }
\clist_map_inline:cn { c_@@_#1_chars_clist }
- { \XeTeXcharclass ##1 = \l_@@_tmpa_int }
+ { \XeTeXcharclass ##1 = \l_@@_tmp_int }
}
\bool_new:N \l_@@_verb_addon_bool
\cs_new_eq:NN \CJKfixedspacing \xeCJKVerbAddon
@@ -5610,36 +5811,86 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
%
% \begin{macro}[internal]{\@@_set_verb_exspace:}
% \changes{v3.1.1}{2012/12/08}{调整间距的计算方法。}
+% \changes{v3.2.4}{2013/06/29}{当计算得出的间距为负时,缩小 CJK 字体。}
% 在抄录环境中,CJK 文字之间的间距为当前西文字体两个空格的宽度与当前字体大小之差,
-% 而与西文和空格的间距为 CJK 文字之间的间距的一半。这里的问题是,
-% \cs{g_@@_verb_exspace_skip} 有可能为负么?现在的处理是保证它非负。如果真的出现
-% 负间距的情况,也可以像下面对后备可视空格符号一样,在 \cs{xeCJK_select_font:} 里
-% 对 CJK 文字的字体大小做调整,并让间距为零。
+% 而与西文和空格的间距为 CJK 文字之间的间距的一半。
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_set_verb_exspace:
{
- \tl_if_exist:cF { xeCJK/verb/\l_xeCJK_family_tl/\curr@fontshape/\f@size }
+ \tl_if_exist:cTF { xeCJK/verb/\l_xeCJK_family_tl/\curr@fontshape/\f@size }
{
- \group_begin:
- \xeCJK_select_font:
+ \skip_set:Nn \l_@@_verb_exspace_skip
+ { \use:c { xeCJK/verb/\l_xeCJK_family_tl/\curr@fontshape/\f@size } }
+ }
+ {
+ \tl_set:Nx \l_@@_current_coor_tl { \l_xeCJK_family_tl/\curr@fontshape }
+ \prop_get:NVNTF \g_@@_scale_family_prop
+ \l_@@_current_coor_tl \l_xeCJK_family_tl
+ {
+ \tl_set_eq:NN \xeCJK@family \l_xeCJK_family_tl
+ \skip_zero:N \l_@@_verb_exspace_skip
+ }
+ {
+ \group_begin: \xeCJK_select_font: \exp_after:wN \group_end:
+ \exp_after:wN \@@_set_verb_exspace:n
+ \exp_after:wN { \dim_use:N \etex_fontcharwd:D \tex_font:D "4E00 }
+ }
+ }
+ }
+\skip_new:N \l_@@_verb_exspace_skip
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\@@_set_verb_exspace:n}
+% 当两个西文空格的宽度小于一个 CJK 文字的宽度时,对目前使用的 CJK 字体进行适当缩小。
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_set_verb_exspace:n #1
+ {
+ \skip_set:Nn \l_@@_verb_exspace_skip
+ { \c_two \tex_fontdimen:D \c_two \tex_font:D - #1 }
+ \dim_compare:nNnTF \l_@@_verb_exspace_skip < \c_zero_dim
+ {
+ \skip_zero:N \l_@@_verb_exspace_skip
\use:x
{
- \group_end:
- \tl_gset:cx
- \exp_not:n { { xeCJK/verb/\l_xeCJK_family_tl/\curr@fontshape/\f@size } }
- {
- \exp_not:N \dim_max:nn { \c_zero_dim }
- {
- \c_two \tex_fontdimen:D \c_two \tex_font:D -
- \dim_use:N \etex_fontcharwd:D \tex_font:D "4E00
- }
- }
+ \@@_set_verb_scale:nn
+ { \dim_to_fp:n { \c_two \tex_fontdimen:D \c_two \tex_font:D } }
+ { \dim_to_fp:n {#1} }
}
}
- \skip_gset:Nn \g_@@_verb_exspace_skip
- { \use:c { xeCJK/verb/\l_xeCJK_family_tl/\curr@fontshape/\f@size } }
+ {
+ \tl_const:cx { xeCJK/verb/\l_xeCJK_family_tl/\curr@fontshape/\f@size }
+ { \skip_use:N \l_@@_verb_exspace_skip }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\@@_set_verb_scale:nn}
+% 缩小 CJK 字体,并保存相关信息。
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_set_verb_scale:nn #1#2
+ {
+ \fp_set:Nn \l_@@_scale_factor_fp { #1 / #2 }
+ \@@_warning:nxx { scale-factor }
+ { \fp_eval:n { round - ( \l_@@_scale_factor_fp , 2 ) } }
+ { \fp_eval:n { round + ( #2 / #1 , 2 ) } }
+ \xeCJK_add_font_features:Nnx \c_true_bool
+ { } { Scale = { \fp_use:N \l_@@_scale_factor_fp } }
+ \prop_gput:NVV \g_@@_scale_family_prop
+ \l_@@_current_coor_tl \l_xeCJK_family_tl
+ }
+\@@_msg_new:nn { scale-factor }
+ {
+ `\token_to_str:N \xeCJKVerbAddon'~may~not~work~properly.\\\\
+ You~may~set~`Scale=#1'~to~CJKfamily~
+ `\@@_msg_family_map:n { \l_xeCJK_family_tl }',\\
+ or~set~`Scale=#2'~to~family~
+ `\str_if_eq_x:nnTF \f@family \ttdefault
+ { \token_to_str:N \ttdefault } { \f@family }'.
}
-\skip_new:N \g_@@_verb_exspace_skip
+\fp_new:N \l_@@_scale_factor_fp
+\prop_new:N \g_@@_scale_family_prop
% \end{macrocode}
% \end{macro}
%
@@ -5727,8 +5978,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{CJKnumber,indentfirst}
-% 是否启用 \pkg{CJKnumb} 宏包和首行是否缩进。
+% \begin{macro}{indentfirst}
+% 首行是否缩进。
% \begin{macrocode}
\keys_define:nn { xeCJK / options }
{
@@ -6055,10 +6306,10 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\str_case:nnn {#1}
{
- { \rmdefault } { \CJKfamily { \CJKrmdefault } }
- { \sfdefault } { \CJKfamily { \CJKsfdefault } }
- { \ttdefault } { \CJKfamily { \CJKttdefault } }
- { \familydefault } { \CJKfamily { \CJKfamilydefault } }
+ { \rmdefault } { \xeCJK_switch_family:n { \CJKrmdefault } }
+ { \sfdefault } { \xeCJK_switch_family:n { \CJKsfdefault } }
+ { \ttdefault } { \xeCJK_switch_family:n { \CJKttdefault } }
+ { \familydefault } { \xeCJK_switch_family:n { \CJKfamilydefault } }
}
{ }
}
@@ -6098,19 +6349,19 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\xeCJK_if_last_node:nTF { default }
{
- \tex_unkern:D \tex_unkern:D \@@italiccorr
+ \xeCJK_remove_node: \@@italiccorr
{ \xeCJK_make_node:n { default } }
}
{
\xeCJK_if_last_node:nTF { CJK }
{
- \tex_unkern:D \tex_unkern:D \@@italiccorr
+ \xeCJK_remove_node: \@@italiccorr
{ \xeCJK_make_node:n { CJK } } \use:n
}
{
\xeCJK_if_last_node:nTF { CJK-space }
{
- \tex_unkern:D \tex_unkern:D \@@italiccorr
+ \xeCJK_remove_node: \@@italiccorr
{ \xeCJK_make_node:n { CJK-space } } \use:n
}
{ \@@italiccorr \use_none:n }
@@ -6257,14 +6508,6 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
% \end{macrocode}
%
-% 禁止在 \pkg{xeCJK} 宏包后再载入 \pkg{CJK} 宏包,并使得
-% \pkg{CJKnumb} 和 \pkg{CJKfntef} 宏包可以使用。
-% \begin{macrocode}
-\tl_set:cn { ver@CJK.sty } { 9999/99/99 }
-\tl_set_eq:cc { ver@CJKulem.sty } { ver@CJK.sty }
-\tl_set_eq:cc { ver@CJKpunct.sty } { ver@CJK.sty }
-% \end{macrocode}
-%
% \begin{macro}[internal]{\xeCJKcaption}
% 可以使用 \pkg{CJK} 宏包中的 |.cpx| 文件。
% \begin{macrocode}
@@ -6318,22 +6561,40 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
% \end{macrocode}
%
+% \changes{v3.2.4}{2013/06/25}{不再使用 \texttt{CJKnumber} 选项,可以在
+% \pkg{xeCJK} 之后直接使用 \pkg{CJKnumb} 宏包得到中文数字。}
+%
+% \begin{macro}[internal]{\CJKaddEncHook}
% 为使用 \pkg{CJKnumb} 宏包而作一些处理。另外 \pkg{CJKnumb} 使用的是传统汉字“萬”
% 和“億”,我们在这里把它们修正为简体字。
% \begin{macrocode}
-\bool_if:NT \g_@@_number_bool
+\cs_new_protected:Npn \CJKaddEncHook #1#2
{
- \tl_set:Nn \CJK@UnicodeEnc { UTF8 }
- \cs_set_protected:Npn \CJKaddEncHook #1#2
- { \cs_set:cpn { @@_enc_#1_hook: } {#2} }
- \cs_set_protected_nopar:Npn \Unicode #1#2
- { \tex_char:D \etex_numexpr:D (#1) * \c_two_hundred_fifty_six + (#2) \scan_stop: }
- \RequirePackage { CJKnumb }
- \cs_if_exist_use:c { @@_enc_ \CJK@UnicodeEnc _hook: }
- \tl_set:Nn \CJK@tenthousand { \Unicode { 78 } { 7 } }
- \tl_set:Nn \CJK@hundredmillion { \Unicode { 78 } { 191 } }
+ \str_if_eq:nnT {#1} { \CJK@UnicodeEnc }
+ {
+ \group_begin:
+ \cs_set_nopar:Npn \Unicode ##1##2
+ { (##1) * \c_two_hundred_fifty_six + (##2) }
+ \cs_set_eq:NN \def \xeCJK_char_from_charcode:Nn
+ #2
+ \group_end:
+ \tl_gset:Nn \CJK@tenthousand { ^^^^4e07 }
+ \tl_gset:Nn \CJK@hundredmillion { ^^^^4ebf }
+ }
}
+\cs_new_protected_nopar:Npn \xeCJK_char_from_charcode:Nn #1#2
+ {
+ \group_begin:
+ \char_set_lccode:nn { "4E00 } {#2}
+ \tl_to_lowercase:n
+ {
+ \group_end:
+ \tl_const:Nn #1 { ^^^^4e00 }
+ }
+ }
+\bool_if:NT \g_@@_number_bool { \RequirePackage { CJKnumb } }
% \end{macrocode}
+% \end{macro}
%
% 最后引入本地配置文件。
% \begin{macrocode}
@@ -6352,6 +6613,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \subsection{\pkg{xeCJKfntef}}
%
% \changes{v3.1.1}{2012/12/08}{增加小宏包 \pkg{xeCJKfntef},用于处理下划线的问题。}
+% \changes{v3.2.4}{2013/06/23}{修正 \pkg{xeCJKfntef} 与 \pkg{natbib} 等的冲突。}
%
% \begin{macrocode}
%<*fntef>
@@ -6369,6 +6631,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\RequirePackage { xeCJK }
\RequirePackage { ulem }
\RequirePackage { CJKfntef }
+\RequirePackage { environ }
% \end{macrocode}
%
% \begin{macrocode}
@@ -6384,7 +6647,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\bool_if:NF \l_@@_ulem_hook_used_bool
{
\bool_set_true:N \l_@@_ulem_hook_used_bool
- \xeCJKsetup { CheckFullRight = false }
+ \xeCJKsetup { CheckFullRight = false , xCJKecglue = false }
\bool_if:NTF \l_@@_ulem_skip_punct_bool
{ \cs_set_eq:NN \@@_ulem_leader_type: \UL@leadtype }
{
@@ -6454,22 +6717,22 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_ulem_initial:
{
- \xeCJK_swap_cs:NN
- \@@_Default_and_FullLeft_glue:N \@@_ulem_Default_and_FullLeft_glue:N
- \xeCJK_swap_cs:NN
- \@@_Default_and_FullRight_glue:N \@@_ulem_Default_and_FullRight_glue:N
- \xeCJK_swap_cs:NN
- \@@_CJK_and_FullLeft_glue:N \@@_ulem_CJK_and_FullLeft_glue:N
- \xeCJK_swap_cs:NN
- \@@_CJK_and_FullRight_glue:N \@@_ulem_CJK_and_FullRight_glue:N
- \xeCJK_swap_cs:NN
- \@@_Boundary_and_FullLeft_glue:N \@@_ulem_Boundary_and_FullLeft_glue:N
- \xeCJK_swap_cs:NN \@@_punct_hskip:n \@@_ulem_punct_hskip:n
- \xeCJK_swap_cs:NN \xeCJK_FullLeft_and_Default: \@@_ulem_FullLeft_and_Default:
- \xeCJK_swap_cs:NN \xeCJK_FullLeft_and_CJK: \@@_ulem_FullLeft_and_CJK:
- \xeCJK_swap_cs:NN \xeCJK_FullRight_and_Default: \@@_ulem_FullRight_and_Default:
- \xeCJK_swap_cs:NN \xeCJK_FullRight_and_CJK: \@@_ulem_FullRight_and_CJK:
- \xeCJK_swap_cs:NN \xeCJK_CJK_and_CJK:N \@@_ulem_CJK_and_CJK:N
+ \@@_ulem_swap_cs:NN
+ \xeCJK_FullLeft_and_Default: \@@_ulem_FullLeft_and_Default:
+ \xeCJK_FullLeft_and_CJK: \@@_ulem_FullLeft_and_CJK:
+ \xeCJK_FullRight_and_Default: \@@_ulem_FullRight_and_Default:
+ \xeCJK_FullRight_and_CJK: \@@_ulem_FullRight_and_CJK:
+ \xeCJK_CJK_and_CJK:N \@@_ulem_CJK_and_CJK:N
+ \xeCJK_Boundary_and_Default: \@@_ulem_Boundary_and_Default:
+ \xeCJK@fix@penalty \@@_ulem_fix_penalty:
+ \@@_punct_hskip:n \@@_ulem_punct_hskip:n
+ \@@_CJK_and_Boundary_aux: \@@_ulem_CJK_and_Boundary_aux:
+ \@@_Default_and_FullLeft_glue:N \@@_ulem_Default_and_FullLeft_glue:N
+ \@@_Default_and_FullRight_glue:N \@@_ulem_Default_and_FullRight_glue:N
+ \@@_CJK_and_FullLeft_glue:N \@@_ulem_CJK_and_FullLeft_glue:N
+ \@@_CJK_and_FullRight_glue:N \@@_ulem_CJK_and_FullRight_glue:N
+ \@@_Boundary_and_FullLeft_glue:N \@@_ulem_Boundary_and_FullLeft_glue:N
+ \q_recursion_tail \q_nil \q_recursion_stop
\seq_map_inline:Nn \g_@@_CJK_sub_class_seq
{
\seq_map_inline:Nn \g_@@_CJK_sub_class_seq
@@ -6488,6 +6751,12 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
}
}
+\cs_new_protected_nopar:Npn \@@_ulem_swap_cs:NN #1#2
+ {
+ \quark_if_recursion_tail_stop:N #1
+ \xeCJK_swap_cs:NN #1#2
+ \@@_ulem_swap_cs:NN
+ }
% \end{macrocode}
% \end{macro}
%
@@ -6509,6 +6778,46 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[internal]{\@@_ulem_Boundary_and_Default:}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_ulem_Boundary_and_Default:
+ {
+ \xeCJK_if_ulem_patch:TF
+ {
+ \xeCJK_if_last_node:nTF { CJK }
+ { \xeCJK_remove_node: \skip_horizontal:N \l_@@_ecglue_skip }
+ { \xeCJK_if_last_node:nT { CJK-space } { \xeCJK_remove_node: \c_space_tl } }
+ }
+ { \@@_ulem_Boundary_and_Default: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\@@_ulem_CJK_and_Boundary_aux:}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_ulem_CJK_and_Boundary_aux:
+ {
+ \xeCJK_if_ulem_patch:TF
+ {
+ \UL@stop \@@_ulem_hskip:n { \c_zero_skip } \UL@start
+ { \xeCJK_make_node:n { CJK } }
+ }
+ { \@@_ulem_CJK_and_Boundary_aux: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\@@_ulem_fix_penalty:}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_ulem_fix_penalty:
+ {
+ \xeCJK_if_ulem_patch:TF
+ { \fix@penalty }
+ { \@@_ulem_fix_penalty: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}[internal]{\@@_ulem_CJK_and_CJK:N}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_ulem_CJK_and_CJK:N
@@ -6621,12 +6930,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\@@_punct_if_long:NTF {#1}
{ \@@_ulem_ccglue: }
{
- \@@_punct_if_middle:NT {#1}
- {
- \xeCJK_no_break:
- \@@_punct_glue:NN \c_@@_right_tl {#1}
- }
\xeCJK_no_break:
+ \@@_punct_if_middle:NT {#1}
+ { \@@_punct_glue:NN \c_@@_right_tl {#1} }
}
\UL@start
}
@@ -6765,7 +7071,8 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\RenewDocumentCommand \CJKunderdot { m }
{
- \bool_if:NT \l_@@_ulem_hook_used_bool { \UL@stop }
+ \bool_if:NT \l_@@_ulem_hook_used_bool
+ { \UL@stop \@@_ulem_restore_CJK_and_Boundary: }
\CJK@preUnderdot
\@@_make_under_symbol:n { \CJK@underdotSkip }
\cs_gset_eq:NN \@@_save_under_dot_CJKsymbol:N \CJKsymbol
@@ -6777,10 +7084,20 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\cs_set_eq:NN \CJKsymbol \@@_save_under_dot_CJKsymbol:N
\tex_output:D \exp_after:wN { \l_@@_underdot_output_tl }
\CJK@postUnderdot
- \bool_if:NT \l_@@_ulem_hook_used_bool { \UL@start }
+ \bool_if:NT \l_@@_ulem_hook_used_bool
+ { \@@_ulem_restore_CJK_and_Boundary: \UL@start }
\tex_ignorespaces:D
}
\box_new:N \g_@@_under_symbol_box
+\cs_new_protected_nopar:Npn \@@_ulem_restore_CJK_and_Boundary:
+ {
+ \xeCJK_if_ulem_patch:TF
+ {
+ \xeCJK_swap_cs:NN
+ \@@_CJK_and_Boundary_aux: \@@_ulem_CJK_and_Boundary_aux:
+ }
+ { }
+ }
% \end{macrocode}
% \end{macro}
%
@@ -6813,7 +7130,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{
\exp_after:wN \cs_set_eq:NN
\exp_after:wN \CJKsymbol
- \exp_after:wN \__xeCJK_save_under_dot_CJKsymbol:N
+ \exp_after:wN \@@_save_under_dot_CJKsymbol:N
\l_@@_underdot_output_tl
}
}
@@ -6852,38 +7169,51 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \end{macrocode}
% \end{macro}
%
+%
% \begin{macro}[internal]{CJKfilltwosides}
-% 修改 |CJKfilltwosides| 环境,使其不必重定义 \cs{CJKsymbol}。
+% \changes{v3.2.4}{2012/06/26}{改用 \texttt{minipage} 和 \LaTeX 表格(\texttt{tabular})来实现。}
+% 使用 \texttt{minipage} 和 \LaTeX 表格(\texttt{tabular})来定义 |CJKfilltwosides| 环境。
+% 可选参数 |#1| 表示环境的垂直对齐位置,默认居中;参数 |#2| 表示环境的宽度。
+% 带星号的环境,如果 |#2| 不大于零或者不大于环境最长文本行的宽度,则取环境的自然宽度。
% \begin{macrocode}
-\RenewDocumentEnvironment { CJKfilltwosides } { m }
+\RenewDocumentEnvironment { CJKfilltwosides } { O { c } m }
{
- \dim_set:Nn \l_@@_fill_width_dim {#1}
- \cs_set_eq:NN \CJKglue \tex_hfil:D
- \cs_set_eq:NN \\ \@@_fill_newline:
- \mode_if_vertical:T { \tex_indent:D }
- \tex_vbox:D \c_group_begin_token
- \tex_hbox:D to \l_@@_fill_width_dim \c_group_begin_token
- \tex_ignorespaces:D
+ \use:x { \exp_not:N \minipage [#1] { \dim_eval:n {#2} } }
+ \cs_set_eq:NN \CJKglue \tex_hfill:D
}
{
- \tex_unskip:D
- \c_group_end_token
- \c_group_end_token
+ \endminipage
+ \ignorespacesafterend
}
-\dim_new:N \l_@@_fill_width_dim
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}[internal]{\@@_fill_newline:}
-% |CJKfilltwosides| 环境里的断行命令 |\\|。
-% \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_fill_newline:
+\NewEnviron { CJKfilltwosides* } [ 2 ] [ c ]
{
- \tex_unskip:D
- \c_group_end_token
- \tex_hbox:D to \l_@@_fill_width_dim \c_group_begin_token
- \tex_ignorespaces:D
+ \cs_set_eq:NN \CJKglue \tex_hfill:D
+ \tl_set:Nn \arraystretch { 1 }
+ \token_if_dim_register:NT \extrarowheight
+ { \dim_set_eq:NN \extrarowheight \c_zero_dim }
+ \dim_compare:nNnTF {#2} > \c_zero_dim
+ {
+ \hbox_set:Nn \l_@@_tmp_box
+ {
+ \tabular [#1] { @ { } c @ { } }
+ \BODY
+ \endtabular
+ }
+ \dim_compare:nNnTF {#2} > { \box_wd:N \l_@@_tmp_box }
+ {
+ \tabular [#1] { @ { } p { \dim_eval:n {#2} } @ { } }
+ \BODY
+ \endtabular
+ }
+ { \hbox_unpack:N \l_@@_tmp_box }
+ }
+ {
+ \tabular [#1] { @ { } c @ { } }
+ \BODY
+ \endtabular
+ }
}
+ [ \ignorespacesafterend ]
% \end{macrocode}
% \end{macro}
%
@@ -6917,6 +7247,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\lst@AddToHook { SelectCharTable } { \@@_listings_toks_hook: }
\lst@AddToHook { OutputBox }
{
+ \tl_set_eq:NN \l_xeCJK_punct_style_tl \c_@@_punct_style_plain_tl
\l_@@_restore_listings_toks_tl
\@@_listings_output_IVS:
}
@@ -6945,6 +7276,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\exp_after:wN \use:n
\tex_the:D \tex_output:D
}
+ \lst@ifbreaklines
+ \cs_set_eq:NN \@@_listings_CJK_toks: \@@_listings_breaklines_toks:
+ \fi:
}
% \end{macrocode}
% \end{macro}
@@ -6970,10 +7304,26 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
}
\xeCJK_inter_class_toks:nnn { Boundary } { Default }
{ \@@_listings_process_Default:N }
- \xeCJK_inter_class_toks:nnn { Boundary } { CJK }
- { \@@_listings_process_CJK:nN { \c_two } }
\xeCJK_inter_class_toks:nnn { Boundary } { IVS }
{ \@@_listings_process_IVS:nN { \c_zero } }
+ \@@_listings_CJK_toks_hook:
+ }
+\tl_new:N \l_@@_restore_listings_toks_tl
+\cs_new_nopar:Npn \@@_backup_inter_class_toks:nn #1#2
+ {
+ \xeCJK_inter_class_toks:nnn {#1} {#2}
+ { \xeCJK_get_inter_class_toks:nn {#1} {#2} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\@@_listings_CJK_toks_hook:,\@@_listings_breaklines_toks:}
+% 根据 \texttt{breaklines} 选项的使用与否,选择不同的处理方式。
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_listings_CJK_toks_hook:
+ {
+ \xeCJK_inter_class_toks:nnn { Boundary } { CJK }
+ { \@@_listings_process_CJK:nN { \c_two } }
\xeCJK_inter_class_toks:nnn { Boundary } { FullLeft }
{ \@@_listings_process_CJK:nN { \c_two } }
\xeCJK_inter_class_toks:nnn { Boundary } { FullRight }
@@ -6984,11 +7334,19 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
{ \@@_listings_process_CJK:nN { \c_two } }
}
}
-\tl_new:N \l_@@_restore_listings_toks_tl
-\cs_new_nopar:Npn \@@_backup_inter_class_toks:nn #1#2
+\cs_new_protected_nopar:Npn \@@_listings_breaklines_toks:
{
- \xeCJK_inter_class_toks:nnn {#1} {#2}
- { \xeCJK_get_inter_class_toks:nn {#1} {#2} }
+ \xeCJK_inter_class_toks:nnn { Boundary } { CJK }
+ { \@@_listings_process_breaklines_CJK:nN { \c_two } }
+ \xeCJK_inter_class_toks:nnn { Boundary } { FullLeft }
+ { \@@_listings_process_FullLeft:nN { \c_two } }
+ \xeCJK_inter_class_toks:nnn { Boundary } { FullRight }
+ { \@@_listings_process_FullRight:nN { \c_two } }
+ \seq_map_inline:Nn \g_@@_CJK_sub_class_seq
+ {
+ \xeCJK_inter_class_toks:nnn { Boundary } { CJK/##1 }
+ { \@@_listings_process_breaklines_CJK:nN { \c_two } }
+ }
}
% \end{macrocode}
% \end{macro}
@@ -7035,12 +7393,7 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\bool_if:NTF \l_@@_listings_letter_bool
{ \lst@lettertrue }
{
- \lst@ifletter
- \lst@Output
- \else:
- \lst@OutputOther
- \lst@lettertrue
- \fi:
+ \lst@ifletter \lst@Output \else: \lst@OutputOther \lst@lettertrue \fi:
\bool_set_true:N \l_@@_listings_letter_bool
}
\@@_listings_append:nN
@@ -7050,35 +7403,108 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
\lst@whitespacefalse
\bool_if:NTF \l_@@_listings_letter_bool
{
- \lst@Output
+ \lst@Output \lst@letterfalse
\bool_set_false:N \l_@@_listings_letter_bool
- \lst@letterfalse
}
{ \lst@ifletter \lst@Output \lst@letterfalse \fi: }
\cs_set_eq:NN \lst@lastother #2
\@@_listings_append:nN {#1} #2
}
-\bool_new:N \l_@@_listings_letter_bool
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{v3.2.4}{2012/07/05}
+% {使 \pkg{listings} 的 \texttt{breaklines} 选项对 CJK 字符类可用,并保持标点符号的禁则。}
+%
+% \begin{macro}[internal]
+% {\@@_listings_process_breaklines_CJK:nN,
+% \@@_listings_process_FullLeft:nN,
+% \@@_listings_process_FullRight:nN}
+% 当使用 \texttt{breaklines} 选项时,立即输出之前的单个文字,以便于断行。并将标点
+% 与它前/后的 CJK 文字放在同一个盒子中,以保持禁则。但是不能区分 letter 和 other。
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_listings_process_breaklines_CJK:nN
+ {
+ \lst@whitespacefalse
+ \bool_if:NTF \l_@@_listings_letter_bool
+ {
+ \int_compare:nNnF \l_@@_listings_flag_int = \c_two { \lst@Output }
+ \lst@lettertrue
+ }
+ {
+ \lst@ifletter \lst@Output \else: \lst@OutputOther \lst@lettertrue \fi:
+ \bool_set_true:N \l_@@_listings_letter_bool
+ }
+ \int_set_eq:NN \l_@@_listings_flag_int \c_one
+ \@@_listings_append:nN
+ }
+\cs_new_protected_nopar:Npn \@@_listings_process_FullLeft:nN #1#2
+ {
+ \lst@whitespacefalse
+ \bool_if:NTF \l_@@_listings_letter_bool
+ {
+ \bool_if:nF
+ {
+ \int_compare_p:nNn \l_@@_listings_flag_int = \c_two ||
+ ( \int_compare_p:nNn \l_@@_listings_flag_int = \c_three &&
+ ! \l_@@_punct_breakable_bool )
+ }
+ { \lst@Output }
+ \lst@lettertrue
+ }
+ {
+ \lst@ifletter \lst@Output \else: \lst@OutputOther \lst@lettertrue \fi:
+ \bool_set_true:N \l_@@_listings_letter_bool
+ }
+ \int_set_eq:NN \l_@@_listings_flag_int \c_two
+ \@@_listings_append:nN {#1} #2
+ }
+\cs_new_protected_nopar:Npn \@@_listings_process_FullRight:nN #1#2
+ {
+ \lst@whitespacefalse
+ \bool_if:NTF \l_@@_listings_letter_bool
+ {
+ \bool_if:nT
+ {
+ \int_compare_p:nNn \l_@@_listings_flag_int < \c_two &&
+ \@@_punct_if_long_p:N #2
+ }
+ { \lst@Output }
+ \lst@lettertrue
+ }
+ {
+ \lst@ifletter \lst@Output \else: \lst@OutputOther \lst@lettertrue \fi:
+ \bool_set_true:N \l_@@_listings_letter_bool
+ }
+ \int_set_eq:NN \l_@@_listings_flag_int \c_three
+ \@@_listings_append:nN {#1} #2
+ }
+\int_new:N \l_@@_listings_flag_int
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\lst@AppendLetter,\lst@AppendOther}
+% \begin{macrocode}
\cs_set_protected_nopar:Npn \lst@AppendLetter
{
\bool_if:NTF \l_@@_listings_letter_bool
{
- \lst@Output
+ \lst@Output \lst@lettertrue
\bool_set_false:N \l_@@_listings_letter_bool
- \lst@lettertrue
}
{ \reverse_if:N \lst@ifletter \lst@OutputOther \lst@lettertrue \fi: }
+ \lst@ifbreaklines \int_zero:N \l_@@_listings_flag_int \fi:
\lst@Append
}
\cs_set_protected_nopar:Npn \lst@AppendOther
{
\bool_if:NTF \l_@@_listings_letter_bool
{
- \lst@Output
+ \lst@Output \lst@letterfalse
\bool_set_false:N \l_@@_listings_letter_bool
- \lst@letterfalse
}
{ \lst@ifletter \lst@Output \lst@letterfalse \fi: }
+ \lst@ifbreaklines \int_zero:N \l_@@_listings_flag_int \fi:
\tex_futurelet:D \lst@lastother \lst@Append
}
% \end{macrocode}
@@ -7147,9 +7573,9 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% \begin{macrocode}
\cs_new_protected:Npn \@@_listings_inside_convert:nw #1 ~ \@empty
{
- \tl_set_rescan:Nnn \l_@@_tmpa_tl { } {#1}
+ \tl_set_rescan:Nnn \l_@@_tmp_tl { } {#1}
\@@_set_listings_escape:
- \tl_put_right:NV \lst@arg \l_@@_tmpa_tl
+ \tl_put_right:NV \lst@arg \l_@@_tmp_tl
}
\cs_set_eq:NN \lst@InsideConvert@ \@@_listings_inside_convert:nw
\cs_new_protected_nopar:Npn \@@_listings_inline_group:w
@@ -7172,16 +7598,20 @@ $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $
% 特殊字符,与原来宏包一致。
% \begin{macrocode}
\group_begin:
-\char_set_catcode_active:N \/
-\char_set_lccode:nn { `\/ } { `\\ }
-\tl_to_lowercase:n
+\cs_set:Npn \@@_tmp:w #1
{
\group_end:
\cs_new_protected:Npn \@@_set_listings_escape:
- { \xeCJK_swap_cs:NN / \@@_listings_escape:N }
- \cs_new_protected:Npn \@@_listings_escape:N #1
- { \cs_if_eq:NNTF / #1 { \@@_listings_escape:N } {#1} }
+ { \xeCJK_swap_cs:NN #1 \@@_listings_escape:N }
+ \cs_new_protected:Npn \@@_listings_escape:N ##1
+ { \cs_if_eq:NNTF #1 ##1 { \@@_listings_escape:N } {##1} }
+ }
+\use:n
+ {
+ \char_set_catcode_active:N \\
+ \@@_tmp:w
}
+ { \ }
% \end{macrocode}
% \end{macro}
%
@@ -7502,12 +7932,14 @@ x^2+y^2
\CJKunderanyline{0.2em}{\kern-.03em\vtop{\kern.2ex\hrule width.2em\kern 0.11em
\hrule height 0.1em}\kern-.03em}{自定义下划线}
-\CJKunderanyline{0.5em}{-}{\showtext}
+\indent\CJKunderanyline{0.5em}{-}{\showtext}
\CJKunderanysymbol{0.2em}{-}{\showtext}
\CJKunderdot{\showtext}
+\hrule depth \dp\strutbox width 0 pt \relax
+
\begin{CJKfilltwosides}{40mm}
两端分散对齐\\
分散对齐\\
@@ -7515,6 +7947,8 @@ x^2+y^2
\CJKunderline{汉字可加下划线}
\end{CJKfilltwosides}
+\hrule depth \dp\strutbox width 0 pt \relax
+
\CJKfntef{CJKunderline}
\CJKfntef{CJKunderwave}
\CJKfntef{CJKunderdblline}
@@ -7709,8 +8143,9 @@ lang_set = {
\setCJKmonofont[Kana]{Meiryo}
\setmonofont{Latin Modern Mono Light}
+\makeatletter
\lstset{%
- basicstyle=\small\ttfamily,
+ basicstyle=\small\ttfamily,breakindent=4\lst@width,
numbers=left,numberstyle=\tiny\color{gray},
commentstyle=\color{green!50!black},keywordstyle=\color{blue}\bfseries,
identifierstyle=\color{violet},stringstyle=\color{brown},
@@ -7718,6 +8153,7 @@ lang_set = {
\lstnewenvironment{cppcode}[1][]
{\lstset{language=C++,#1}}
{}
+\makeatother
\begin{document}
@@ -7774,6 +8210,13 @@ int main()
\end{cppcode}
\end{LTXexample}
+\section{\texttt{breaklines} 测试}
+
+\begin{lstlisting}[linewidth=10em,frame=single,rulecolor=\color{black},breaklines]
+断行文字text测试,断行文字text测试,断行文字text测试,断行文字text测试
+断行文字text测试,断行文字text测试,断行文字text测试,断行文字text测试
+\end{lstlisting}
+
\section{\lstinline|\\lstinputlisting| 测试}
\lstinputlisting[language={[AlLaTeX]TeX}]{\jobname}