summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-07-21 00:15:15 +0000
committerKarl Berry <karl@freefriends.org>2009-07-21 00:15:15 +0000
commit1bbc54e16e5508665f03fa07135d4eb1abf087da (patch)
treecf31fb7e93ac439443c1bd484dff03775e992571 /Master
parentc575a3e01c48c6807ff66e39df09c16ece08af60 (diff)
new cjk/xetex package zhspacing (20jul09)
git-svn-id: svn://tug.org/texlive/trunk@14357 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/zhspacing/README11
-rw-r--r--Master/texmf-dist/doc/latex/zhspacing/zhs-man.pdfbin0 -> 192721 bytes
-rw-r--r--Master/texmf-dist/doc/latex/zhspacing/zhs-man.tex514
-rw-r--r--Master/texmf-dist/doc/latex/zhspacing/zhspacing-context-test.tex45
-rw-r--r--Master/texmf-dist/tex/xetex/zhspacing/context/t-zhspacing.tex117
-rw-r--r--Master/texmf-dist/tex/xetex/zhspacing/latex/zhfont.sty143
-rw-r--r--Master/texmf-dist/tex/xetex/zhspacing/latex/zhulem.sty18
-rw-r--r--Master/texmf-dist/tex/xetex/zhspacing/plain/zhmath.sty156
-rw-r--r--Master/texmf-dist/tex/xetex/zhspacing/plain/zhsmyclass.sty150
-rw-r--r--Master/texmf-dist/tex/xetex/zhspacing/plain/zhspacing.sty818
-rw-r--r--Master/texmf-dist/tex/xetex/zhspacing/plain/zhsusefulmacros.sty97
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds25
-rw-r--r--Master/tlpkg/tlpsrc/collection-langcjk.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/zhspacing.tlpsrc0
15 files changed, 2089 insertions, 8 deletions
diff --git a/Master/texmf-dist/doc/latex/zhspacing/README b/Master/texmf-dist/doc/latex/zhspacing/README
new file mode 100644
index 00000000000..be0359202ab
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/zhspacing/README
@@ -0,0 +1,11 @@
+zhspacing is a package for typesetting CJK documents in XeTeX
+for plain TeX, LaTeX and ConTeXt.
+
+This package is licensed in LPPL.
+
+If you are interested in the process of development you
+may observe
+
+ http://code.google.com/p/ctex-kit/updates/list
+
+- Yin Dian (yindian@gmail.com)
diff --git a/Master/texmf-dist/doc/latex/zhspacing/zhs-man.pdf b/Master/texmf-dist/doc/latex/zhspacing/zhs-man.pdf
new file mode 100644
index 00000000000..c0a828fb9f3
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/zhspacing/zhs-man.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/zhspacing/zhs-man.tex b/Master/texmf-dist/doc/latex/zhspacing/zhs-man.tex
new file mode 100644
index 00000000000..0ec7e478aba
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/zhspacing/zhs-man.tex
@@ -0,0 +1,514 @@
+% Hist: 070824 First document out. All but Implementation written.
+% In the evening fixed some typos.
+\documentclass[12pt]{ltxdoc}
+%\usepackage[margin=1.5in]{geometry}
+\usepackage{fontspec}
+\defaultfontfeatures{Mapping=tex-text}
+\usepackage[no-sscript]{xltxtra}
+\usepackage{zhspacing}
+\usepackage[fakebold]{zhfont}
+\usepackage[noactive]{zhmath}
+\usepackage[dvipdfmx]{hyperref}
+\newfontfamily\zhcjkextafont{Sun-ExtA}
+\newfontfamily\zhcjkextbfont{Sun-ExtB}
+\zhspacing
+\usepackage{fancyvrb}
+\DefineVerbatimEnvironment{verbatim}{Verbatim}{baselinestretch=0.9}%,fontsize=\footnotesize}
+\usepackage{pst-all}
+\setlength\parskip{0.5em plus 0.5em minus 0.5em}
+\newcommand\q[1]{``\hbox spread -0.2em{#1}''}
+\newcommand\name[1]{\hbox{#1}}
+\newcommand\fntname[1]{\texttt{#1}}
+\newcommand\NFSS{\textsf{NFSS}}
+\newcommand\mymacro[1]{\ifvmode\noindent\else\setbox0=\lastbox\fi\llap{$\bullet$}\cmd#1\\\indent}
+\makeatletter
+\@addtoreset{section}{part}
+\makeatother
+\begin{document}
+\title{Typesetting Chinese in \XeTeX: |zhspacing| user's
+manual\footnote{Revision: \zhspacingrevision.}}
+\author{\textsc{Yin} Dian\footnote{Lab.\ of Network Comm. System \&
+Control, Univ.\ of Sci.\ \& Tech.\ of China.}}
+\date{2007.12.11.}
+\maketitle
+\tableofcontents
+\newpage
+
+\part{zhspacing.sty}
+\section{Introduction}
+\XeTeX\ is a new \TeX\ engine by Jonathan Kew and SIL International, which combines
+\eTeX\ with pervasive Unicode support and advanced font support\footnote{Words
+copied from the ConTeXt Wiki.}. Using \XeTeX, it is possible to typeset scripts
+of any languages whose glyphs are contained in the font in use, without the
+help of any extra packages, such as |CJK|\footnote{|CJK| is a LaTeX 2e macro
+package which enables the use of CJK scripts (Chinese/Japanese/Korean) in
+various encodings, written by Werner Lemberg.}.
+
+However, \XeTeX\ itself does not solve all the problems. Some details in
+Chinese typesetting have not been dealt with by \XeTeX, such as the automatic
+font switch between Chinese and Western characters, the skip adjustment of
+fullwidth punctuations, the automatic skip insertion between Chinese and
+Western characters or math formulas, etc.
+
+To meet the need of easy and high quality typesetting of Chinese documents
+using \XeTeX, the package |zhspacing| is coded, utilizing the new primitive of
+\cs{XeTeXinterchartoks} provided in \XeTeX\ version 0.997.
+
+\section{Getting Started}
+|zhspacing| can be used in both plain \XeTeX\ or \XeLaTeX. The usage is quite
+straightforward. For instance, in plain \XeTeX,
+{\emptyskipscheme
+\begin{verbatim}
+ \input zhspacing.sty
+ \zhspacing
+ 这是中文测 试。中文和English的混排。中
+ 文和$E=mc^2$的混排。
+ \bye
+\end{verbatim}
+}
+And in \XeLaTeX,
+{\emptyskipscheme
+\begin{verbatim}
+ \documentclass{article}
+ \usepackage{zhspacing}
+ \zhspacing
+ \begin{document}
+ 这是中文测 试。中文和English的混排。中
+ 文和$E=mc^2$的混排。
+ \end{document}
+\end{verbatim}
+}
+Both of the examples above produce the same result as follows,
+\begin{center}
+这是中文测 试。中文和English的混排。中
+文和$E=mc^2$的混排。
+\end{center}
+
+As you can see, spaces after Chinese characters are always ignored. Moreover, a
+noticable skip is inserted between Chinese characters and English characters as
+well as math formulas. In fact, all of the following inputs can produce mixed
+langauge output with skip automatically inserted between Chinese and English
+characters,
+\begin{center}
+\emptyskipscheme |中Eng文|,\quad |中 Eng文|,\quad |中Eng 文|\quad and\quad |中 Eng 文|.
+\end{center}
+And their corresponding output is,
+\begin{center}
+中Eng文,\quad 中 Eng文,\quad 中Eng 文\quad and\quad 中 Eng 文.
+\end{center}
+
+Look close and you'll find, that the first and second input generates exactly
+the same output, and so does the third and fourth. However, the skip between
+|Eng| and |文| in the last two cases is wider than the skip between |中| and
+|Eng|. That is because the space is produced by the space token after the
+letter |g|, not the skip automatically inserted by |zhspacing|'s skip
+mechanism.
+
+The space ignoring and skip auto-inserting ability of |zhspacing| can make
+writing documents much comfortable. You don't need to worry about the manual
+insertion of skips such as adding the annoying |~| in |CJK|.
+
+Now come to the topic of punctuation skip adjustment. Proper Chinese
+typesetting requires consecutive fullwidth punctuations be compressed, and a
+linebreak before or after a fullwidth punctuation will cut off the blank spaces
+of this punctuation, making it align to the margin. |zhspacing| does have
+solved these problems, as well as proper prohibitions(禁则). Here's an example.
+\begin{center}
+\begin{minipage}{21em}
+他强调,“三个代表”重要思想是在新的历史条件下运用马克思主义的立场、观点和方法的
+典范,是我们学习马克思主义的立场、观点和方法最现实、最生动的教材。“三个代表”
+重要思想是与时俱进的理论。
+\end{minipage}
+\end{center}
+
+\section{Advanced Usage}
+\subsection{Fonts}
+|zhspacing| uses an extensible way of selecting fonts. The rules can be
+summarized as follows,
+\begin{itemize}
+ \item Western characters, i.e.\ those that are not CJKV ideographies nor
+ CJKV punctuations, use the same font as default.
+ \item Chinese characters use seperate fonts. Font changes in the
+ document does not affect the font used to display Chinese,
+ unless you are using \NFSS\ and change the font series or shape.
+ \item On displaying basic Chinese ideographies, execute the command
+ \cs{zhfont}.
+ \item On displaying Chinese punctuations, execute the command
+ \cs{zhpunctfont}.
+ \item On displaying CJK Ext-A characters, execute the command
+ \cs{zhcjkextafont}.
+ \item On displaying CJK Ext-B characters, execute the command
+ \cs{zhcjkextbfont}.
+ \item When switching from non-Chinese characters to Chinese characters,
+ execute \cs{zhs@savefont}. When switching back, execute
+ \cs{zhs@restorefont}.
+\end{itemize}
+
+When importing |zhspacing| from plain \XeTeX, the default definitions of the
+above commands are,
+\begin{verbatim}
+ \font\zhfont="SimSun" at 10pt
+ \font\zhpunctfont="SimSun" at 10pt
+ \def\zhcjkextafont{\message{CJK Ext-A}}
+ \def\zhcjkextbfont{\message{CJK Ext-B}}
+ \let\zhs@savefont=\begingroup
+ \let\zhs@restorefont=\endgroup
+\end{verbatim}
+
+When imported from \XeLaTeX, the defaults are,
+\begin{verbatim}
+ \newfontfamily\zhfont[BoldFont=SimHei]{SimSun}
+ \newfontfamily\zhpunctfont{SimSun}
+ \def\zhcjkextafont{\message{CJK Ext-A}}
+ \def\zhcjkextbfont{\message{CJK Ext-B}}
+ \def\zhs@savefont{\zhs@savef@nt{old}}
+ \def\zhs@restorefont{\zhs@restoref@nt{old}}
+\end{verbatim}
+Here \cs{zhs@savef@nt} and \cs{zhs@restoref@nt} are internal macros to save and
+restore the \NFSS\ info of the current font to specified places.
+
+CJK Ext-A/B fonts have not been defined by default in consideration that not
+every user has installed the particular fonts. I recommend to use
+\fntname{Sun-ExtA} and \fntname{Sun-ExtB} as the corresponding fonts. You can
+define the ext-font macros manually in a similar way to the definition of
+\cs{zhfont}.
+
+An example of mixed typesetting of various classes of characters is as follows,
+cited from \emph{The Tale of Kiều}\footnote{《金云翘传》,or \emph{Truyện Kiều},
+a Vietnamese \emph{lục bát} poem written in \emph{chữ Nôm}. \emph{Chữ Nôm} is
+a system of ideographies created by the Vietnamese laboring people, most of
+which are encoded in CJK Ext-A\hskip -0.2em/B area, or not even included in
+Unicode.}.
+\begin{center}
+\parbox{21em}{
+\fontspec{Times New Roman}
+𤾓𢆥𥪝𡎝𠊛些
+Trăm năm, trong cõi người ta,
+𡨸才𡨸命𡑛罗恄𠑬
+Chữ tài, chữ mệnh, khéo là ghét nhau.
+𣦆戈𠬠局𣷭橷
+Trải qua một cuộc bể dâu,
+仍條𥉩𧡊𦓡𤴬疸𢚸
+Những điều trông thấy mà đau đớn lòng.
+\footnotemark
+}
+\end{center}
+\footnotetext{Some of the ideographies are replaced by similar characters due
+to the limitation of character set. A picture of the original manuscript can be found at
+\href{http://bbs.gophor.cn/cjkv/attachment/14_2_b44e05d28a68271.jpg}{\emph{this
+link}}.}% or Fig.~\ref{fig:kieu}.}
+\subsection{More on Fonts}
+Sometimes it may be desirable to use different Chinese fonts for different
+\NFSS\ font families in \LaTeX. This can be done by changing the definition of
+\cs{zhs@savefont} and \cs{zhfont}, without modifying the |zhspacing| source.
+
+Here is the way to do it.\footnote{See zhfont.sty later for convenient ways.}
+\begin{verbatim}
+\makeatletter
+\g@addto@macro\zhs@savefont{%
+ \long\edef\zhs@tmpmacro{\f@family}%
+ \def\zhs@curr@fam{0}%
+ \ifx\zhs@tmpmacro\sfdefault
+ \def\zhs@curr@fam{1}%
+ \else\ifx\zhs@tmpmacro\ttdefault
+ \def\zhs@curr@fam{2}%
+ \fi\fi
+ \edef\zhs@tmpmacro{\f@family}%
+ \ifx\zhs@tmpmacro\sfdefault
+ \def\zhs@curr@fam{1}%
+ \else\ifx\zhs@tmpmacro\ttdefault
+ \def\zhs@curr@fam{2}%
+ \fi\fi
+}
+\newfontfamily\zhrmfont[BoldFont=SimHei,
+ ItalicFont=KaiTi_GB2312]{SimSun}
+\newfontfamily\zhsffont{SimHei}
+\newfontfamily\zhttfont[BoldFont=SimHei]{KaiTi_GB2312}
+\def\zhfont{\ifcase\zhs@curr@fam\zhrmfont\or\zhsffont
+ \or\zhttfont\else\zhrmfont\fi}
+\end{verbatim}
+\subsection{Skips}
+The skip mechanism in |zhspacing| is also flexible. |zhspacing| utilizes the
+following skip commands. Note that they are defined as macros instead of skip
+register values, in order that the skip varies according to font size changes.
+\begin{description}
+ \item[\mdseries\cs{skipzh}]
+ Skip between adjacent Chinese characters.
+ \item[\mdseries\cs{skipenzh}]
+ Skip between a Chinese character and a Western character or a
+ math formula.
+ \item[\mdseries\cs{skipzhopen}]
+ Skip before fullwidth opening punctuations, such as \q{“},
+ \q{(}, \q{《}, etc.
+ \item[\mdseries\cs{skipzhinteropen}]
+ Skip before a fullwidth opening punctuation when preceded by
+ another fullwidth punctuation.
+ \item[\mdseries\cs{skipzhlinestartopen}]
+ Skip before a fullwidth opening punctuation when it occurs at
+ the start of a line.
+ \item[\mdseries\cs{skipzhclose}]
+ Skip after fullwidth closing punctuations, such as \q{”},
+ \q{)}, \q{》}, etc.
+ \item[\mdseries\cs{skipzhinterclose}]
+ Skip after a fullwidth closing punctuation when followed by
+ another fullwidth punctuation.
+ \item[\mdseries\cs{skipzhlineendclose}]
+ Skip after a fullwidth closing punctuation when it occurs at
+ the end of a line.
+ \item[\mdseries\cs{skipzhfullstop}]
+ Skip after fullwidth fullstop punctuations, such as \q{;},
+ \q{.}, \q{。}, etc.
+ \item[\mdseries\cs{skipzhinterfullstop}]
+ Skip after a fullwidth fullstop punctuation when followed by
+ another fullwidth punctuation.
+ \item[\mdseries\cs{skipzhlineendfullstop}]
+ Skip after a fullwidth fullstop punctuation when it occurs at
+ the end of a line.
+ \item[\mdseries\cs{skipzhhalfstop}]
+ Skip after fullwidth halfstop punctuations, such as \q{、},
+ \q{,}, \q{:}, etc.
+ \item[\mdseries\cs{skipzhinterhalfstop}]
+ Skip after a fullwidth halfstop punctuation when followed by
+ another fullwidth punctuation.
+ \item[\mdseries\cs{skipzhlineendhalfstop}]
+ Skip after a fullwidth halfstop punctuation when it occurs at
+ the end of a line.
+ \item[\mdseries\cs{skipnegzhlinestartopen}]
+ Negative skip to \cs{skipzhlinestartopen}.
+ \item[\mdseries\cs{skipnegzhlineendclose}]
+ Negative skip to \cs{skipzhlineendclose}.
+ \item[\mdseries\cs{skipnegzhlineendfullstop}]
+ Negative skip to \cs{skipzhlineendfullstop}.
+ \item[\mdseries\cs{skipnegzhlineendhalfstop}]
+ Negative skip to \cs{skipzhlineendhalfstop}.
+\end{description}
+
+All of the skip commands above are defined in the pattern \\
+\vadjust{}\hfil |\def\skipxxx{\hskip xxxxx}|.
+
+|zhspacing| comes with three pre-defined skip schemes, namely
+\cs{simsunskipscheme}, \cs{emptyskipscheme} and \cs{haltskipscheme}. The
+first scheme should be suitable for font \fntname{SimSun} and other popular
+Chinese fonts used in China, which does not support OpenType features of
+|halt|, and needs negative spaces be inserted before opening punctuations and
+after closing or judou punctuations. The second scheme simply addes zero
+length. And the last one should be fit for OpenType Chinese fonts supporting
+|halt| feature such as Adobe Song Std, where positive spaces should be inserted
+before or after certain punctuations. You can define your own skip schemes for
+customization, of course.
+\subsection{Vertical Chinese}
+Vertical Chinese can be achieved by adding raw feature |vertical| to the
+specified font. An example could be, \hfil
+\setbox0=\hbox to 0pt{\vbox{\noindent
+\newfontfamily\zhfont[RawFeature={vertical:},BoldFont=SimHei]{SimSun}
+\newfontfamily\zhpunctfont[RawFeature={vertical:+vert:+vhal}]{[AdobeSongStd-Light.otf]}
+\haltskipscheme
+\rotatebox{-90}{\fbox{\raise 0.8em\hbox{我是中国人,我爱自己的祖国。}}}
+}\hss}
+\dp0=0pt \raise 0.8em\box0
+
+\begin{verbatim}
+ \documentclass[12pt]{article}
+ \usepackage[dvipdfm]{graphicx}
+ \usepackage{zhspacing}
+ \zhspacing
+ \begin{document}
+ \newfontfamily\zhfont[RawFeature={vertical:}]{SimSun}
+ \newfontfamily\zhpunctfont[RawFeature={vertical:
+ +vert:+vhal}]{[AdobeSongStd-Light.otf]}
+ \haltskipscheme
+ \rotatebox{-90}{我是中国人,我爱自己的祖国。}
+ \end{document}
+\end{verbatim}
+
+Note that in this example, in order to have proper vertical punctuations, we
+set \cs{zhpunctfont} to use the Adobe one supporting |vert| feature, and change
+the skip scheme to \cs{haltskipscheme} to match the |vhal| feature specified.
+
+However, there exists some bug in typesetting vertical Chinese containing
+punctuations using some fonts such as \fntname{KaiTi\_GB2312} etc. I've told
+this bug to \name{jjgod} in May, but it seems that he hasn't solved the problem
+yet. Moreover, the baseline of vertical Chinese is not correct, so mixed
+typesetting of Chinese and English in vertical mode generates ugly results, and
+thus should be avoided.
+\subsection{Compatibility}
+Theoretically, |zhspacing| should be compatible with all macro packages, except
+those who change the definition of \cs{hskip} and \cs{penalty}, in which case
+special treatment should be applied. I haven't found any conflict when using
+common packages such as |hyperref| and |fancyhdr|. However, |ulem| redefineds
+\cs{hskip} and \cs{penalty}, and causes unexpected output\footnote{I was using
+\cs{begingroup} and \cs{endgroup} as the font saving/restoring commands.
+However, I found |ulem| redefines \cs{hskip} and \cs{penalty} to end the
+current hbox group and start a new hbox, and thus group mismatch occurs. So I
+changed the font saving/restoring commands when used in \LaTeX, using \NFSS\ info
+instead of groups. But in the new hbox group, no Chinese font is applied by
+default so the Chinese characters disappears. Therefore I changed the
+definitions of |ulem|'s new \cs{hskip} and \cs{penalty} in |zhulem|, and advice
+users to use this modified one.}. Use |zhulem| provided along with
+|zhspacing| instead.
+
+\subsection{Working with the \texttt{ctex} package}
+The |ctex| package, made by \href{http://www.ctex.org}{|ctex.org|}, is a widely
+used Chinese document framework which hides the underlying Chinese processing
+details to the user, which enables portability between different Chinese
+processing packages or systems, such as |CCT| and |CJK|. \name{Jjgod} has made
+a \XeTeX\ port of the |ctex| package, named |cxetex|, which can be found at
+\url{http://www.newsmth.net/att.php?s.460.257121.452.bz2}.
+
+To use |zhspacing| in |cxetex|, a slight modification of the file |ctexcjk.clo|
+should be made. Change the corresponding lines to the followes (\% means the
+original lines).
+\begin{verbatim}
+%\XeTeXlinebreaklocale "zh"
+%\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt
+%\setmainfont[BoldFont={cwTeXHeiBold},
+% ItalicFont={cwTeXKaiItalic},
+% Mapping=tex-text]{cwTeXMing}
+%\setsansfont[BoldFont={cwTeXHeiBold},Mapping=tex-text]{cwTeXYen}
+%\setmonofont{cwTeXFangSongTT}
+\usepackage{zhspacing}
+\newfontfamily\zhfont[BoldFont=SimHei]{SimSun}
+\newfontfamily\zhcjkextafont{Sun-ExtA}
+\newfontfamily\zhcjkextbfont{Sun-ExtB}
+\zhspacing
+\end{verbatim}
+
+You can surely change these lines to your own taste.
+
+\section{Getting \texttt{zhspacing}}
+|zhspacing| is hosted on an open-source project at googlecode. The project
+homepage is \url{http://code.google.com/p/zhspacing/}. You can get the lastest
+source from the download page or via SVN.
+
+\goodbreak
+\part{zhfont.sty}
+\section{Introduction}
+To simplify the complex font setting to use \NFSS\ in \LaTeX, the package
+|zhfont| is coded. It also adds simple interface to define fonts with fake
+slant, and also supports fake bold.
+\section{Package Options}
+|zhfont| currently has only one option --- |fakebold|. This option sets
+Chinese show fake boldface when the current series is bold.
+\section{Provided Macros}
+\mymacro\zhrmfont
+\mymacro\zhsffont
+\mymacro\zhttfont
+The font commands to be executed according to the current font family.
+You can redefine them to customize your fonts.
+
+\mymacro\setzhmainfont
+\mymacro\setzhsansfont
+\mymacro\setzhmonofont
+Simply macro to set \cs{zh\{rm/sf/tt\}font} using \cs{newfontfamily}.
+
+\mymacro\newfontfamilywithslant
+Create a font family with fake slant. Take one argument as the font name.
+
+Example: |\newfontfamilywithslant\zhrmfont{SimSun}|
+
+\mymacro\newfontfamilywithslantandbold
+Create a font family with fake slant, and specify another font for its
+boldface. Take two arguments as the font name and bold font name.
+
+Example:\\\quad |\newfontfamilywithslantandbold\zhrmfont{SimSun}{SimHei}|
+\section{Examples}
+The following example is generated with |zhfont| loaded with option
+|fakebold|.
+
+{\emptyskipscheme
+\begin{verbatim}
+\newfontfamilywithslant\zhrmfont{SimSun}
+中文\textbf{测试}。\textit{中文\textbf{测试}。}
+\newfontfamilywithslant\zhrmfont{FangSong_GB2312}
+中文\textbf{测试}。\textit{中文\textbf{测试}。}
+\end{verbatim}
+}
+\nobreak
+{
+\newfontfamilywithslant\zhrmfont{SimSun}
+中文\textbf{测试}。\textit{中文\textbf{测试}。}
+\newfontfamilywithslant\zhrmfont{FangSong_GB2312}
+中文\textbf{测试}。\textit{中文\textbf{测试}。}
+}
+\goodbreak
+
+\part{zhmath.sty}
+\section{Introduction}
+|zhmath| is a generic package which allows the Chinese characters to be
+displayed in math formulas. It also allows changing the math font for alphas
+and numbers.
+
+|zhmath| only sets the basic Chinese characters to be displayable, not CJK
+Ext-A/B ones, as they are seldom used and discouraged in math. You can use
+\cs{hbox} to let |zhspacing| display them, however.
+\section{Package Options}
+In \LaTeX, |zhmath| has two options --- |active| and |noactive|. They set the
+method to implement Chinese character displaying in math. The default is
+|noactive|.
+
+When |active| is set, the Chinese characters in math formulas are set to
+active, which, when executed, display the corresponding characters in
+\cs{zhmathfont}. This behavior is much like that of the package |mathcjk|. The
+font size in different styles are also set in \cs{mathcjksizea}/|b|/|c|/|d|.
+
+When |noactive| is set, the mathcodes of Chinese characters are set to use a
+special math font family to display them. This way is more native than to use
+active characters.
+
+Both |active| and |noactive| have disadvantages. In |active| mode the Chinese
+math font sizes are determined by \cs{mathcjksizea}/|b|/|c|/|d|, so they are
+somewhat independent with the main text size, which means their size cannot
+change when the main font size changes, which gives ugly results. However, in
+|noactive| mode, although Chinese math font size varies with the main font
+size, Chinese inside \cs{mathrm} etc cannot be displayed, because the math
+font family are set to \cs{mathrm}'s. So choose the option to your own need.
+
+In plain \TeX\ no package options are available.
+\section{Provided Macros}
+\mymacro\setzhmathfont
+Set the math font used to display Chinese. Take one argument as the font
+command. Preamble only.
+
+\mymacro\zhmathfont
+The font command which determines the math font for Chinese. However, if you
+use |noactive| option in \LaTeX, or you're in plain \TeX, they are not
+executed when Chinese in math occur, but when \cs{setzhmathfont} is invoked.
+So you should always call |\setzhmathfont\zhmathfont| after the change.
+
+\mymacro\usecustommathfonts
+Enable the use of custom math fonts for alphas and numbers. The default is
+Times New Roman.
+
+\mymacro\setalphanummathfonts
+Set the math font used to display alphas and numbers. Preamble only. Take one
+argument as the font family in \LaTeX, and two argument as the font command
+for alphas and numbers accordingly in plain \TeX.
+
+\mymacro\zhmathalphanumfont
+The font command which determines the math font for alphas and numbers in
+\LaTeX. Should always call |\setalphanummathfonts\zhmathalphanumfont| after
+it changes.
+
+\mymacro\zhmathletterfont
+\mymacro\zhmathnumberfont
+The font command which determines the math font for alphas and numbers in plain
+\TeX. After their change \cs{setalphanummathfonts} with corresponding
+arguments should be called.
+\section{Examples}
+{\emptyskipscheme
+\begin{verbatim}
+{
+$中文 in math 测_试$
+\usecustommathfonts
+\Large $能量E = mc^2$, $s_总 = {1 \over 2} at^2$
+}
+\end{verbatim}
+}
+\nobreak
+{
+$中文 in math 测_试$
+\usecustommathfonts
+\Large $能量E = mc^2$, $s_总 = {1 \over 2} at^2$
+}
+\goodbreak
+\end{document}
diff --git a/Master/texmf-dist/doc/latex/zhspacing/zhspacing-context-test.tex b/Master/texmf-dist/doc/latex/zhspacing/zhspacing-context-test.tex
new file mode 100644
index 00000000000..1f6c528d25c
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/zhspacing/zhspacing-context-test.tex
@@ -0,0 +1,45 @@
+\usemodule[zhspacing]
+
+
+这是中文测试。中文和English的混排。中
+文和$E=mc^2$的混排。
+
+九齿钉耙学名上宝沁晶耙,是俺的武器。九齿钉耙并非普通的农具,而是由
+太上老君\footnote{太上老君,三清之第三位。又称“道德天尊”、
+“混元老君”、“降生天尊”、“太清大帝”等。}用神冰铁亲自锤炼,借五方五
+帝、六丁六甲之力锻造而成,有诗为证:
+
+九齿钉耙学名上宝沁晶耙,是俺的武器。九齿钉耙并非普通的农具,而是由
+太上老君\footnote{太上老君,三清之第三位。又称“道德天尊”、
+“混元老君”、“降生天尊”、“太清大帝”等。}用神冰铁亲自锤炼,借五方五
+帝、六丁六甲之力锻造而成,有诗为证:
+
+\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps
+
+\ss\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps
+
+\tt\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps
+
+\blank
+
+\rm\tf 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+\rm\it 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+\rm\bf 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+\rm\bi 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+
+\blank
+
+\ss\tf 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+\ss\it 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+\ss\bf 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+\ss\bi 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+
+\blank
+
+\tt\tf 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+\tt\it 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+\tt\bf 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+\tt\bi 兡也包因沘氓侷柵苗孫孫財 text 兡也包因沘氓侷柵苗孫孫財\par
+
+
+\bye \ No newline at end of file
diff --git a/Master/texmf-dist/tex/xetex/zhspacing/context/t-zhspacing.tex b/Master/texmf-dist/tex/xetex/zhspacing/context/t-zhspacing.tex
new file mode 100644
index 00000000000..ce91f7ab9af
--- /dev/null
+++ b/Master/texmf-dist/tex/xetex/zhspacing/context/t-zhspacing.tex
@@ -0,0 +1,117 @@
+%D \module
+%D [ file=t-zhspacing,
+%D version=2009.05.11,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Zh-Spacing,
+%D author=Yue Wang,
+%D date=\currentdate,
+%D copyright=Yue Wang
+%D email=yuleopen@gmail.com,
+%D license=BSD]
+
+\writestatus{loading}{Context User Module / Zh-Spacing}
+\unprotect
+
+%D Macro package \type{zhspacing} was written by Yin Dian in order to
+%D typeset Simplified Chinese in \XeTeX. The macro package uses \XeTeX's
+%D inter-char token mechanism in order to support the basic Chinese
+%D typesetting rules. This macro aims to port \type{zhspacing} to Hans
+%D Hagen's \ConTeXt\ format.
+
+%D \ConTeXt\ MKII does not load unicode-letters.tex automatically
+%D when the format is dumped. What's worse, standard \ConTeXt\
+%D distribution does not have unicode-letters.tex included.
+%D So in order to define all the default \XeTeX\ character classes
+%D as in plain \TeX\ and \LaTeX, we striped the related macros
+%D from unicode-letters.tex to \type{zhspacing-unicode}.
+
+
+\def\ID #1 #2 {\set{#1}{#2}{\global\XeTeXcharclass\n=1 \global\catcode\n=11 }}
+\countdef\n=255
+\def\set#1#2#3{\n="#1 \loop #3 \ifnum\n<"#2 \advance\n by 1 \repeat}
+\def\loop#1\repeat{\def\body{#1}\iterate}
+\def\iterate{\body \let\next\iterate \else\let\next\relax\fi \next}
+\let\repeat=\fi \ID 3400 4DB5 \ID 4E00 9FC3 \ID 20000 2A6D6
+
+%D \ConTeXt\ does not have the right catcode for zhspacing.sty defined.
+%D So we should define the catcode correctly in order to load it.
+
+\catcode`\!=12
+\catcode`\@=11
+\catcode`\?=12
+
+
+%D zhspacing uses \TeX\ commands \type{\lq} and \type{\rq} in plain TeX.
+%D However, these are not defined in \ConTeXt. So we define the two macros.
+
+\def\lq{`} \def\rq{'}
+
+%D And now we can load \type{zhspacing.sty} safely.
+
+\input zhspacing.sty
+
+
+%D Last thing: we define the typescript for Adobe Chinese fonts.
+
+\starttypescript [serif] [myzhfont]
+ \definefontsynonym [Serif] [ZhSerif]
+ \definefontsynonym [SerifBold] [ZhSerifBold]
+ \definefontsynonym [SerifItalic] [ZhSerifItalic]
+ \definefontsynonym [SerifBoldItalic] [ZhSerifBoldItalic]
+\stoptypescript
+
+\starttypescript [serif] [myzhfont]
+ \definefontsynonym [ZhSerif] [name:AdobeSongStd-Light]
+ \definefontsynonym [ZhSerifBold] [name:AdobeHeitiStd-Regular]
+ \definefontsynonym [ZhSerifItalic] [name:AdobeKaitiStd-Regular]
+ \definefontsynonym [ZhSerifBoldItalic] [name:AdobeHeitiStd-Regular]
+\stoptypescript
+
+\starttypescript [sans] [myzhfont]
+ \definefontsynonym [Sans] [ZhSans]
+ \definefontsynonym [SansBold] [ZhSansBold]
+ \definefontsynonym [SansItalic] [ZhSansItalic]
+ \definefontsynonym [SansBoldItalic] [ZhSansBoldItalic]
+\stoptypescript
+
+\starttypescript [sans] [myzhfont]
+ \definefontsynonym [ZhSans] [name:AdobeKaitiStd-Regular]
+ \definefontsynonym [ZhSansBold] [name:AdobeHeitiStd-Regular]
+ \definefontsynonym [ZhSansItalic] [name:AdobeKaitiStd-Regular]
+ \definefontsynonym [ZhSansBoldItalic] [name:AdobeHeitiStd-Regular]
+\stoptypescript
+
+\starttypescript [mono] [myzhfont]
+ \definefontsynonym [Mono] [ZhMono]
+ \definefontsynonym [MonoBold] [ZhMonoBold]
+ \definefontsynonym [MonoItalic] [ZhMonoItalic]
+ \definefontsynonym [MonoBoldItalic] [ZhMonoBoldItalic]
+\stoptypescript
+
+\starttypescript [mono] [myzhfont]
+ \definefontsynonym [ZhMono] [name:AdobeFangsongStd-Regular]
+ \definefontsynonym [ZhMonoBold] [name:AdobeHeitiStd-Regular]
+ \definefontsynonym [ZhMonoItalic] [name:AdobeFangsongStd-Regular]
+ \definefontsynonym [ZhMonoBoldItalic] [name:AdobeHeitiStd-Regular]
+\stoptypescript
+
+
+\starttypescript[myzhfont]
+ \definetypeface [myzhfont] [rm] [serif] [myzhfont] [default]
+ \definetypeface [myzhfont] [ss] [sans] [myzhfont] [default]
+ \definetypeface [myzhfont] [tt] [mono] [myzhfont] [default]
+\stoptypescript
+
+\usetypescript[myzhfont]
+
+%D We set all the \type{zhxxxfont} used in \type{zhspacing.sty}.
+
+\zhspacing
+\def\zhongwen{\pushcurrentfont\myzhfont\popcurrentfont}
+\def\zhfont{\zhongwen}
+\def\zhpunctfont{\zhongwen}
+\def\zhcjkextafont{\zhongwen}
+\def\zhcjkextbfont{\zhongwen}
+
+
+\protect \ No newline at end of file
diff --git a/Master/texmf-dist/tex/xetex/zhspacing/latex/zhfont.sty b/Master/texmf-dist/tex/xetex/zhspacing/latex/zhfont.sty
new file mode 100644
index 00000000000..660f7a1ac2c
--- /dev/null
+++ b/Master/texmf-dist/tex/xetex/zhspacing/latex/zhfont.sty
@@ -0,0 +1,143 @@
+% zhfont.sty coded by YIN Dian
+% Simplify setting various font effects
+% Hist: 071204 First coded.
+% 071210 Improved. Added \newfontfamilywithslant and
+% \newfontfamilywithslantandbold to simplify setting.
+% 071211 Added fake bold support.
+% 071231 Added underdot support.
+% 080102 Minor changes on underdot. Don's use \scantokens.
+% Fixed bug of \zhfont in ulem. Added font family
+% selection and fake bold support in active hanzi.
+\NeedsTeXFormat{LaTeX2e}[1996/12/01]
+\def\filedate{2008/01/02}
+\ProvidesPackage{zhfont}[\filedate]
+\RequirePackage{zhspacing}
+\RequirePackage{zhulem}
+\newif\ifzhfont@fakebold
+\zhfont@fakeboldfalse
+\DeclareOption{fakebold}{\zhfont@fakeboldtrue}
+\ProcessOptions\relax
+
+\def\zhs@tmpmacro{}
+\def\zhs@curr@fam{-1}
+
+\zhnfsssavefont
+\g@addto@macro\zhs@savefont{%
+ \long\edef\zhs@tmpmacro{\f@family}%
+ \def\zhs@curr@fam{0}%
+ \ifx\zhs@tmpmacro\sfdefault
+ \def\zhs@curr@fam{1}%
+ \else\ifx\zhs@tmpmacro\ttdefault
+ \def\zhs@curr@fam{2}%
+ \fi\fi
+ \edef\zhs@tmpmacro{\f@family}%
+ \ifx\zhs@tmpmacro\sfdefault
+ \def\zhs@curr@fam{1}%
+ \else\ifx\zhs@tmpmacro\ttdefault
+ \def\zhs@curr@fam{2}%
+ \fi\fi
+}
+\ifzhfont@fakebold
+\def\zhfont@bx{bx}
+\g@addto@macro\zhs@savefont{%
+ \ifx\f@series\zhfont@bx
+ \special{pdf: literal direct q 0.3 w 2 Tr}%
+ \fi
+}
+\g@addto@macro\zhs@restorefont{%
+ \ifx\f@series\zhfont@bx
+ \special{pdf: literal direct 0 Tr}%
+ \fi
+}
+\fi
+
+\def\newfontfamilywithslant#1#2{%
+ \newfontfamily#1[ItalicFont=#2,ItalicFeatures={RawFeature={slant=0.17}},BoldItalicFont=#2,BoldItalicFeatures={RawFeature={slant=0.17}}]{#2}%
+}
+\def\newfontfamilywithslantandbold#1#2#3{%
+ \newfontfamily#1[BoldFont=#3,ItalicFont=#2,ItalicFeatures={RawFeature={slant=0.17}},BoldItalicFont=#3,BoldItalicFeatures={RawFeature={slant=0.17}}]{#2}%
+}
+
+%\newfontfamily\zhrmfont[BoldFont=SimHei,ItalicFont=SimSun,ItalicFeatures={RawFeature={slant=0.17}},BoldItalicFont=SimHei,BoldItalicFeatures={RawFeature={slant=0.17}}]{SimSun}
+%\newfontfamily\zhsffont[ItalicFont=SimHei,ItalicFeatures={RawFeature={slant=0.17}}]{SimHei}
+%\newfontfamily\zhttfont[BoldFont=KaiTi_GB2312,ItalicFont=FangSong_GB2312,ItalicFeatures={RawFeature={slant=0.17}},BoldItalicFont=KaiTi_GB2312,BoldItalicFeatures={RawFeature={slant=0.17}}]{FangSong_GB2312}
+\ifzhfont@fakebold
+\newfontfamilywithslant\zhrmfont{SimSun}
+\newfontfamilywithslant\zhsffont{SimHei}
+\newfontfamilywithslant\zhttfont{FangSong_GB2312}
+\else
+\newfontfamilywithslantandbold\zhrmfont{SimSun}{SimHei}
+\newfontfamilywithslant\zhsffont{SimHei}
+\newfontfamilywithslantandbold\zhttfont{FangSong_GB2312}{KaiTi_GB2312}
+\fi
+\def\zhfont{\ifcase\zhs@curr@fam\zhrmfont\or\zhsffont\or\zhttfont\else\zhrmfont\fi}
+
+\def\setzhmainfont{\newfontfamily\zhrmfont}
+\def\setzhsansfont{\newfontfamily\zhsffont}
+\def\setzhmonofont{\newfontfamily\zhttfont}
+
+\enableactivehanzi
+\def\zhhanzihook#1{%
+ % select family
+ \long\edef\zhs@tmpmacro{\f@family}%
+ \def\zhs@curr@fam{0}%
+ \ifx\zhs@tmpmacro\sfdefault
+ \def\zhs@curr@fam{1}%
+ \else\ifx\zhs@tmpmacro\ttdefault
+ \def\zhs@curr@fam{2}%
+ \fi\fi
+ \edef\zhs@tmpmacro{\f@family}%
+ \ifx\zhs@tmpmacro\sfdefault
+ \def\zhs@curr@fam{1}%
+ \else\ifx\zhs@tmpmacro\ttdefault
+ \def\zhs@curr@fam{2}%
+ \fi\fi
+ \ifzhfont@fakebold\ifx\f@series\zhfont@bx
+ \special{pdf: literal direct q 0.3 w 2 Tr}%
+ \fi\fi
+ {\XeTeXinterchartokenstate=0\zhs@font #1}%
+ \ifzhfont@fakebold\ifx\f@series\zhfont@bx
+ \special{pdf: literal direct 0 Tr}%
+ \fi\fi
+}
+
+\def\underdot@dot{\XeTeXinterchartokenstate=0\zhpunctfont \vbox to 0.5em{\vss\hbox{·}\vss}}
+%\def\underdot@dot{\vbox to 0.5em{\vss\hbox{\bf .}\vss}}
+\newskip\underdot@skip
+\underdot@skip=2.5pt
+\def\underdot{%
+ \begingroup
+ \makehanziglobalactive
+ \def\zhhanzihook##1{%
+ \setbox0=\hbox{\underdot@dot}%
+ \leavevmode\vtop{\baselineskip=\underdot@skip\lineskiplimit=-\maxdimen
+ \advance\baselineskip\ht0
+ % select family
+ \long\edef\zhs@tmpmacro{\f@family}%
+ \def\zhs@curr@fam{0}%
+ \ifx\zhs@tmpmacro\sfdefault
+ \def\zhs@curr@fam{1}%
+ \else\ifx\zhs@tmpmacro\ttdefault
+ \def\zhs@curr@fam{2}%
+ \fi\fi
+ \edef\zhs@tmpmacro{\f@family}%
+ \ifx\zhs@tmpmacro\sfdefault
+ \def\zhs@curr@fam{1}%
+ \else\ifx\zhs@tmpmacro\ttdefault
+ \def\zhs@curr@fam{2}%
+ \fi\fi
+ \ialign{####\cr\XeTeXinterchartokenstate=0\zhs@font
+ \ifzhfont@fakebold\ifx\f@series\zhfont@bx
+ \special{pdf: literal direct q 0.3 w 2 Tr}##1%
+ \special{pdf: literal direct 0 Tr}\else ##1\fi\else ##1\fi
+ \cr\hidewidth\box0\hidewidth\cr}}%
+ }%
+ \underd@t
+}
+\def\underd@t#1{%
+ #1%
+ \makehanzigloballetter
+ \endgroup
+}
+
+\endinput
diff --git a/Master/texmf-dist/tex/xetex/zhspacing/latex/zhulem.sty b/Master/texmf-dist/tex/xetex/zhspacing/latex/zhulem.sty
new file mode 100644
index 00000000000..86365e380ab
--- /dev/null
+++ b/Master/texmf-dist/tex/xetex/zhspacing/latex/zhulem.sty
@@ -0,0 +1,18 @@
+% zhulem.sty coded by YIN Dian
+% Fix compatibility problem with ulem
+% Hist: 070822 Changed \UL@reskip and \UL@@penalty, able to work.
+\NeedsTeXFormat{LaTeX2e}[1996/12/01]
+\def\fileversion{0.4}
+\def\filedate{2007/08/22}
+\ProvidesPackage{zhulem}[\filedate\space\fileversion]
+\RequirePackage{ulem}[2000/05/26]
+%\let\zhulem@printfont\zhs@printf@nt
+\def\zhulem@printfont#1{}
+\def\UL@reskip{\zhs@savef@nt{tmp}\UL@stop \zhulem@printfont{tmp}\UL@leaders
+ \UL@start\zhs@restoref@nt{tmp}}
+\def\UL@@penalty{\LA@penalty \ifnum\count@=\z@
+ \@ne \else \count@ \fi % zero penalty => no penalty, so use 1 instead.
+ \zhs@savef@nt{tmp}\UL@stop \zhulem@printfont{tmp}\UL@start
+ \zhs@restoref@nt{tmp}}
+
+\endinput
diff --git a/Master/texmf-dist/tex/xetex/zhspacing/plain/zhmath.sty b/Master/texmf-dist/tex/xetex/zhspacing/plain/zhmath.sty
new file mode 100644
index 00000000000..88e69f60d7f
--- /dev/null
+++ b/Master/texmf-dist/tex/xetex/zhspacing/plain/zhmath.sty
@@ -0,0 +1,156 @@
+% zhmath.sty coded by YIN Dian
+% Use basic CJK characters in math environment.
+% Hist: 071202 First coded.
+% 071204 Set \XeTeXinterchartokenstate=0 to avoid a XeTeX bug.
+% Added \ProvidesPackage.
+% 071210 Added another method to set Chinese math fonts in
+% LaTeX, via option noactive. Improved format detection.
+% Added ability to set alpha and number fonts.
+% 071211 Put \setalphanummathfonts in preamble so that
+% \usecustommathfonts can be used in document in LaTeX.
+% Changed \hbox to \mbox. Changed default option to
+% noactive.
+% 071215 Removed \XeTeXinterchartokenstate=0, as the XeTeX bug
+% is fixed by JK. Changed \mathcjksizec/d to fit the
+% main text size.
+% 071229 Added \XeTeXinterchartokenstate=0 again, because not
+% everyone has the latest version of XeTeX. Added custom
+% and nocustom options.
+\catcode`\@=11
+\ifx\zhmath@defined\@undefined
+\def\zhmath@defined{\relax}
+\def\filedate{2007/12/29}
+\ifx\zhspacingrevision\@undefined
+\input zhspacing.sty
+\fi
+
+\def\zhmath@setXeTeXmathcodefam#1#2#3{%
+ % set #1..#2's math family to #3
+ \count@=#1%
+ \loop
+ \XeTeXmathcode\count@=7 #3 \count@
+ \unless\ifnum\count@>#2%
+ \advance\count@ by 1
+ \repeat
+}
+
+\def\zhmath@setactivemathchar#1#2#3#4#5#6{%
+ % set #1..#2 to active math chars, executing \mathchoice #3 #4 #5 #6.
+ \count@=#1%
+ \loop
+ \mathcode\count@="8000
+ {\catcode\count@=\active\lccode`\~=\count@
+ \lowercase{\xdef~{{\mathchoice{\noexpand#3{\number\count@}}%
+ {\noexpand#4{\number\count@}}{\noexpand#5{\number\count@}}
+ {\noexpand#6{\number\count@}}}}}%
+ }%
+ \unless\ifnum\count@>#2%
+ \advance\count@ by 1
+ \repeat
+}
+\newif\ifzhmath@active
+\newif\ifzhmath@custom
+
+\ifLaTeX@e % in LaTeX, similar to mathcjk
+
+\ProvidesPackage{zhmath}[\filedate]
+\DeclareOption{active}{\zhmath@activetrue}
+\DeclareOption{noactive}{\zhmath@activefalse}
+\DeclareOption{custom}{\zhmath@customtrue}
+\DeclareOption{nocustom}{\zhmath@customfalse}
+\zhmath@activefalse
+\zhmath@customtrue
+\ProcessOptions\relax
+
+\def\mathcjksizea{}
+\def\mathcjksizeb{}
+\def\mathcjksizec{\dimen@=\dimexpr\f@size pt*6/10\relax\fontsize{\dimen@}{\dimen@}}
+\def\mathcjksized{\dimen@=\dimexpr\f@size pt*5/10\relax\fontsize{\dimen@}{\dimen@}}
+
+\@ifundefined{zhmathfont}{\newfontfamily\zhmathfont{SimSun}}{}
+
+\ifzhmath@active
+ \def\zhmath@zhfont@disp#1{{\mbox{\XeTeXinterchartokenstate=0\zhmathfont\mathcjksizea\char#1\relax}}}
+ \def\zhmath@zhfont@text#1{{\mbox{\XeTeXinterchartokenstate=0\zhmathfont\mathcjksizeb\char#1\relax}}}
+ \def\zhmath@zhfont@scrp#1{{\mbox{\XeTeXinterchartokenstate=0\zhmathfont\mathcjksizec\char#1\relax}}}
+ \def\zhmath@zhfont@subs#1{{\mbox{\XeTeXinterchartokenstate=0\zhmathfont\mathcjksized\char#1\relax}}}
+
+ \zhmath@setactivemathchar{"2E80}{"9FFF}{\zhmath@zhfont@disp}%
+ {\zhmath@zhfont@text}{\zhmath@zhfont@scrp}{\zhmath@zhfont@subs}
+
+ \def\setzhmathfont#1{\let\zhmathfont=#1}
+\else
+ \def\setzhmathfont#1{%
+ \let\zhmathfont=#1%
+ \begingroup
+ \normalfont
+ \zhmathfont
+ \xdef\zhmath@fenc{\f@encoding}%
+ \xdef\zhmath@ffam{\f@family}%
+ \endgroup
+ \DeclareSymbolFont{hanzi}{\zhmath@fenc}{\zhmath@ffam}{m}{n}%
+ }
+ \setzhmathfont\zhmathfont
+ \zhmath@setXeTeXmathcodefam{"2E80}{"9FFF}{\symhanzi}
+\fi
+
+\ifzhmath@custom
+\def\setalphanummathfonts#1{%
+ \let\zhmathalphanumfont=#1%
+ \begingroup
+ \normalfont
+ \zhmathalphanumfont
+ \xdef\zhmath@@fenc{\f@encoding}%
+ \xdef\zhmath@@ffam{\f@family}%
+ \endgroup
+ \DeclareSymbolFont{@letter}{\zhmath@@fenc}{\zhmath@@ffam}{m}{it}%
+ \DeclareSymbolFont{@number}{\zhmath@@fenc}{\zhmath@@ffam}{m}{n}%
+ \SetSymbolFont{@letter}{bold}{\zhmath@@fenc}{\zhmath@@ffam}{bx}{it}%
+ \SetSymbolFont{@number}{bold}{\zhmath@@fenc}{\zhmath@@ffam}{bx}{n}%
+}
+\@ifundefined{zhmathalphanumfont}{\newfontfamily\zhmathalphanumfont{Times New Roman}}{}
+\setalphanummathfonts\zhmathalphanumfont
+\def\usecustommathfonts{%
+ \zhmath@setXeTeXmathcodefam{`\0}{`\9}{\sym@number}
+ \zhmath@setXeTeXmathcodefam{`\a}{`\z}{\sym@letter}
+ \zhmath@setXeTeXmathcodefam{`\A}{`\Z}{\sym@letter}
+}
+\fi
+
+\else %in plain TeX
+
+\@ifundefined{zhmathfont}{\font\zhmathfont="SimSun" at 10pt}{}
+\newfam\zhmath@fam
+\newfam\zhmath@letterfam
+\newfam\zhmath@numberfam
+
+\def\@setzhmathfonts#1#2{%
+ \edef\zhmath@font{\fontname#1 }%
+ \font\zhmath@tenfont=\zhmath@font at 10pt
+ \font\zhmath@sevenfont=\zhmath@font at 7pt
+ \font\zhmath@fivefont=\zhmath@font at 5pt\relax
+ \textfont#2=\zhmath@tenfont
+ \scriptfont#2=\zhmath@sevenfont
+ \scriptscriptfont#2=\zhmath@fivefont
+}
+\def\setzhmathfont#1{\@setzhmathfonts{#1}\zhmath@fam}
+\setzhmathfont\zhmathfont
+
+\def\setalphanummathfonts#1#2{% #1: alpha, #2, num
+ \@setzhmathfonts{#1}\zhmath@letterfam
+ \@setzhmathfonts{#2}\zhmath@numberfam
+}
+
+\zhmath@setXeTeXmathcodefam{"2E80}{"9FFF}{\zhmath@fam}
+
+\def\usecustommathfonts{%
+ \@ifundefined{zhmathletterfont}{\font\zhmathletterfont="Times New Roman/I" at 10pt}{}
+ \@ifundefined{zhmathnumberfont}{\font\zhmathnumberfont="Times New Roman" at 10pt}{}
+ \setalphanummathfonts\zhmathletterfont\zhmathnumberfont
+ \zhmath@setXeTeXmathcodefam{`\0}{`\9}{\zhmath@numberfam}
+ \zhmath@setXeTeXmathcodefam{`\a}{`\z}{\zhmath@letterfam}
+ \zhmath@setXeTeXmathcodefam{`\A}{`\Z}{\zhmath@letterfam}
+}
+
+\fi % end if LaTeX
+\fi
diff --git a/Master/texmf-dist/tex/xetex/zhspacing/plain/zhsmyclass.sty b/Master/texmf-dist/tex/xetex/zhspacing/plain/zhsmyclass.sty
new file mode 100644
index 00000000000..fc80762f09d
--- /dev/null
+++ b/Master/texmf-dist/tex/xetex/zhspacing/plain/zhsmyclass.sty
@@ -0,0 +1,150 @@
+% zhsmyclass.sty coded by YIN Dian
+% Implement easy inter-class token definition with inheritance
+% Hist: 070807 First usable version coded. \newclass, \{set,get,prepend,append}interclasstoks
+% The tricky part is prepending stuffs to a token register, see TeX by Topics.
+% 070808 Added \setclassnum and \registerXeTeXclasstoks
+% 070809 Removed unnecessary \global's.
+% 070810 Only register non-empty tokens.
+% 071019 Added \getclassnum
+% 071210 Changed \@foreach to \@for.
+\catcode`\@=11
+\ifx\@myclass@defined\@undefined
+\def\@myclass@defined{\relax}
+\input zhsusefulmacros.sty
+\catcode`\@=11
+\def\@class@list{}
+\def\newclass{\@ifnextchar[{\@newclass@param}{\@newclass}}
+\def\@newclass@param[#1]#2{%
+ \if!#1!
+ \errmessage{Base class name shouldn't be empty.}%
+ \fi
+ \if!#2!
+ \errmessage{Class name shouldn't be empty.}%
+ \fi
+ \@ifundefined{@@classname@#1}{%
+ \errmessage{Base class not defined yet.}%
+ }{}%
+ \@ifundefined{@@classname@#2}{% if
+ \@namedef{@@classname@#2}{\relax}%
+ \@namedef{@@baseclass@#2}{#1}%
+ \@for\@@class:=\@class@list\do{% for
+ \if!\@@class!
+ \else
+ \@newinterclasstoks{#2}{\@@class}%
+ \@newinterclasstoks{\@@class}{#2}%
+ %\setinterclasstoks{#2}{\@@class}{\getinterclasstoks{#1}{\@@class}}%
+ %\setinterclasstoks{\@@class}{#2}{\getinterclasstoks{\@@class}{#1}}%
+ \copyinterclasstoks{#2}{\@@class}{#1}{\@@class}%
+ \copyinterclasstoks{\@@class}{#2}{\@@class}{#1}%
+ \fi
+ }% end for
+ \@newinterclasstoks{#2}{#2}%
+ \edef\@class@list{\@class@list,#2}%
+ }{% else
+ \errmessage{Class already defined.}%
+ }% end if
+}
+\def\@newclass#1{%
+ \if!#1!
+ \errmessage{Class name shouldn't be empty.}%
+ \fi
+ \@ifundefined{@@classname@#1}{% if
+ \@namedef{@@classname@#1}{\relax}%
+ \@for\@@class:=\@class@list\do{% for
+ \if!\@@class!
+ \else
+ \@newinterclasstoks{#1}{\@@class}%
+ \@newinterclasstoks{\@@class}{#1}%
+ \fi
+ }% end for
+ \@newinterclasstoks{#1}{#1}%
+ \edef\@class@list{\@class@list,#1}%
+ }{% else
+ \errmessage{Class already defined.}%
+ }% end if
+}
+\def\getbaseclass#1#2{%
+ \@ifundefined{@@baseclass@#1}{\def#2{}}{\edef#2{\csname @@baseclass@#1\endcsname}}%
+}
+\def\@newinterclasstoks#1#2{%
+ \expandafter\newtoks\csname @@interclasstoks@#1@#2\endcsname
+ \csname @@interclasstoks@#1@#2\endcsname={}%\meaning #1, \meaning #2}%
+ %%\expandafter\gdef\csname @@interclasstoks@#1@#2\endcsname{}%
+}
+\def\setinterclasstoks#1#2#3{%
+ \csname @@interclasstoks@#1@#2\endcsname={#3}%
+ %%\expandafter\edef\csname @@interclasstoks@#1@#2\endcsname{#3}%
+}
+\def\getinterclasstoks#1#2{%
+ \expandafter\the\csname @@interclasstoks@#1@#2\endcsname
+ %%\csname @@interclasstoks@#1@#2\endcsname
+}
+\def\copyinterclasstoks#1#2#3#4{% (#1, #2) <- (#3, #4)
+ \expandafter\csname @@interclasstoks@#1@#2\endcsname\expandafter{\expandafter\the\csname @@interclasstoks@#3@#4\endcsname}%
+}
+\def\prependinterclasstoks#1#2#3{%
+ \toks0={#3}%
+ \edef\@@prepend@act{\csname @@interclasstoks@#1@#2\endcsname={\the\toks0
+ \expandafter\the\csname @@interclasstoks@#1@#2\endcsname}}%
+ \@@prepend@act
+ %%\expandafter\edef\csname @@interclasstoks@#1@#2\endcsname{#3\csname @@interclasstoks@#1@#2\endcsname}%
+}
+\def\appendinterclasstoks#1#2#3{%
+ \expandafter\csname @@interclasstoks@#1@#2\endcsname\expandafter{\the\csname @@interclasstoks@#1@#2\endcsname #3}%
+ %%\global\expandafter\edef\csname @@interclasstoks@#1@#2\endcsname{\csname @@interclasstoks@#1@#2\endcsname #3}%
+}
+\def\showallinterclasstoks{%
+ \par
+ \begingroup
+ \@for\class:=\@class@list\do{%
+ \if!\class!
+ \else
+ \@for\anotherclass:=\@class@list\do{%
+ \if!\anotherclass!
+ \else
+ [\class, \anotherclass]: %\csname @@interclasstoks@\class @\anotherclass\endcsname
+ \expandafter\the\csname @@interclasstoks@\class @\anotherclass\endcsname
+ \hfil\break
+ \fi
+ }%
+ \fi
+ }%
+ \endgroup
+}
+\newlinechar`\^^J
+\def\setclassnum#1#2{%
+ \expandafter\chardef\csname @@classnum@#1\endcsname=#2\relax
+}
+\def\getclassnum#1{%
+ \csname @@classnum@#1\endcsname
+}
+\def\mydbgmessag@#1{}
+\def\registerXeTeXclasstoks{%
+ \@for\class:=\@class@list\do{%
+ \@ifundefined{@@classnum@\class}{}{%
+ \@for\anotherclass:=\@class@list\do{%
+ \@ifundefined{@@classnum@\anotherclass}{}{%
+ \edef\@@temp@macro{\the\csname @@interclasstoks@\class @\anotherclass\endcsname}%
+ \ifx\@@temp@macro\empty
+ \else
+ \edef\@@temp@macro{\@@temp@macro}%
+ \ifx\@@temp@macro\empty
+ \else
+ \edef\@@register@act{\noexpand\XeTeXinterchartoks\csname @@classnum@\class\endcsname
+ \csname @@classnum@\anotherclass\endcsname\noexpand{\expandafter\the\csname
+ @@interclasstoks@\class @\anotherclass\endcsname\noexpand}}%
+ \@@register@act
+ \edef\@@register@act{\noexpand\mydbgmessag@\noexpand{Registered (\expandafter\number
+ \csname @@classnum@\class\endcsname, \expandafter\number
+ \csname @@classnum@\anotherclass\endcsname)\noexpand}}%
+ \@@register@act
+ \mydbgmessag@{Registered (\class, \anotherclass) token: \expandafter\the\csname
+ @@interclasstoks@\class @\anotherclass\endcsname ^^J}%
+ \fi
+ \fi
+ }%
+ }%
+ }%
+ }%
+}
+\fi
diff --git a/Master/texmf-dist/tex/xetex/zhspacing/plain/zhspacing.sty b/Master/texmf-dist/tex/xetex/zhspacing/plain/zhspacing.sty
new file mode 100644
index 00000000000..36a13bb5139
--- /dev/null
+++ b/Master/texmf-dist/tex/xetex/zhspacing/plain/zhspacing.sty
@@ -0,0 +1,818 @@
+% zhspacing.sty version 3.5
+% Simple macro for typesetting mixed Chinese documents in XeTeX
+% with punctuation space adjustment and prohibitions
+% coded by YIN Dian (yindian@ustc)
+% Licensed under GPL
+% History: 070804 First usable version.
+% 070805 Several line breaking bug fixes.
+% 070807 \zhinteropenskip changed to 0.6em. \enfont
+% TODO list written.
+% 070808 Use macros instead of skips to fit different font size.
+% 070809 Tried to use myclass to manage classes, but failed.
+% Then I found it works when \relax is added.
+% 070810 Changed skip parameters. Removed \relax, only register
+% non-empty tokens instead. Now it seems to work right.
+% Several bugs fixed. CJK Ext-A/B support added.
+% Added three skip schemes.
+% 070812 Fixed font switch bug between CJK Ext-A and Ext-B chars.
+% Obsoleted the use of \enfont.
+% 070822 Fixed bug of unbalanced group when using ulem? Cleared
+% XeTeX's pre-defined inter-char tokens. Use seperate
+% font for punctuations.
+% Deprecated the use of begin/end-groups in LaTeX, in
+% order to work properly with ulem. Coded zhulem.sty.
+% 070823 Use more flexible way to save font. Changed space
+% ignoring mechanism after hanzi to allow \skipenzh added
+% between hanzi and boundary if the next non-space token
+% is a char and is not fullwidth nor in PUA.
+% 070824 Enabled automatic skip between math formulas and CJK
+% chars. Changed skip schemes. Added \zhspacingrevision.
+% 071008 Fixed bug of missing \skipzh when hanzi next to space.
+% Found bug of \zhs@skipspaces --- \iffalse error.
+% Found bug?? in 10pt article:
+% \fbox{\vbox{\hsize=12.2001pt\scriptsize \parindent=0pt
+% \parskip=0pt《口口》口:“}}
+% 071014 Found bug introduced by the last bug fix, which breaks
+% the punctuation prohibitions. (Fixed on 071020)
+% 071015 Fixed bug of not changing punctuation font after space.
+% 071019 Fixed the \iffalse bug. Use \the\XeTeXcharclass
+% instead of ifcjkchar.
+% Defined token patterns to simplify settings, haha.
+% 071020 Added ability to deal with space seperated characters.
+% Added XeTeX existence test. More intelligent parindent
+% setting. Fixed bug of English font change through not
+% using \getinterclasstoks, hmmm.
+% Seperated fullstop and halfstop skips. They were both
+% treated as judou before. Added \halthalfskipscheme.
+% 071027 Fixed bug of \halthalfskipscheme. Added class setting
+% for some punctuations.
+% 071103 Fixed bug of no \skipzh between CJK Ext-A/B chars.
+% However, due to the current bug of XeTeX, CJK Ext-B
+% chars may not have a correct \meaning, so having them
+% after spaces may result in a compiling failure.
+% 071117 Use \ifzhs@isvalidchar to avoid the XeTeX \meaning
+% bug. Added \ProvidesPackage when under LaTeX.
+% 071202 Fixed bug of wrong \ProvidesPackage in plain TeX.
+% 071210 Changed usefulmacros.sty. Removed \@foreach because I
+% find they are redundant --- \@for already has
+% \expandafter #2. Improved LaTeX detecting.
+% 071211 Minor change on \simsunskipscheme.
+% 071229 Added a few punctuation classification settings.
+% Refined code. Added active hanzi hook. Removed some
+% debug code for compiling speed. Not thoroughly tested.
+% 071231 Use \zhs@@a to reduce memory usage. Removed
+% \zhs@active@alphabound because it's not effective.
+% Use \lastnodetype and \spacefactor to determine whether
+% or not to insert \skipenzh. Added a few punctuation
+% classification settings.
+% 080102 No \enableactivehanzi by default. Changed \zhhanzihook.
+% Use hex number to represent hanzi. Added \zhs@font.
+% Added ambiwide and ambinarrow options. Made active
+% hanzi protected.
+% 090720 Rename usefulmacros.sty and myclass.sty to
+% zhsusefulmacros.sty and zhsmyclass.sty.
+% Note: 1. Catcode test requires letter 'a' to be in category 11, and '!'
+% to be in category 12. So don't change the default catcodes.
+% 2. To speed up processing long Chinese documents, set \skipzh to
+% empty and \XeTeXinterchartoks 1 1={}. This can save 1/4 time.
+% 3. \zhspacing will generate a few spaces. Using it in horizontal
+% mode will produce unwanted skips.
+\catcode`\@=11
+\ifx\XeTeXrevision\@undefined
+ \errmessage{XeTeX required to use zhspacing}%
+\fi
+\ifx\XeTeXinterchartokenstate\@undefined
+ \errmessage{XeTeX 0.997 or above required to use zhspacing}%
+\fi
+\ifx\zhspacingrevision\@undefined
+\def\zhspacingrevision{2008/01/02}
+\input zhsusefulmacros.sty
+\newif\ifzhs@ambiwide
+\zhs@ambiwidetrue
+\ifLaTeX@e
+ \ProvidesPackage{zhspacing}[\zhspacingrevision]
+ \DeclareOption{ambiwide}{\zhs@ambiwidetrue}
+ \DeclareOption{ambinarrow}{\zhs@ambiwidefalse}
+ \ProcessOptions\relax
+\fi
+\XeTeXlinebreaklocale="zh"
+\XeTeXlinebreakskip=0pt plus 0.2em minus 0.1em
+\def\zhnobreak{\nobreak}
+\def\simsunskipscheme{% should be fit for sim-xxx fonts
+ % my skip
+ \def\skipzh{\hskip 0em plus 0.2em minus 0.1em}
+ \def\skipenzh{\hskip 0.25em plus 0.15em minus 0.05em}
+ \def\skipzhopen{\hskip -0.0em plus 0.0em minus 0.3em}
+ \def\skipzhinteropen{\hskip -0.3em plus 0.1em minus 0.1em}
+ \def\skipzhlinestartopen{\hskip -0.35em}
+ \def\skipzhclose{\hskip -0.0em plus 0.0em minus 0.3em}
+ \def\skipzhinterclose{\hskip -0.3em plus 0.1em minus 0.1em}
+ \def\skipzhlineendclose{\hskip -0.35em}
+ \def\skipzhhalfstop{\hskip -0.0em plus 0.0em minus 0.5em}
+ \def\skipzhinterhalfstop{\hskip -0.3em plus 0.1em minus 0.1em}
+ \def\skipzhlineendhalfstop{\hskip -0.6em}
+ \def\skipzhfullstop{\hskip -0.0em plus 0.0em minus 0.5em}
+ \def\skipzhinterfullstop{\hskip -0.3em plus 0.1em minus 0.1em}
+ \def\skipzhlineendfullstop{\hskip -0.575em}
+ % neg
+ \def\skipnegzhlinestartopen{\hskip 0.35em}
+ \def\skipnegzhlineendclose{\hskip 0.35em}
+ \def\skipnegzhlineendhalfstop{\hskip 0.6em}
+ \def\skipnegzhlineendfullstop{\hskip 0.575em}
+}
+\def\emptyskipscheme{% just for test use
+ % my skip
+ \def\skipzh{\hskip 0em plus 0.1em}
+ \def\skipenzh{\hskip 0em plus 0.2em}
+ \def\skipzhopen{\hskip 0pt}
+ \def\skipzhinteropen{\hskip 0pt}
+ \def\skipzhlinestartopen{\hskip 0pt}
+ \def\skipzhclose{\hskip 0pt}
+ \def\skipzhinterclose{\hskip 0pt}
+ \def\skipzhlineendclose{\hskip 0pt}
+ \def\skipzhhalfstop{\hskip 0pt}
+ \def\skipzhinterhalfstop{\hskip 0pt}
+ \def\skipzhlineendhalfstop{\hskip 0pt}
+ \def\skipzhfullstop{\hskip 0pt}
+ \def\skipzhinterfullstop{\hskip 0pt}
+ \def\skipzhlineendfullstop{\hskip 0pt}
+ % neg
+ \def\skipnegzhlinestartopen{\hskip 0pt}
+ \def\skipnegzhlineendclose{\hskip 0pt}
+ \def\skipnegzhlineendhalfstop{\hskip 0pt}
+ \def\skipnegzhlineendfullstop{\hskip 0pt}
+}
+\def\haltfullskipscheme{% should be fit for Adobe opentype fonts with halfwidth alternative enabled
+ % my skip
+ \def\skipzh{\hskip 0em plus 0.2em minus 0.1em}
+ \def\skipenzh{\hskip 0.25em plus 0.15em minus 0.05em}
+ \def\skipzhopen{\hskip 0.3em minus 0.3em}
+ \def\skipzhinteropen{\hskip 0em plus 0.1em }
+ \def\skipzhlinestartopen{\hskip 0em}
+ \def\skipzhclose{\hskip 0.3em minus 0.3em}
+ \def\skipzhinterclose{\hskip 0em plus 0.1em}
+ \def\skipzhlineendclose{\hskip 0em}
+ \def\skipzhhalfstop{\hskip 0.4em minus 0.4em}
+ \def\skipzhinterhalfstop{\hskip 0em plus 0.1em}
+ \def\skipzhlineendhalfstop{\hskip 0em}
+ \def\skipzhfullstop{\hskip 0.4em minus 0.4em}
+ \def\skipzhinterfullstop{\hskip 0em plus 0.1em}
+ \def\skipzhlineendfullstop{\hskip 0em}
+ % neg
+ \def\skipnegzhlinestartopen{\hskip 0em}
+ \def\skipnegzhlineendclose{\hskip 0em}
+ \def\skipnegzhlineendhalfstop{\hskip 0em}
+ \def\skipnegzhlineendfullstop{\hskip 0em}
+}
+\let\haltskipscheme\haltfullskipscheme % for backward compatibility
+\def\halthalfskipscheme{% should be fit for Adobe opentype fonts with halfwidth alternative enabled
+ % my skip
+ \def\skipzh{\hskip 0em plus 0.2em minus 0.1em}
+ \def\skipenzh{\hskip 0.25em plus 0.15em minus 0.05em}
+ \def\skipzhopen{\hskip 0.0em plus 0.3em}
+ \def\skipzhinteropen{\hskip 0em plus 0.1em }
+ \def\skipzhlinestartopen{\hskip 0em}
+ \def\skipzhclose{\hskip 0.0em plus 0.3em}
+ \def\skipzhinterclose{\hskip 0em plus 0.1em}
+ \def\skipzhlineendclose{\hskip 0em}
+ \def\skipzhhalfstop{\hskip 0.0em plus 0.4em}
+ \def\skipzhinterhalfstop{\hskip 0em plus 0.1em}
+ \def\skipzhlineendhalfstop{\hskip -0.15em}
+ \def\skipzhfullstop{\hskip 0.0em plus 0.4em}
+ \def\skipzhinterfullstop{\hskip 0em plus 0.1em}
+ \def\skipzhlineendfullstop{\hskip -0.15em}
+ % neg
+ \def\skipnegzhlinestartopen{\hskip 0em}
+ \def\skipnegzhlineendclose{\hskip 0em}
+ \def\skipnegzhlineendhalfstop{\hskip 0.15em}
+ \def\skipnegzhlineendfullstop{\hskip 0.15em}
+}
+\simsunskipscheme
+%\let\mydbgmessage\message
+\def\mydbgmessage#1{}
+
+% font save and restore
+\def\zhs@oldf@encoding{}
+\def\zhs@oldf@family{}
+\def\zhs@oldf@series{}
+\def\zhs@oldf@shape{}
+\def\zhs@oldf@size{}
+\def\zhs@savef@nt#1{%
+ \expandafter\xdef\csname zhs@#1f@encoding\endcsname{\f@encoding}%
+ \expandafter\xdef\csname zhs@#1f@family\endcsname{\f@family}%
+ \expandafter\xdef\csname zhs@#1f@series\endcsname{\f@series}%
+ \expandafter\xdef\csname zhs@#1f@shape\endcsname{\f@shape}%
+ \expandafter\xdef\csname zhs@#1f@size\endcsname{\f@size}%
+}
+\def\zhs@restoref@nt#1{%
+ \edef\f@encoding{\csname zhs@#1f@encoding\endcsname}%
+ \edef\f@family{\csname zhs@#1f@family\endcsname}%
+ \edef\f@series{\csname zhs@#1f@series\endcsname}%
+ \edef\f@shape{\csname zhs@#1f@shape\endcsname}%
+ \edef\f@size{\csname zhs@#1f@size\endcsname}%
+ \selectfont
+}
+\def\zhs@printf@nt#1{%
+ \immediate\write16{Font #1 is: \csname zhs@#1f@encoding\endcsname/\csname zhs@#1f@family\endcsname/\csname
+ zhs@#1f@series\endcsname/\csname zhs@#1f@shape\endcsname/\csname zhs@#1f@size\endcsname}%
+}
+\def\zhgroupsavefont{%
+ \let\zhs@savefont=\begingroup
+ \let\zhs@restorefont=\endgroup
+}
+\def\zhnfsssavefont{%
+ \def\zhs@savefont{\zhs@savef@nt{old}}
+ \def\zhs@restorefont{\zhs@restoref@nt{old}}
+}
+\ifLaTeX@e
+ \zhnfsssavefont
+\else
+ \zhgroupsavefont
+\fi
+
+% test CJK char
+\def\chartonum#1#2{% #1: an explicit or implicit char; #2: return macro
+ \ifcat#1a%
+ \edef#2{\expandafter\@lettertonum\meaning #1\@end}%
+ \edef#2{\expandafter\number\expandafter\lq #2}%
+ \else
+ \ifcat#1!%
+ \edef#2{\expandafter\@chartonum\meaning #1\@end}%
+ \edef#2{\expandafter\number\expandafter\lq #2}%
+ \else
+ \errmessage{In \string\chartonum, parameter not a letter, nor a character}%
+ \fi
+ \fi
+}
+{\escapechar=-1
+ \expandafter\expandafter\expandafter\gdef
+ \expandafter\expandafter\expandafter\@lettertonum
+ \expandafter\string\csname the letter \endcsname#1\@end{#1}
+ \expandafter\expandafter\expandafter\gdef
+ \expandafter\expandafter\expandafter\@chartonum
+ \expandafter\string\csname the character \endcsname#1\@end{#1}
+}
+\let\zhs@tmpchar\relax
+\def\zhs@skipspaces{\futurenonspacelet\zhs@tmpchar\zhs@skipsp@ces}
+\def\zhs@skipsp@ces{%
+ %\expandafter\mydbgmessage\expandafter{\meaning\zhs@tmpchar}%
+ \ifcat a\noexpand\zhs@tmpchar % catcode 11
+ \zhs@testskipenzh
+ \else
+ \ifcat !\noexpand\zhs@tmpchar % catcode 12
+ \zhs@testskipenzh
+ \else
+ \ifcat $\noexpand\zhs@tmpchar % catcode 3
+ \skipenzh\relax
+ \fi
+ \fi
+ \fi
+}
+\def\zhs@tmpnum{-1}
+\def\ifzhs@isvalidchar#1??#2\ok{\if!#2!}
+\def\zhs@testskipenzh{%
+ \chartonum\zhs@tmpchar\zhs@tmpnum
+ \expandafter\ifzhs@isvalidchar\zhs@tmpnum??\ok
+ \edef\zhs@tmpnum{\the\XeTeXcharclass\zhs@tmpnum}%
+ \else
+ \edef\zhs@tmpnum{\getclassnum{cjkextb}}%
+ \fi
+ \ifnum\zhs@tmpnum = \getclassnum{alphanum}%
+ \skipenzh\relax
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{hanzi}%
+ \skipzh\relax
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{closefw}%
+ %\getinterclasstoks{hanzi}{closefw}%
+ \zhnobreak
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{halfstop}%
+ %\getinterclasstoks{hanzi}{halfstop}%
+ \zhnobreak
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{fullstop}%
+ \zhnobreak
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{openfw}%
+ \zhnobreak\skipnegzhlinestartopen\relax % compensate
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{cjkexta}%
+ \skipzh\relax
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{cjkextb}%
+ \skipzh\relax
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+}
+\def\zhs@aftermathskip{%
+ \ifnum\lastnodetype=10 % math node
+ \skipenzh\relax
+ \fi
+}
+% Character class settings.
+\input zhsmyclass.sty
+% three base classes: boundary, halfwidth and fullwidth
+\newclass{boundary}
+\setclassnum{boundary}{255}
+\newclass{halfwidth}
+\newclass{fullwidth}
+\setinterclasstoks{boundary}{fullwidth}{\mydbgmessage{^^JZ}\zhs@savefont\zhfont}
+\setinterclasstoks{fullwidth}{boundary}{\mydbgmessage{^^Jz}\zhs@restorefont\ignorespaces}
+\setinterclasstoks{halfwidth}{fullwidth}{\mydbgmessage{^^JP}\zhs@savefont\zhfont}
+\setinterclasstoks{fullwidth}{halfwidth}{\mydbgmessage{^^Jp}\zhs@restorefont}
+% derived class alphanum and hanzi
+\newclass[halfwidth]{alphanum}
+\setclassnum{alphanum}{0}
+\newclass[fullwidth]{hanzi}
+\setclassnum{hanzi}{1}
+\setinterclasstoks{hanzi}{hanzi}{\skipzh\relax}
+%\appendinterclasstoks{alphanum}{hanzi}{\mydbgmessage{^^JQ}\skipenzh\relax}
+%\prependinterclasstoks{hanzi}{alphanum}{\mydbgmessage{^^Jq}\skipenzh\relax}
+\setinterclasstoks{alphanum}{hanzi}{\mydbgmessage{^^JQ}\skipenzh\relax\zhs@savefont\zhfont}
+\setinterclasstoks{hanzi}{alphanum}{\mydbgmessage{^^Jq}\zhs@restorefont\skipenzh\relax}
+\setinterclasstoks{hanzi}{boundary}{\mydbgmessage{^^Ji}\zhs@restorefont\zhs@skipspaces}
+\setinterclasstoks{boundary}{hanzi}{\mydbgmessage{^^JI}\zhs@aftermathskip\zhs@savefont\zhfont}
+% derived class from fullwidth
+\newclass[fullwidth]{openfw} % ‘, (, etc
+\setclassnum{openfw}{2}
+\newclass[fullwidth]{closefw} % ’, ), etc
+\setclassnum{closefw}{3}
+\newclass[fullwidth]{halfstop} % ,, , etc
+\setclassnum{halfstop}{4}
+\newclass[fullwidth]{fullstop} % 。 etc
+\setclassnum{fullstop}{10}
+\newclass[fullwidth]{fwpunct} % extra fullwidth punctuations
+\setclassnum{fwpunct}{7}
+% patterns
+\def\zhs@punct@inter#1{%
+ \zhnobreak\csname skipzhinter#1\endcsname\relax
+}
+\def\zhs@leftpunct@after#1{%
+ \allowbreak\csname skipzh#1\endcsname\nobreak\csname skipnegzhlinestart#1\endcsname\vadjust{}\zhnobreak\csname skipzhlinestart#1\endcsname\relax
+}
+\def\zhs@leftpunct@after@boundary#1{%
+ \zhnobreak\csname skipzhlinestart#1\endcsname\relax
+}
+\let\zhs@tmp\relax
+\def\zhs@leftpunct@before@boundary#1{\def\zhs@tmp{#1}\futurenonspacelet\zhs@tmpchar\zhs@leftpunct@before@boundary@}
+\def\zhs@leftpunct@before@boundary@{%
+ %\mydbgmessage{left punct before boundary}%
+ %\expandafter\mydbgmessage\expandafter{\meaning\zhs@tmpchar}%
+ \ifcat a\noexpand\zhs@tmpchar % catcode 11
+ \zhs@leftpunct@before@boundary@@
+ \else
+ \ifcat !\noexpand\zhs@tmpchar % catcode 12
+ \zhs@leftpunct@before@boundary@@
+ \fi
+ \fi
+}
+\def\zhs@leftpunct@before@boundary@@{%
+ \chartonum\zhs@tmpchar\zhs@tmpnum
+ \expandafter\ifzhs@isvalidchar\zhs@tmpnum??\ok
+ \edef\zhs@tmpnum{\the\XeTeXcharclass\zhs@tmpnum}%
+ \else
+ \edef\zhs@tmpnum{\getclassnum{cjkextb}}%
+ \fi
+ \zhs@tmp
+}
+\def\zhs@leftpunct@after@right#1#2{%
+ \zhnobreak\csname skipzhlineend#2\endcsname\allowbreak\csname skipnegzhlineend#2\endcsname\csname skipzhinter#2\endcsname\csname skipzhinter#1\endcsname\csname skipnegzhlinestart#1\endcsname\vadjust{}\zhnobreak\csname skipzhlinestart#1\endcsname\relax
+}
+\def\zhs@rightpunct@before#1{%
+ \zhnobreak\csname skipzhlineend#1\endcsname\allowbreak\csname skipnegzhlineend#1\endcsname\csname skipzh#1\endcsname\relax
+}
+\def\zhs@rightpunct@before@boundary#1{\def\zhs@tmp{#1}\futurenonspacelet\zhs@tmpchar\zhs@rightpunct@before@boundary@}
+\def\zhs@rightpunct@before@boundary@{%
+ %\mydbgmessage{right punct before boundary}%
+ %\expandafter\mydbgmessage\expandafter{\meaning\zhs@tmpchar}%
+ \ifcat a\noexpand\zhs@tmpchar % catcode 11
+ \zhs@rightpunct@before@boundary@@
+ \else
+ \ifcat !\noexpand\zhs@tmpchar % catcode 12
+ \zhs@rightpunct@before@boundary@@
+ \fi
+ \fi
+}
+\def\zhs@rightpunct@before@boundary@@{%
+ \chartonum\zhs@tmpchar\zhs@tmpnum
+ \expandafter\ifzhs@isvalidchar\zhs@tmpnum??\ok
+ \edef\zhs@tmpnum{\the\XeTeXcharclass\zhs@tmpnum}%
+ \else
+ \edef\zhs@tmpnum{\getclassnum{cjkextb}}%
+ \fi
+ \zhs@tmp
+}
+% open fullwidth punctuation after other characters
+\@for\zhs@class:={hanzi,fwpunct,alphanum,halfwidth}\do{%,boundary
+ \prependinterclasstoks{\zhs@class}{openfw}{\mydbgmessage{^^JA1}\zhs@leftpunct@after{open}}
+}
+\setinterclasstoks{openfw}{openfw}{\mydbgmessage{^^JA2}\zhs@punct@inter{open}}
+\setinterclasstoks{closefw}{openfw}{\mydbgmessage{^^JA3}\zhs@leftpunct@after@right{open}{close}}
+\setinterclasstoks{halfstop}{openfw}{\mydbgmessage{^^JA4}\zhs@leftpunct@after@right{open}{halfstop}}
+\setinterclasstoks{fullstop}{openfw}{\mydbgmessage{^^JA4}\zhs@leftpunct@after@right{open}{fullstop}}
+% close fullwidth punctuation before other characters
+\@for\zhs@class:={hanzi,fwpunct,alphanum,halfwidth}\do{%,boundary
+ \prependinterclasstoks{closefw}{\zhs@class}{\mydbgmessage{^^JB1}\zhs@rightpunct@before{close}}
+}
+\setinterclasstoks{closefw}{closefw}{\mydbgmessage{^^JB2}\zhs@punct@inter{close}}
+\setinterclasstoks{closefw}{halfstop}{\mydbgmessage{^^JB3}\zhs@punct@inter{close}}
+\setinterclasstoks{closefw}{fullstop}{\mydbgmessage{^^JB3}\zhs@punct@inter{close}}
+% halfstop punctuation before other characters
+\@for\zhs@class:={hanzi,fwpunct,alphanum,halfwidth}\do{%,boundary
+ \prependinterclasstoks{halfstop}{\zhs@class}{\mydbgmessage{^^JC1}\zhs@rightpunct@before{halfstop}}
+}
+\setinterclasstoks{halfstop}{closefw}{\mydbgmessage{^^Jb2}\zhs@punct@inter{halfstop}}
+\setinterclasstoks{halfstop}{halfstop}{\mydbgmessage{^^JC2}\zhs@punct@inter{halfstop}}
+\setinterclasstoks{halfstop}{fullstop}{\mydbgmessage{^^JC2}\zhs@punct@inter{halfstop}}
+% fullstop punctuation before other characters
+\@for\zhs@class:={hanzi,fwpunct,alphanum,halfwidth}\do{%,boundary
+ \prependinterclasstoks{fullstop}{\zhs@class}{\mydbgmessage{^^JC1}\zhs@rightpunct@before{fullstop}}
+}
+\setinterclasstoks{fullstop}{closefw}{\mydbgmessage{^^Jb2}\zhs@punct@inter{fullstop}}
+\setinterclasstoks{fullstop}{halfstop}{\mydbgmessage{^^JC2}\zhs@punct@inter{fullstop}}
+\setinterclasstoks{fullstop}{fullstop}{\mydbgmessage{^^JC2}\zhs@punct@inter{fullstop}}
+% open fullwidth punctuation before other characters
+\@for\zhs@class:={hanzi,fwpunct,alphanum,halfwidth,closefw,halfstop,fullstop}\do{%,boundary
+ \prependinterclasstoks{openfw}{\zhs@class}{\mydbgmessage{^^Ja}\zhnobreak}
+}
+% close fullwidth punctuation after other characters
+\@for\zhs@class:={hanzi,fwpunct,alphanum,halfwidth,boundary}\do{%
+ \prependinterclasstoks{\zhs@class}{closefw}{\mydbgmessage{^^Jb}\zhnobreak}
+}
+% halfstop punctuation after other characters
+\@for\zhs@class:={hanzi,fwpunct,alphanum,halfwidth,boundary}\do{%
+ \prependinterclasstoks{\zhs@class}{halfstop}{\mydbgmessage{^^Jc}\zhnobreak}
+}
+% fullstop punctuation after other characters
+\@for\zhs@class:={hanzi,fwpunct,alphanum,halfwidth,boundary}\do{%
+ \prependinterclasstoks{\zhs@class}{fullstop}{\mydbgmessage{^^Jc}\zhnobreak}
+}
+% boundary special treat
+\prependinterclasstoks{boundary}{openfw}{\mydbgmessage{^^JA0}\zhs@leftpunct@after@boundary{open}}
+\appendinterclasstoks{closefw}{boundary}{\mydbgmessage{^^JB0}\zhs@rightpunct@before@boundary{%
+ \ifnum\zhs@tmpnum = \getclassnum{closefw}%
+ %\getinterclasstoks{closefw}{closefw}%
+ \zhs@punct@inter{close}%
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{halfstop}%
+ %\getinterclasstoks{closefw}{halfstop}%
+ \zhs@punct@inter{close}%
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{fullstop}%
+ \zhs@punct@inter{close}%
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{openfw}%
+ %\getinterclasstoks{closefw}{openfw}%
+ \zhs@leftpunct@after@right{open}{close}%
+ \zhnobreak\skipnegzhlinestartopen\relax % compensate
+ \else
+ \zhs@rightpunct@before{close}%
+ \fi
+ \fi
+ \fi
+ \fi
+}}
+\appendinterclasstoks{halfstop}{boundary}{\mydbgmessage{^^JC0}\zhs@rightpunct@before@boundary{%
+ \ifnum\zhs@tmpnum = \getclassnum{closefw}%
+ %\getinterclasstoks{halfstop}{closefw}%
+ \zhs@punct@inter{halfstop}%
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{halfstop}%
+ %\getinterclasstoks{halfstop}{halfstop}%
+ \zhs@punct@inter{halfstop}%
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{fullstop}%
+ \zhs@punct@inter{halfstop}%
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{openfw}%
+ %\getinterclasstoks{halfstop}{openfw}%
+ \zhs@leftpunct@after@right{open}{halfstop}%
+ \zhnobreak\skipnegzhlinestartopen\relax % compensate
+ \else
+ \zhs@rightpunct@before{halfstop}%
+ \fi
+ \fi
+ \fi
+ \fi
+}}
+\appendinterclasstoks{fullstop}{boundary}{\mydbgmessage{^^JC0}\zhs@rightpunct@before@boundary{%
+ \ifnum\zhs@tmpnum = \getclassnum{closefw}%
+ \zhs@punct@inter{fullstop}%
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{halfstop}%
+ \zhs@punct@inter{fullstop}%
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{fullstop}%
+ \zhs@punct@inter{fullstop}%
+ \else
+ \ifnum\zhs@tmpnum = \getclassnum{openfw}%
+ \zhs@leftpunct@after@right{open}{fullstop}%
+ \zhnobreak\skipnegzhlinestartopen\relax % compensate
+ \else
+ \zhs@rightpunct@before{fullstop}%
+ \fi
+ \fi
+ \fi
+ \fi
+}}
+\appendinterclasstoks{openfw}{boundary}{\mydbgmessage{^^Ja0}\zhs@leftpunct@before@boundary{%
+ \ifnum\zhs@tmpnum = \getclassnum{openfw}%
+ %\getinterclasstoks{openfw}{openfw}%
+ \zhs@punct@inter{open}%
+ \zhnobreak\skipnegzhlinestartopen\relax % compensate
+ \fi
+}}
+% punctuation font change
+\@for\zhs@class:={openfw,closefw,halfstop,fullstop,fwpunct}\do{%
+ \appendinterclasstoks{hanzi}{\zhs@class}{\zhpunctfont}
+ \appendinterclasstoks{\zhs@class}{hanzi}{\zhfont}
+ \appendinterclasstoks{boundary}{\zhs@class}{\zhpunctfont}
+ \appendinterclasstoks{halfwidth}{\zhs@class}{\zhpunctfont}
+}
+% CJK Ext-A/B support
+\newclass[hanzi]{cjkexta}
+\setclassnum{cjkexta}{8}
+\newclass[hanzi]{cjkextb}
+\setclassnum{cjkextb}{9}
+\@for\zhs@class:={hanzi,fwpunct,openfw,closefw,halfstop,fullstop,alphanum,halfwidth,boundary}\do{%
+ \appendinterclasstoks{\zhs@class}{cjkexta}{\zhcjkextafont}
+ \appendinterclasstoks{\zhs@class}{cjkextb}{\zhcjkextbfont}
+ \prependinterclasstoks{cjkexta}{\zhs@class}{\zhfont}
+ \prependinterclasstoks{cjkextb}{\zhs@class}{\zhfont}
+}
+\setinterclasstoks{cjkexta}{cjkexta}{\skipzh\relax}
+\setinterclasstoks{cjkexta}{cjkextb}{\zhcjkextbfont\skipzh\relax}
+\setinterclasstoks{cjkextb}{cjkexta}{\zhcjkextafont\skipzh\relax}
+\setinterclasstoks{cjkextb}{cjkextb}{\skipzh\relax}
+{
+\newcount\n
+\n="3400 \loop \ifnum\n<"4E00 \global\XeTeXcharclass\n=8 \advance\n by 1\repeat
+\n="20000\loop \ifnum\n<"30000 \global\XeTeXcharclass\n=9 \advance\n by 1\repeat
+}
+% long fullwidth punctuations
+\newclass[fwpunct]{longpunct} % … etc
+\setclassnum{longpunct}{5}
+\setinterclasstoks{longpunct}{longpunct}{\zhnobreak}
+% derived class from halfwidth
+\newclass[halfwidth]{hwpunct} % (, ., etc
+\setclassnum{hwpunct}{6}
+
+% Font settings
+\ifLaTeX@e
+ \RequirePackage{fontspec}
+ \@ifundefined{zhfont}{\newfontfamily\zhfont[BoldFont=SimHei]{SimSun}}{}
+ \@ifundefined{zhpunctfont}{\newfontfamily\zhpunctfont{SimSun}}{}
+ \@ifundefined{zhcjkextafont}{\def\zhcjkextafont{\message{CJK Ext-A}}}{}
+ \@ifundefined{zhcjkextbfont}{\def\zhcjkextbfont{\message{CJK Ext-B}}}{}
+\else
+ \@ifundefined{zhfont}{\font\zhfont="SimSun" at 10pt}{}
+ \@ifundefined{zhpunctfont}{\font\zhpunctfont="SimSun" at 10pt}{}
+ \@ifundefined{zhcjkextafont}{\def\zhcjkextafont{\message{CJK Ext-A}}}{}
+ \@ifundefined{zhcjkextbfont}{\def\zhcjkextbfont{\message{CJK Ext-B}}}{}
+\fi
+
+% code range utils
+\newif\ifzhs@result
+\newcount\zhs@tmpcnt
+\def\@ifnuminrange#1#2#3#4{% #1: num, #2: range with format a->b,c->d
+ % #3: true block, #4: false block
+ \zhs@resultfalse
+ \@for\zhs@range:=#2\do{%
+ \expandafter\@ifrangecontains\expandafter[\zhs@range]{#1}{\zhs@resulttrue}{}%
+ }%
+ \ifzhs@result #3\else #4\fi
+}
+
+\def\@ifrangecontains[#1->#2]#3#4#5{%
+ \ifnum#3<#1\relax
+ #5%
+ \else
+ \ifnum#3>#2\relax
+ #5%
+ \else
+ #4%
+ \fi
+ \fi
+}
+
+\def\@fornuminrange#1:=#2\do#3{% #1: count register, #2: range
+ \@for\zhs@range:=#2\do{%
+ \expandafter\@@fornuminrange\expandafter[\zhs@range]{#1}{#3}%
+ }%
+}
+\def\@@fornuminrange[#1->#2]#3#4{%
+ #3=#1%
+ \loop
+ \unless\ifnum#3>#2\relax
+ #4\relax
+ \advance #3by 1%
+ \repeat
+}
+
+\def\zhs@hanzirange{% data from unicodeletters.tex
+ "2E80->"2E99,
+ "2E9B->"2EF3,
+ "2F00->"2FD5,
+ "2FF0->"2FFB,
+ "3000->"3000,
+ "3003->"3004,
+ "3006->"3007,
+ "3012->"3013,
+ "3020->"3029,
+ "3030->"303A,
+ "303D->"303F,
+ "3042->"3042,
+ "3044->"3044,
+ "3046->"3046,
+ "3048->"3048,
+ "304A->"3062,
+ "3064->"3082,
+ "3084->"3084,
+ "3086->"3086,
+ "3088->"308D,
+ "308F->"3094,
+ "309F->"309F,
+ "30A2->"30A2,
+ "30A4->"30A4,
+ "30A6->"30A6,
+ "30A8->"30A8,
+ "30AA->"30C2,
+ "30C4->"30E2,
+ "30E4->"30E4,
+ "30E6->"30E6,
+ "30E8->"30ED,
+ "30EF->"30F4,
+ "30F7->"30FA,
+ "30FF->"30FF,
+ "3105->"312C,
+ "3131->"318E,
+ "3190->"31B7,
+ "31C0->"31CF,
+ "3200->"321E,
+ "3220->"3243,
+ "3250->"32FE,
+ "3300->"33FF,
+ "3400->"4DB5,
+ "4E00->"9FBB,
+ "A000->"A014,
+ "A016->"A48C,
+ "A490->"A4C6,
+ "F900->"FA2D,
+ "FA30->"FA6A,
+ "FA70->"FAD9,
+ "FE30->"FE34,
+ "FE45->"FE46,
+ "FE49->"FE4F,
+ "FE51->"FE51,
+ "FE58->"FE58,
+ "FE5F->"FE66,
+ "FE68->"FE68,
+ "FE6B->"FE6B,
+ "FF02->"FF03,
+ "FF06->"FF07,
+ "FF0A->"FF0B,
+ "FF0D->"FF0D,
+ "FF0F->"FF19,
+ "FF1C->"FF1E,
+ "FF20->"FF3A,
+ "FF3C->"FF3C,
+ "FF3E->"FF5A,
+ "FF5C->"FF5C,
+ "FF5E->"FF5E,
+ "FFE2->"FFE4,
+ "20000->"2A6D6,
+ "2F800->"2FA1D
+}
+\def\zhs@extarange{"3400->"4DB5}
+\def\zhs@extbrange{"20000->"2FA1D}
+
+% set active hanzi for hooking
+\def\makehanziglobalactive{%
+ \@fornuminrange\zhs@tmpcnt:=\zhs@hanzirange\do{%
+ \global\catcode\zhs@tmpcnt=\active}%
+}
+
+\def\makehanzigloballetter{%
+ \@fornuminrange\zhs@tmpcnt:=\zhs@hanzirange\do{%
+ \global\catcode\zhs@tmpcnt=11}%
+}
+
+\def\zhhanzihook#1{{\XeTeXinterchartokenstate=0\zhs@font #1}}
+
+\def\zhs@h@x#1{\ifcase#1 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or
+ 9\or A\or B\or C\or D\or E\or F\fi}
+\def\zhs@hex#1{\if!#1!\else\ifnum#1<16 \zhs@h@x{#1}\else
+ \expandafter\zhs@hex\expandafter{\number\numexpr(#1-8)/16}%
+ \expandafter\zhs@h@x\expandafter{\number\numexpr#1-(#1-8)/16*16}\fi\fi}
+
+\let\zhs@font\zhfont
+\def\enableactivehanzi{%
+ \def\zhs@@a##1{\zhs@afteralphamathskip
+ \expandafter\@ifrangecontains\expandafter[\zhs@extarange]{"##1}{\global
+ \let\zhs@font\zhcjkextafont}{\expandafter\@ifrangecontains
+ \expandafter[\zhs@extbrange]{"##1}{\global\let\zhs@font\zhcjkextbfont
+ }{\global\let\zhs@font\zhfont}}%
+ \zhhanzihook{\char"##1}\zhs@active@lookafter}%
+ \@fornuminrange\zhs@tmpcnt:=\zhs@hanzirange\do{%
+ \lccode`\~=\zhs@tmpcnt
+ \lowercase{\protected\xdef~{\noexpand\zhs@@a{\expandafter\zhs@hex
+ \expandafter{\number\zhs@tmpcnt}}}}%
+ }%
+}
+
+\def\zhs@afteralphamathskip{%
+ \ifhmode
+ \ifnum\lastnodetype=10 % math node
+ \skipenzh\relax
+ \else\ifnum\lastnodetype=0
+ \ifnum\spacefactor=999
+ \skipenzh
+ \else\ifnum\spacefactor=1000
+ \skipenzh
+ \fi\fi
+ \fi\fi
+ \fi
+}
+
+{\escapechar=-1
+ \xdef\zhs@active@ident{\string\zhs@@a}
+}
+\expandafter\def\expandafter\ifzhs@notactivehanzi\expandafter#\expandafter1%
+ \zhs@active@ident#2\ok{\if!#2!}
+\def\zhs@active@lookafter{\futurenonspacelet\zhs@tmpchar\zhs@active@look@fter}
+\def\zhs@active@look@fter{%
+ %\expandafter\mydbgmessage\expandafter{\meaning\zhs@tmpchar}%
+ \if\relax\noexpand\zhs@tmpchar % control sequence
+ \zhs@beforeactivehanziskip
+ \else
+ \ifcat a\noexpand\zhs@tmpchar % catcode 11
+ \zhs@testskipenzh
+ \else
+ \ifcat !\noexpand\zhs@tmpchar % catcode 12
+ \zhs@testskipenzh
+ \else
+ \ifcat $\noexpand\zhs@tmpchar % catcode 3
+ \skipenzh\relax
+ \fi
+ \fi
+ \fi
+ \fi
+}
+
+\def\zhs@beforeactivehanziskip{%
+ %\let\zhs@tmp\iffalse % for \if match
+ \edef\zhs@tmp{\meaning\zhs@tmpchar}%
+ \expandafter\expandafter\expandafter\ifzhs@notactivehanzi
+ \expandafter\zhs@tmp\zhs@active@ident\ok
+ \else
+ \skipzh\relax
+ \fi
+}
+
+\def\zhspacing{%
+ \@for\zhs@char:={`:,`,,`、}\do{\XeTeXcharclass\zhs@char=4}
+ \@for\zhs@char:={`。,`.,`;}\do{\XeTeXcharclass\zhs@char=10}
+ \ifzhs@ambiwide
+ \@for\zhs@char:={`“,`‘}\do{\XeTeXcharclass\zhs@char=2}
+ \@for\zhs@char:={`”,`’}\do{\XeTeXcharclass\zhs@char=3}
+ \@for\zhs@char:={`—,`…}\do{\XeTeXcharclass\zhs@char=5}
+ \else
+ \@for\zhs@char:={`“,`‘,`”,`’,`—,`…}\do{\XeTeXcharclass\zhs@char=6}
+ \fi
+ \@for\zhs@char:={`\!,`\",`\',`\(,`\),`\,,`\-,`\.,`\:,`\;,`\<,`\>,`\?,`\[,`\],`\`,`\{,`\},`\\,`\/}\do{\XeTeXcharclass\zhs@char=6}
+ \@for\zhs@char:={`℃,`·,`$,`%}\do{\XeTeXcharclass\zhs@char=7}
+ % clear XeTeX pre-defined toks
+ \XeTeXinterchartoks 0 1 = {}
+ \XeTeXinterchartoks 0 2 = {}
+ \XeTeXinterchartoks 0 3 = {}
+ \XeTeXinterchartoks 1 0 = {}
+ \XeTeXinterchartoks 2 0 = {}
+ \XeTeXinterchartoks 3 0 = {}
+ \XeTeXinterchartoks 1 1 = {}
+ \XeTeXinterchartoks 1 2 = {}
+ \XeTeXinterchartoks 1 3 = {}
+ \XeTeXinterchartoks 2 1 = {}
+ \XeTeXinterchartoks 2 2 = {}
+ \XeTeXinterchartoks 2 3 = {}
+ \XeTeXinterchartoks 3 1 = {}
+ \XeTeXinterchartoks 3 2 = {}
+ \XeTeXinterchartoks 3 3 = {}
+ \registerXeTeXclasstoks
+ \XeTeXinterchartokenstate=1\relax
+ \ifLaTeX@e
+ \setbox0=\hbox{\normalsize\def\zhs@tmp{\kern 2em}\zhs@tmp}%
+ \parindent=\wd0
+ \else
+ \parindent=2em\relax
+ \fi
+ \message{zhspacing installed.^^J}
+}
+
+\fi
diff --git a/Master/texmf-dist/tex/xetex/zhspacing/plain/zhsusefulmacros.sty b/Master/texmf-dist/tex/xetex/zhspacing/plain/zhsusefulmacros.sty
new file mode 100644
index 00000000000..96b5d720e7c
--- /dev/null
+++ b/Master/texmf-dist/tex/xetex/zhspacing/plain/zhsusefulmacros.sty
@@ -0,0 +1,97 @@
+% zhsusefulmacros.sty
+% This file provides several useful LaTeX macros as well as \ifLaTeX@e,
+% and \futurenonspacelet.
+% Licensed under LPPL.
+\catcode`\@=11
+\ifx\@usefulmacros@defined\@undefined
+\def\@usefulmacros@defined{\relax}
+\def\@usefulmacros@LaTeX@e{LaTeX2e}
+\def\ifLaTeX@e{\ifx\fmtname\@usefulmacros@LaTeX@e}
+%\ifx\LaTeX\@undefined
+\ifLaTeX@e\else
+\def\@nnil{\@nil}%
+\def\@empty{}%
+\def\@fornoop#1\@@#2#3{}%
+\long\def\@for#1:=#2\do#3{%
+ \expandafter\def\expandafter\@fortmp\expandafter{#2}%
+ \ifx\@fortmp\@empty \else
+ \expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}\fi}%
+\long\def\@forloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
+ #5\def#4{#2}\ifx #4\@nnil \else#5\@iforloop #3\@@#4{#5}\fi\fi}%
+\long\def\@iforloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
+ \expandafter\@fornoop \else
+ #4\relax\expandafter\@iforloop\fi#2\@@#3{#4}}%
+\def\@tfor#1:={\@tf@r#1 }%
+\long\def\@tf@r#1#2\do#3{\def\@fortmp{#2}\ifx\@fortmp\space\else
+ \@tforloop#2\@nil\@nil\@@#1{#3}\fi}%
+\long\def\@tforloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
+ \expandafter\@fornoop \else
+ #4\relax\expandafter\@tforloop\fi#2\@@#3{#4}}%
+\long\def\@ifnextchar#1#2#3{%
+ \let\reserved@d=#1%
+ \def\reserved@a{#2}%
+ \def\reserved@b{#3}%
+ \futurelet\@let@token\@ifnch}
+\def\@ifnch{%
+ \ifx\@let@token\@sptoken
+ \let\reserved@c\@xifnch
+ \else
+ \ifx\@let@token\reserved@d
+ \let\reserved@c\reserved@a
+ \else
+ \let\reserved@c\reserved@b
+ \fi
+ \fi
+ \reserved@c}
+\def\:{\let\@sptoken= } \: % this makes \@sptoken a space token
+\def\:{\@xifnch} \expandafter\def\: {\futurelet\@let@token\@ifnch}
+%
+\long\def\@firstoftwo#1#2{#1}
+\long\def\@secondoftwo#1#2{#2}
+\expandafter\ifx\csname ifcsname\endcsname\relax
+\def\@ifundefined#1{%
+ \expandafter\ifx\csname#1\endcsname\relax
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+\else
+\def\@ifundefined#1{%
+ \unless\ifcsname#1\endcsname
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+\fi
+%
+\def\@namedef#1{\expandafter\def\csname #1\endcsname}
+%
+\fi % end if
+
+\def\@BTcs{}
+\let\nexttoken\relax
+\let\next\relax
+\def\futurenonspacelet#1{\def\@BTcs{#1}%
+ \afterassignment\@BTfnslone\let\nexttoken= }
+\def\@BTfnslone{\expandafter\futurelet\@BTcs\@BTfnsltwo}
+\def\@BTfnsltwo{\expandafter\ifx\@BTcs\@sptoken\let\next=\@BTfnslthree
+ \else\let\next=\nexttoken\fi \next}
+\def\@BTfnslthree{\afterassignment\@BTfnslone\let\next= }
+
+\ifx\fbox\@undefined
+\newbox\fbox@tmpbox
+\newdimen\fbox@linewidth
+\newdimen\fbox@tmpdim
+\fbox@linewidth=0.4pt
+\long\def\fbox#1{%
+ \setbox\fbox@tmpbox=\hbox{#1}%
+ \fbox@tmpdim=2\fbox@linewidth
+ \advance\fbox@tmpdim\wd\fbox@tmpbox
+ \leavevmode\hbox{\vbox{\hrule height \fbox@linewidth width \fbox@tmpdim
+ \hbox{\vrule width \fbox@linewidth height \ht\fbox@tmpbox
+ #1\vrule width \fbox@linewidth height \ht\fbox@tmpbox}%
+ \hrule height \fbox@linewidth width \fbox@tmpdim
+ }}%
+}
+\fi
+\fi
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index 87fda669940..41ea12d6bb5 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -262,7 +262,7 @@ my @WorkingTLP = qw(
xkeyval xlop xltxtra xmpincl xnewcommand xoptarg xpackages
xq xskak xstring xtab xtcapts xunicode xyling xypic-tut-pt xytree
yagusylo york-thesis yplan
- ziffer zwgetfdate zwpagelayout
+ ziffer zhspacing zwgetfdate zwpagelayout
);
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index ca0a71a2551..b13610c5712 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -604,6 +604,7 @@ chdir $startdir || die "chdir($startdir) failed: $!"; # back to raw
'splitindex' => '&POSTsplitindex',
'xecyr' => '&POSTxecyr',
'xetex-pstricks' => '&POSTxetex_pstricks',
+ 'zhspacing' => '&POSTzhspacing',
);
@@ -777,13 +778,14 @@ $standardsourcefmt='latex';
'vaucanson-g', 'generic',
'vertex', 'plain',
'wasy2', 'plain',
- 'xepersian', 'xelatex',
- 'xetex-def', 'xelatex',
- 'xetexfontinfo','xetex',
- 'xltxtra', 'xelatex',
- 'xmlplay', 'xmltex',
- 'xstring', 'generic',
- 'xunicode', 'xelatex',
+ 'xepersian', 'xelatex',
+ 'xetex-def', 'xelatex',
+ 'xetexfontinfo', 'xetex',
+ 'xltxtra', 'xelatex',
+ 'xmlplay', 'xmltex',
+ 'xstring', 'generic',
+ 'xunicode', 'xelatex',
+ 'zhspacing', 'xetex',
);
$standardfmt='latex';
@@ -3749,6 +3751,15 @@ sub POSTxetex_pstricks
&SYSTEM ("$MV generic xelatex xetex tex");
}
+sub POSTzhspacing
+{
+ print "POST$package - move subdirectories.\n";
+ my $dstdir = "$DEST/tex/xetex/$package";
+ &xmkdir ($dstdir);
+ &SYSTEM ("$MV context latex plain $dstdir/");
+ &SYSTEM ("$MV doc/* .; rmdir doc");
+}
+
# Allow overrides. In particular, CTAN can change some hashes to make
# packages with licenses that TL doesn't allow.
diff --git a/Master/tlpkg/tlpsrc/collection-langcjk.tlpsrc b/Master/tlpkg/tlpsrc/collection-langcjk.tlpsrc
index c52afd7f631..1352b75aa82 100644
--- a/Master/tlpkg/tlpsrc/collection-langcjk.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-langcjk.tlpsrc
@@ -15,5 +15,6 @@ depend norasi-c90
depend thaifonts
depend uhc
depend wadalab
+depend zhspacing
depend collection-basic
depend collection-documentation-chinese
diff --git a/Master/tlpkg/tlpsrc/zhspacing.tlpsrc b/Master/tlpkg/tlpsrc/zhspacing.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/zhspacing.tlpsrc