diff options
author | Karl Berry <karl@freefriends.org> | 2011-09-17 23:00:04 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-09-17 23:00:04 +0000 |
commit | 4c3d942ca695f11236ecee35e9ac3cbe3c28d452 (patch) | |
tree | 0074f8974539ae098b1f3ede47122cbb15fe5757 /Master/texmf-dist | |
parent | ae2491a03dcd2036d8879409d6fe624854f27e3f (diff) |
xecjk (17sep11)
git-svn-id: svn://tug.org/texlive/trunk@23994 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
12 files changed, 301 insertions, 93 deletions
diff --git a/Master/texmf-dist/doc/xelatex/xecjk/example-CJKchecksingle.tex b/Master/texmf-dist/doc/xelatex/xecjk/example-CJKchecksingle.tex index bdbab434fdf..360fc87dd82 100644 --- a/Master/texmf-dist/doc/xelatex/xecjk/example-CJKchecksingle.tex +++ b/Master/texmf-dist/doc/xelatex/xecjk/example-CJKchecksingle.tex @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `example-CJKchecksingle') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% diff --git a/Master/texmf-dist/doc/xelatex/xecjk/example-CJKfntef.tex b/Master/texmf-dist/doc/xelatex/xecjk/example-CJKfntef.tex index 28c15d4a334..a7987f7b6d7 100644 --- a/Master/texmf-dist/doc/xelatex/xecjk/example-CJKfntef.tex +++ b/Master/texmf-dist/doc/xelatex/xecjk/example-CJKfntef.tex @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `example-CJKfntef') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% @@ -30,14 +30,15 @@ \begin{document} \setCJKmainfont{AR PLBaosong2GBK Light}% 设置缺省中文字体 -\setCJKmonofont{AR PLBaosong2GBK Light}% 设置缺省中文字体 +\setCJKmonofont*{AR PLBaosong2GBK Light}% 设置等宽中文字体,令其与英文对齐 \baselineskip 16pt \parindent 2em - \section{举例} +\section{举例} \begin{verbatim} -标点。 +抄录环境中,标点不会被“压缩”。 +Alignment with English characters. \end{verbatim} \CJKunderline{汉字}\CJKunderline{加下划线加下划线加下划线加下划线 diff --git a/Master/texmf-dist/doc/xelatex/xecjk/example-addspaces.tex b/Master/texmf-dist/doc/xelatex/xecjk/example-addspaces.tex index b3ea256baed..1df3bffd6d9 100644 --- a/Master/texmf-dist/doc/xelatex/xecjk/example-addspaces.tex +++ b/Master/texmf-dist/doc/xelatex/xecjk/example-addspaces.tex @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `example-addspaces') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% diff --git a/Master/texmf-dist/doc/xelatex/xecjk/example-fallback.tex b/Master/texmf-dist/doc/xelatex/xecjk/example-fallback.tex index 10db8cfa187..243bac236c8 100644 --- a/Master/texmf-dist/doc/xelatex/xecjk/example-fallback.tex +++ b/Master/texmf-dist/doc/xelatex/xecjk/example-fallback.tex @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `example-fallback') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% diff --git a/Master/texmf-dist/doc/xelatex/xecjk/examples/example-CJKchecksingle.tex b/Master/texmf-dist/doc/xelatex/xecjk/examples/example-CJKchecksingle.tex index bdbab434fdf..360fc87dd82 100644 --- a/Master/texmf-dist/doc/xelatex/xecjk/examples/example-CJKchecksingle.tex +++ b/Master/texmf-dist/doc/xelatex/xecjk/examples/example-CJKchecksingle.tex @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `example-CJKchecksingle') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% diff --git a/Master/texmf-dist/doc/xelatex/xecjk/examples/example-CJKfntef.tex b/Master/texmf-dist/doc/xelatex/xecjk/examples/example-CJKfntef.tex index 28c15d4a334..a7987f7b6d7 100644 --- a/Master/texmf-dist/doc/xelatex/xecjk/examples/example-CJKfntef.tex +++ b/Master/texmf-dist/doc/xelatex/xecjk/examples/example-CJKfntef.tex @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `example-CJKfntef') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% @@ -30,14 +30,15 @@ \begin{document} \setCJKmainfont{AR PLBaosong2GBK Light}% 设置缺省中文字体 -\setCJKmonofont{AR PLBaosong2GBK Light}% 设置缺省中文字体 +\setCJKmonofont*{AR PLBaosong2GBK Light}% 设置等宽中文字体,令其与英文对齐 \baselineskip 16pt \parindent 2em - \section{举例} +\section{举例} \begin{verbatim} -标点。 +抄录环境中,标点不会被“压缩”。 +Alignment with English characters. \end{verbatim} \CJKunderline{汉字}\CJKunderline{加下划线加下划线加下划线加下划线 diff --git a/Master/texmf-dist/doc/xelatex/xecjk/examples/example-addspaces.tex b/Master/texmf-dist/doc/xelatex/xecjk/examples/example-addspaces.tex index b3ea256baed..1df3bffd6d9 100644 --- a/Master/texmf-dist/doc/xelatex/xecjk/examples/example-addspaces.tex +++ b/Master/texmf-dist/doc/xelatex/xecjk/examples/example-addspaces.tex @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `example-addspaces') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% diff --git a/Master/texmf-dist/doc/xelatex/xecjk/examples/example-fallback.tex b/Master/texmf-dist/doc/xelatex/xecjk/examples/example-fallback.tex index 10db8cfa187..243bac236c8 100644 --- a/Master/texmf-dist/doc/xelatex/xecjk/examples/example-fallback.tex +++ b/Master/texmf-dist/doc/xelatex/xecjk/examples/example-fallback.tex @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `example-fallback') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% diff --git a/Master/texmf-dist/doc/xelatex/xecjk/xeCJK.pdf b/Master/texmf-dist/doc/xelatex/xecjk/xeCJK.pdf Binary files differindex 8a37f1129ba..f821e47025e 100644 --- a/Master/texmf-dist/doc/xelatex/xecjk/xeCJK.pdf +++ b/Master/texmf-dist/doc/xelatex/xecjk/xeCJK.pdf diff --git a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx index 82943b531ad..0678e72f489 100644 --- a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx +++ b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.dtx @@ -36,7 +36,7 @@ may observe \keepsilent \preamble - Version 2.4.2 (12-June-2011) + Version 2.4.4 (17-Sep-2011) Copyright (C) Wenchang Sun <sunwch@hotmail.com> @@ -79,7 +79,7 @@ may observe \def\CJKmainfont{AR PLBaosong2GBK Light} \fi \setCJKmainfont{\CJKmainfont}% 设置缺省中文字体 -\setCJKmonofont[Scale=1.1]{\CJKmainfont}% 设置 中文字体 +\setCJKmonofont*{\CJKmainfont}% 设置 中文字体 \setCJKfamilyfont{song}{\CJKmainfont}% 设置 中文字体 \def\xeCJK{{\textcolor{blue}{\texttt{xeCJK}}}} % macros @@ -140,8 +140,8 @@ may observe %</driver> % %<*xeCJK> -\def\fileversion{2.4.2} -\def\filedate{2011/06/12} +\def\fileversion{2.4.4} +\def\filedate{2011/09/17} \ProvidesPackage{xeCJK}[\filedate\space\fileversion\space package for typesetting CJK scripts with XeLaTeX] %</xeCJK> % @@ -229,6 +229,8 @@ may observe % \defmacro{\setCJKmainfont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ % \defmacro{\setCJKsansfont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ % \defmacro{\setCJKmonofont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ +% \defmacro{\setCJKmonofont*} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ +% \defmacro{\setCJKmonofont+} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ % \defmacro{\setCJKfamilyfont} \arg{family name}[\textcolor{optioncolor} % {<font features>}]\arg{font name}\\ % \defmacro{\setCJKfallbackfamilyfont} \arg{family name} @@ -252,7 +254,13 @@ may observe % \renewcommand\CJKfamilydefault{\CJKsfdefault} % \end{verbatim} % +% \defmacro{\setCJKmonofont} 命令后面可以加上星号 |*| 或加号 |+|,分别表示使用 +% 放缩的方式或改变间距的方式,让 CJK 字符的宽度等于西文字体中两个空格的宽度。 +% 这有利于等宽字体的代码对齐等情形。 % +% \defmacro{\setCJKmonoscale} 和 \defmacro{\setCJKmonoexspace} 命令分别计算并设置 +% 当前字号下西文等宽字体与 CJK 字体的放缩比例和字距,以符合上面加 |*| 与加 |+| 号 +% 命令的意义。在字号改变时,应该使用两个命令之一;但注意两个命令不能同时使用。 % % 与 CJK 包类似, 使用命令 \defmacro{\CJKfamily}\arg{family name} 改变当前中文字体。 % @@ -262,9 +270,9 @@ may observe % 以下命令设置缺省英文字体为 TeX Gyre Termes, 缺省中文字体为 AR PLBaosong2GBK Light (文鼎PL报宋二\kern 0sp GBK), % 最后一个命令设置 CJKfamily “song”。 % \begin{verbatim} -% \setmainfont{TeX Gyre Termes} -% \setCJKmainfont{AR PLBaosong2GBK Light} -% \setCJKfamilyfont{song}{AR PLBaosong2GBK Light} +% \setmainfont{TeX Gyre Termes} +% \setCJKmainfont{AR PLBaosong2GBK Light} +% \setCJKfamilyfont{song}{AR PLBaosong2GBK Light} % \end{verbatim} % % \noindent @@ -496,6 +504,8 @@ may observe % \defmacro{\setCJKmainfont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ % \defmacro{\setCJKsansfont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ % \defmacro{\setCJKmonofont} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ +% \defmacro{\setCJKmonofont*} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ +% \defmacro{\setCJKmonofont+} [\textcolor{optioncolor}{<font features>}]\arg{font name}\\ % \defmacro{\setCJKfamilyfont} \arg{family name}[\textcolor{optioncolor} % {<font features>}]\arg{font name}\\ % \defmacro{\setCJKfallbackfamilyfont} \arg{family name} @@ -530,6 +540,14 @@ may observe % \renewcommand\CJKfamilydefault{\CJKsfdefault} % \end{verbatim} % +% \defmacro{\setCJKmonofont} can be appended with a |*| or |+| symbol. They make sure +% that the width of a CJK glyph equals to 2 space for monospace fonts, by scaling and +% spacing, respectively. +% +% \defmacro{\setCJKmonoscale} and \defmacro{\setCJKmonoexspace} reset the scale and extra +% space introduced by |\setCJKmainfont*| and |\setCJKmonofont+|, respectively. They are +% useful when changing the font size. +% % \section{Advanced settings} % % @@ -608,7 +626,7 @@ may observe % % \clearpage % \part{xeCJK.sty} -% \section{宏包选项} +% \section{宏包选项与内部工具} % % \iffalse %<*xeCJK> @@ -666,8 +684,9 @@ may observe \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{fontspec}} \ProcessOptions\relax +\RequirePackage{xkeyval} +\RequirePackage{expl3} \RequirePackage{fontspec} -\relax \ifxeCJK@indentfirst \let\@afterindentfalse\relax @@ -678,6 +697,14 @@ may observe \endlinechar \m@ne % \end{macrocode} % +% 给已有宏内容前后附加补丁 +% \begin{macrocode} +\def\xeCJK@patch#1#2#3{ + \edef#1{ + \unexpanded{#2} + \unexpanded\expandafter{#1} + \unexpanded{#3}}} +% \end{macrocode} % \section{字符类别设定} % \label{sec:charclass} % \xeCJK{} 功能开关 @@ -765,68 +792,68 @@ may observe % \item[] 以下 |"2E80|--|"4DBF| 连续 % \item CJK Radicals Supplement % \begin{macrocode} -\xeCJKsetcharclass{"2E80}{"2EFF}{1} +\xeCJKsetcharclass{"2E80}{"2EFF}{1} % \end{macrocode} % \item Kangxi Radicals % \begin{macrocode} -\xeCJKsetcharclass{"2F00}{"2FDF}{1} +\xeCJKsetcharclass{"2F00}{"2FDF}{1} % \end{macrocode} % \item Ideographic Description Characters % \begin{macrocode} -\xeCJKsetcharclass{"2FF0}{"2FFF}{1} +\xeCJKsetcharclass{"2FF0}{"2FFF}{1} % \end{macrocode} % \item CJK Symbolsand Punctuation % \begin{macrocode} -\xeCJKsetcharclass{"3000}{"303F}{1} +\xeCJKsetcharclass{"3000}{"303F}{1} % \end{macrocode} % \item Hiragana % \begin{macrocode} -\xeCJKsetcharclass{"3040}{"309F}{1} +\xeCJKsetcharclass{"3040}{"309F}{1} % \end{macrocode} % \item Katakana % \begin{macrocode} -\xeCJKsetcharclass{"30A0}{"30FF}{1} +\xeCJKsetcharclass{"30A0}{"30FF}{1} % \end{macrocode} % \item Bopomofo % \begin{macrocode} -\xeCJKsetcharclass{"3100}{"312F}{1} +\xeCJKsetcharclass{"3100}{"312F}{1} % \end{macrocode} % \item Hangul Compatibility Jamo % \begin{macrocode} -\xeCJKsetcharclass{"3130}{"318F}{1} +\xeCJKsetcharclass{"3130}{"318F}{1} % \end{macrocode} % \item Kanbun % \begin{macrocode} -\xeCJKsetcharclass{"3190}{"319F}{1} +\xeCJKsetcharclass{"3190}{"319F}{1} % \end{macrocode} % \item Bopomofo Extended % \begin{macrocode} -\xeCJKsetcharclass{"31A0}{"31BF}{1} +\xeCJKsetcharclass{"31A0}{"31BF}{1} % \end{macrocode} % \item CJK Strokes % \begin{macrocode} -\xeCJKsetcharclass{"31C0}{"31EF}{1} +\xeCJKsetcharclass{"31C0}{"31EF}{1} % \end{macrocode} % \item Katakana Phonetic Extensions % \begin{macrocode} -\xeCJKsetcharclass{"31F0}{"31FF}{1} +\xeCJKsetcharclass{"31F0}{"31FF}{1} % \end{macrocode} % \item Enclosed CJK Letters and Months % \begin{macrocode} -\xeCJKsetcharclass{"3200}{"32FF}{1} +\xeCJKsetcharclass{"3200}{"32FF}{1} % \end{macrocode} % \item CJK Compatibility % \begin{macrocode} -\xeCJKsetcharclass{"3300}{"33FF}{1} +\xeCJKsetcharclass{"3300}{"33FF}{1} % \end{macrocode} % \item CJKUnified Ideographs Extension A % \begin{macrocode} -\xeCJKsetcharclass{"3400}{"4DBF}{1} +\xeCJKsetcharclass{"3400}{"4DBF}{1} % \end{macrocode} % \item[] 以下块不连续 % \item CJK Unified Ideographs % \begin{macrocode} -\xeCJKsetcharclass{"4E00}{"9FFF}{1} +\xeCJKsetcharclass{"4E00}{"9FFF}{1} % \end{macrocode} % \item Yi % \begin{macrocode} @@ -834,23 +861,23 @@ may observe % \end{macrocode} % \item Hangul Syllables % \begin{macrocode} -\xeCJKsetcharclass{"AC00}{"D7AF}{1} +\xeCJKsetcharclass{"AC00}{"D7AF}{1} % \end{macrocode} % \item CJK Compatibility Ideographs % \begin{macrocode} -\xeCJKsetcharclass{"F900}{"FAFF}{1} +\xeCJKsetcharclass{"F900}{"FAFF}{1} % \end{macrocode} % \item CJK Compatibility Forms % \begin{macrocode} -\xeCJKsetcharclass{"FE30}{"FE4F}{1} +\xeCJKsetcharclass{"FE30}{"FE4F}{1} % \end{macrocode} % \item Halfwidth and Fullwidth Forms % \begin{macrocode} -\xeCJKsetcharclass{"FF00}{"FFEF}{1} +\xeCJKsetcharclass{"FF00}{"FFEF}{1} % \end{macrocode} % \item CJK Unified Ideographs Extension B % \begin{macrocode} -\xeCJKsetcharclass{"20000}{"2A6DF}{1} +\xeCJKsetcharclass{"20000}{"2A6DF}{1} % \end{macrocode} % \item CJK Unified Ideographs Extension C % \begin{macrocode} @@ -862,7 +889,7 @@ may observe % \end{macrocode} % \item CJK Compatibility Ideographs Supplement % \begin{macrocode} -\xeCJKsetcharclass{"2F800}{"2FA1F}{1} +\xeCJKsetcharclass{"2F800}{"2FA1F}{1} % \end{macrocode} % \end{itemize} % \begin{macrocode} @@ -882,18 +909,20 @@ may observe \normalspacedchars{/} % \end{macrocode} -% 处理宽度有分歧的两个标点:省略号和间隔号。保证其命令形式输出的是西文字体。 +% +% 单独处理宽度有分歧的两个标点:省略号和间隔号。保证其命令形式输出的是西文字体。 +% 并对间隔号(U+00B7)为一些编码的符号宏包做特殊处理: % \begin{macrocode} \AtBeginDocument{% - \let\xeCJK@save@textellipsis\textellipsis - \def\textellipsis{\begingroup\makexeCJKinactive - \xeCJK@save@textellipsis\endgroup} - \let\xeCJK@save@textperiodcentered\textperiodcentered - \def\textperiodcentered{\begingroup\makexeCJKinactive - \xeCJK@save@textperiodcentered\endgroup} - \let\xeCJK@save@textcentereddot\textcentereddot - \def\textcentereddot{\begingroup\makexeCJKinactive - \xeCJK@save@textcentereddot\endgroup} + \xeCJK@patch\textellipsis {\begingroup\makexeCJKinactive}{\endgroup} + \xeCJK@patch\textperiodcentered {\begingroup\makexeCJKinactive}{\endgroup} + \xeCJK@patch\textcentereddot {\begingroup\makexeCJKinactive}{\endgroup} + \xeCJK@patch\tipaencoding {\makexeCJKinactive}{} % tipa package in T3 encoding + \let\xeCJK@save@r\r + \def\r#1{{\makexeCJKinactive\xeCJK@save@r{#1}}} % \r{u} in T1 encoding + \@ifpackageloaded{pifont}{ % pifont package in U encoding + \renewcommand\Pifont[1]{\fontfamily{#1}\fontencoding{U}% + \fontseries{m}\fontshape{n}\selectfont\makexeCJKinactive}}{} } % \end{macrocode} % @@ -1610,14 +1639,42 @@ may observe \XeTeXinterchartokenstate=0} \fi} +% \end{macrocode} +% |\xeCJK@setfont| 实际切换中文字体。它使用名为 +% |xeCJK@\xeCJK@family/\f@series/\f@shape/\f@size| 的宏来缓存特定 NFSS 坐标 +% 中文字体的原始 |\font| 命令格式,以加快编译速度。在第一次使用这一 NFSS 坐标 +% 时,会调用名为 |xeCJK@font@\xeCJK@family| 的宏(它将展开为 |\fontspec|), +% 利用 |fontspec| 宏包选择中文字体,并缓存原始字体形式。 +% \begin{macrocode} \def\xeCJK@setfont{ - \ifcsname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname - \csname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname + \ifcsname xeCJK@\xeCJK@family/\f@series/\f@shape/\f@size\endcsname +% \end{macrocode} +% 使用已缓存的字体。 +% \begin{macrocode} + \csname xeCJK@\xeCJK@family/\f@series/\f@shape/\f@size\endcsname \else +% \end{macrocode} +% 预存需要的 NFSS 坐标到 |\xeCJK@currentcoor|,以免在缺字体时被替换字体改变。 +% \begin{macrocode} + \edef\xeCJK@currentcoor{xeCJK@\xeCJK@family/\f@series/\f@shape/\f@size} +% \end{macrocode} +% 切换未缓存的字体。 +% \begin{macrocode} \csname xeCJK@font@\xeCJK@family\endcsname - \get@external@font +% \end{macrocode} +% |\get@external@font| 可能会产生奇怪的副作用\footnote{参见 ctex-kit 项目 +% \href{http://code.google.com/p/ctex-kit/issues/detail?id=57}{issue 57}。}。 +% 这里使用分组令其局部化,仅保留对 |\external@font| 的赋值。 +% \begin{macrocode} + \begingroup + \get@external@font + \edef\xeCJK@temp{\def\noexpand\external@font{\external@font}} + \expandafter\endgroup\xeCJK@temp +% \end{macrocode} +% 缓存字体。 +% \begin{macrocode} \expandafter\global\expandafter\font - \csname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname=\external@font + \csname\xeCJK@currentcoor\endcsname=\external@font \fi} \def\CJKrmdefault{rm} @@ -1631,14 +1688,15 @@ may observe \xeCJK@newfontfamily{\CJKsfdefault}} \providecommand\CJKttdefault{tt} -\def\setCJKmonofont{ - \xeCJK@newfontfamily{\CJKttdefault}} +% \end{macrocode} +% |\setCJKmonofont| 在后面单独定义。 +% \begin{macrocode} \def\setCJKfamilyfont#1{ \xeCJK@newfontfamily{#1}} % \end{macrocode} -% Redefine \string\normalfont, \string\rmfamily, \string\sffamily -% and \string\ttfamily\ to set CJKfamily +% 重定义 |\normalfont|, |\rmfamily|, |\sffamily|,添加 CJK 字体族的设置。 +% |\ttfamily| 可能需要单独调整宽度,将在后面定义。 % \begin{macrocode} \def\CJKfamilydefault{\CJKrmdefault} \DeclareRobustCommand\normalfont @@ -1658,9 +1716,6 @@ may observe {\not@math@alphabet\sffamily\mathsf \fontfamily\sfdefault\CJKfamily{\CJKsfdefault}\selectfont} -\DeclareRobustCommand\ttfamily - {\not@math@alphabet\ttfamily\mathtt - \fontfamily\ttdefault\CJKfamily{\CJKttdefault}\selectfont} % \end{macrocode} % \string\xeCJK@newfontfamily is similar to \string\newfontfamily % but introduce fake slant/bold fonts for CJK characters. @@ -1783,6 +1838,82 @@ may observe \xeCJKsetslantfactor{0.17} \xeCJKsetemboldenfactor{4} % \end{macrocode} +% \section{处理等宽字体和抄录环境} +% \begin{macrocode} +\ExplSyntaxOn + +\fp_new:N \g_xecjk_monoscale_fp +\fp_gset_eq:NN \g_xecjk_monoscale_fp \c_one_fp + +\dim_new:N \g_xecjk_exspace_dim +\dim_gset_eq:NN \g_xecjk_exspace_dim \c_zero_dim + +\cs_new:Nn \xecjk_setmonoscale: +{ + \dim_gset_eq:NN \g_xecjk_exspace_dim \c_zero_dim + \group_begin: + \fontfamily\ttdefault\selectfont + \fp_gset_from_dim:Nn \g_xecjk_monoscale_fp {\c_two\fontdimen\c_two\font} + \fp_gdiv:Nn \g_xecjk_monoscale_fp {\f@size} + \group_end: +} + +\newcommand*\setCJKmonoscale{ + \xecjk_setmonoscale: + \addCJKfontfeatures{Scale=\fp_use:N\g_xecjk_monoscale_fp} +} + +\DeclareRobustCommand\setCJKmonoscalefont[2][]{ + \xecjk_setmonoscale: + \xeCJK@newfontfamily{\CJKttdefault}[#1,Scale=\fp_use:N \g_xecjk_monoscale_fp]{#2}} + +\cs_new:Nn \xecjk_set_monoexspace: +{ + \fp_gset_eq:NN \g_xecjk_monoscale_fp \c_one_fp + \group_begin: + \fontfamily\ttdefault\selectfont + \dim_gset:Nn \g_xecjk_exspace_dim {\c_two\fontdimen\c_two\font - \f@size\p@} + \group_end: +} + +\newcommand*\setCJKmonoexspace{ + \xecjk_set_monoexspace: + \CJKsetecglue{\skip_horizontal:N .5\g_xecjk_exspace_dim} + \def\CJKglue{\skip_horizontal:N \g_xecjk_exspace_dim} +} + + +\DeclareRobustCommand\setCJKmonoexspacefont[2][]{ + \setCJKmonoexspace + \xeCJK@newfontfamily{\CJKttdefault}[#1]{#2}} + +\def\xeCJK@ifplus#1{\@ifnextchar +{\@firstoftwo{#1}}} + +\DeclareRobustCommand\setCJKmonofont{\@ifstar + {\setCJKmonoscalefont} + {\xeCJK@ifplus + {\setCJKmonoexspacefont} + {\xeCJK@newfontfamily{\CJKttdefault}}}} + +\DeclareRobustCommand\ttfamily + {\not@math@alphabet\ttfamily\mathtt + \fontfamily\ttdefault\CJKfamily{\CJKttdefault}\selectfont + \CJKsetecglue{\skip_horizontal:N .5\g_xecjk_exspace_dim} + \def\CJKglue{\skip_horizontal:N \g_xecjk_exspace_dim}} + +% \end{macrocode} +% 修补 \verbatim@font +% \begin{macrocode} +\AtBeginDocument{ + \tl_put_right:Nn \verbatim@font { + \punctstyle{plain} + \CJKsetecglue{\skip_horizontal:N \g_xecjk_exspace_dim} + \def\CJKglue{\skip_horizontal:N \g_xecjk_exspace_dim}} +} + +\ExplSyntaxOff + +% \end{macrocode} % \section{使用CJKnumb宏包} % \begin{macrocode} % @@ -1943,14 +2074,15 @@ xeCJK 改进了中英文间距的处理, 并且还可以避免单个汉字独 \begin{document} \setCJKmainfont{AR PLBaosong2GBK Light}% 设置缺省中文字体 -\setCJKmonofont{AR PLBaosong2GBK Light}% 设置缺省中文字体 +\setCJKmonofont*{AR PLBaosong2GBK Light}% 设置等宽中文字体,令其与英文对齐 \baselineskip 16pt \parindent 2em - \section{举例} +\section{举例} \begin{verbatim} -标点。 +抄录环境中,标点不会被“压缩”。 +Alignment with English characters. \end{verbatim} \CJKunderline{汉字}\CJKunderline{加下划线加下划线加下划线加下划线 diff --git a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.ins b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.ins index 94dc0cc0966..6fda2caa5e9 100644 --- a/Master/texmf-dist/source/xelatex/xecjk/xeCJK.ins +++ b/Master/texmf-dist/source/xelatex/xecjk/xeCJK.ins @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `batchfile') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% @@ -22,7 +22,7 @@ \keepsilent \preamble - Version 2.4.2 (12-June-2011) + Version 2.4.4 (17-Sep-2011) Copyright (C) Wenchang Sun <sunwch@hotmail.com> diff --git a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty index 7fce8d8f86e..441dc0605fe 100644 --- a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty +++ b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK.sty @@ -6,7 +6,7 @@ %% %% xeCJK.dtx (with options: `xeCJK') %% -%% Version 2.4.2 (12-June-2011) +%% Version 2.4.4 (17-Sep-2011) %% %% Copyright (C) Wenchang Sun <sunwch@hotmail.com> %% @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of LaTeX %% version 2005/12/01 or later. %% -\def\fileversion{2.4.2} -\def\filedate{2011/06/12} +\def\fileversion{2.4.4} +\def\filedate{2011/09/17} \ProvidesPackage{xeCJK}[\filedate\space\fileversion\space package for typesetting CJK scripts with XeLaTeX] \RequirePackage{ifxetex} \RequireXeTeX @@ -68,13 +68,19 @@ \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{fontspec}} \ProcessOptions\relax +\RequirePackage{xkeyval} +\RequirePackage{expl3} \RequirePackage{fontspec} -\relax \ifxeCJK@indentfirst \let\@afterindentfalse\relax \fi \endlinechar \m@ne +\def\xeCJK@patch#1#2#3{ + \edef#1{ + \unexpanded{#2} + \unexpanded\expandafter{#1} + \unexpanded{#3}}} \def\makexeCJKactive{ \XeTeXinterchartokenstate=1\relax} @@ -171,15 +177,15 @@ \normalspacedchars{/} \AtBeginDocument{% - \let\xeCJK@save@textellipsis\textellipsis - \def\textellipsis{\begingroup\makexeCJKinactive - \xeCJK@save@textellipsis\endgroup} - \let\xeCJK@save@textperiodcentered\textperiodcentered - \def\textperiodcentered{\begingroup\makexeCJKinactive - \xeCJK@save@textperiodcentered\endgroup} - \let\xeCJK@save@textcentereddot\textcentereddot - \def\textcentereddot{\begingroup\makexeCJKinactive - \xeCJK@save@textcentereddot\endgroup} + \xeCJK@patch\textellipsis {\begingroup\makexeCJKinactive}{\endgroup} + \xeCJK@patch\textperiodcentered {\begingroup\makexeCJKinactive}{\endgroup} + \xeCJK@patch\textcentereddot {\begingroup\makexeCJKinactive}{\endgroup} + \xeCJK@patch\tipaencoding {\makexeCJKinactive}{} % tipa package in T3 encoding + \let\xeCJK@save@r\r + \def\r#1{{\makexeCJKinactive\xeCJK@save@r{#1}}} % \r{u} in T1 encoding + \@ifpackageloaded{pifont}{ % pifont package in U encoding + \renewcommand\Pifont[1]{\fontfamily{#1}\fontencoding{U}% + \fontseries{m}\fontshape{n}\selectfont\makexeCJKinactive}}{} } \XeTeXinterchartoks 1 0{\egroup\CJKecglue} \XeTeXinterchartoks 1 1{\xeCJK@i@i} @@ -844,13 +850,17 @@ \fi} \def\xeCJK@setfont{ - \ifcsname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname - \csname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname + \ifcsname xeCJK@\xeCJK@family/\f@series/\f@shape/\f@size\endcsname + \csname xeCJK@\xeCJK@family/\f@series/\f@shape/\f@size\endcsname \else + \edef\xeCJK@currentcoor{xeCJK@\xeCJK@family/\f@series/\f@shape/\f@size} \csname xeCJK@font@\xeCJK@family\endcsname - \get@external@font + \begingroup + \get@external@font + \edef\xeCJK@temp{\def\noexpand\external@font{\external@font}} + \expandafter\endgroup\xeCJK@temp \expandafter\global\expandafter\font - \csname\xeCJK@family/\f@series/\f@shape/\f@size\endcsname=\external@font + \csname\xeCJK@currentcoor\endcsname=\external@font \fi} \def\CJKrmdefault{rm} @@ -864,8 +874,6 @@ \xeCJK@newfontfamily{\CJKsfdefault}} \providecommand\CJKttdefault{tt} -\def\setCJKmonofont{ - \xeCJK@newfontfamily{\CJKttdefault}} \def\setCJKfamilyfont#1{ \xeCJK@newfontfamily{#1}} @@ -887,9 +895,6 @@ {\not@math@alphabet\sffamily\mathsf \fontfamily\sfdefault\CJKfamily{\CJKsfdefault}\selectfont} -\DeclareRobustCommand\ttfamily - {\not@math@alphabet\ttfamily\mathtt - \fontfamily\ttdefault\CJKfamily{\CJKttdefault}\selectfont} \newcommand*\xeCJK@newfontfamily[1]{ \@ifnextchar[ {\xeCJK@newfontfamily@{#1}} @@ -1003,6 +1008,75 @@ \xeCJKsetslantfactor{0.17} \xeCJKsetemboldenfactor{4} +\ExplSyntaxOn + +\fp_new:N \g_xecjk_monoscale_fp +\fp_gset_eq:NN \g_xecjk_monoscale_fp \c_one_fp + +\dim_new:N \g_xecjk_exspace_dim +\dim_gset_eq:NN \g_xecjk_exspace_dim \c_zero_dim + +\cs_new:Nn \xecjk_setmonoscale: +{ + \dim_gset_eq:NN \g_xecjk_exspace_dim \c_zero_dim + \group_begin: + \fontfamily\ttdefault\selectfont + \fp_gset_from_dim:Nn \g_xecjk_monoscale_fp {\c_two\fontdimen\c_two\font} + \fp_gdiv:Nn \g_xecjk_monoscale_fp {\f@size} + \group_end: +} + +\newcommand*\setCJKmonoscale{ + \xecjk_setmonoscale: + \addCJKfontfeatures{Scale=\fp_use:N\g_xecjk_monoscale_fp} +} + +\DeclareRobustCommand\setCJKmonoscalefont[2][]{ + \xecjk_setmonoscale: + \xeCJK@newfontfamily{\CJKttdefault}[#1,Scale=\fp_use:N \g_xecjk_monoscale_fp]{#2}} + +\cs_new:Nn \xecjk_set_monoexspace: +{ + \fp_gset_eq:NN \g_xecjk_monoscale_fp \c_one_fp + \group_begin: + \fontfamily\ttdefault\selectfont + \dim_gset:Nn \g_xecjk_exspace_dim {\c_two\fontdimen\c_two\font - \f@size\p@} + \group_end: +} + +\newcommand*\setCJKmonoexspace{ + \xecjk_set_monoexspace: + \CJKsetecglue{\skip_horizontal:N .5\g_xecjk_exspace_dim} + \def\CJKglue{\skip_horizontal:N \g_xecjk_exspace_dim} +} + +\DeclareRobustCommand\setCJKmonoexspacefont[2][]{ + \setCJKmonoexspace + \xeCJK@newfontfamily{\CJKttdefault}[#1]{#2}} + +\def\xeCJK@ifplus#1{\@ifnextchar +{\@firstoftwo{#1}}} + +\DeclareRobustCommand\setCJKmonofont{\@ifstar + {\setCJKmonoscalefont} + {\xeCJK@ifplus + {\setCJKmonoexspacefont} + {\xeCJK@newfontfamily{\CJKttdefault}}}} + +\DeclareRobustCommand\ttfamily + {\not@math@alphabet\ttfamily\mathtt + \fontfamily\ttdefault\CJKfamily{\CJKttdefault}\selectfont + \CJKsetecglue{\skip_horizontal:N .5\g_xecjk_exspace_dim} + \def\CJKglue{\skip_horizontal:N \g_xecjk_exspace_dim}} + +\AtBeginDocument{ + \tl_put_right:Nn \verbatim@font { + \punctstyle{plain} + \CJKsetecglue{\skip_horizontal:N \g_xecjk_exspace_dim} + \def\CJKglue{\skip_horizontal:N \g_xecjk_exspace_dim}} +} + +\ExplSyntaxOff + \ifxeCJK@num \edef\CJK@UnicodeEnc{UTF8} |