summaryrefslogtreecommitdiff
path: root/macros/xetex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-10-02 03:03:32 +0000
committerNorbert Preining <norbert@preining.info>2021-10-02 03:03:32 +0000
commitac5a96ddb02c62d71eb214ed35e3be9a154d991f (patch)
treecdf35312568ce6b2b69e7374745ddafdd3e3c66b /macros/xetex
parent569e4d488d3398f8ed12807dd67e2b301b7447d5 (diff)
CTAN sync 202110020303
Diffstat (limited to 'macros/xetex')
-rw-r--r--macros/xetex/latex/zitie/README.md17
-rw-r--r--macros/xetex/latex/zitie/doc/zitie-cn.pdfbin288061 -> 339839 bytes
-rw-r--r--macros/xetex/latex/zitie/doc/zitie-cn.tex481
-rw-r--r--macros/xetex/latex/zitie/tex/zitie.luatex.def90
-rw-r--r--macros/xetex/latex/zitie/tex/zitie.sty689
-rw-r--r--macros/xetex/latex/zitie/tex/zitie.xetex.def52
6 files changed, 1031 insertions, 298 deletions
diff --git a/macros/xetex/latex/zitie/README.md b/macros/xetex/latex/zitie/README.md
index f70e1fc844..d8bdf4f0de 100644
--- a/macros/xetex/latex/zitie/README.md
+++ b/macros/xetex/latex/zitie/README.md
@@ -3,11 +3,10 @@
zitie is a LaTeX package for making CJK character calligraphy practicing
sheet (copybook).
-zitie distinguishes `CJK` Classes and `Punctutation` Classes (`FullLeft`,
-`FullRight`, `HalfLeft`, `HalfRight`) and other Classes.
-
## Main Interfaces
+`\framesingle[<options>]{<CJK char>}`, makes frame for single <CJK char>
+
`\framezi*[<options>]{<CJK chars>}`, makes frame for every single <CJK chars>
`\framezifile*[<options>]{<filename>}`, makes frame from <filename>
@@ -16,6 +15,10 @@ containning <CJK chars>
`\framerange[<options>]{<char Hex range>}`, makes frame from Hex range,
such as: "4E00 -> "4E27, "4E30. etc
+`\frametallrange[<options>]{<char Hex range>}`
+
+`\framezitallfile*[<options>]{<filename>}`
+
`\zitienewfont*{...}`, declares new font(s) for making frame
`\framezhlipsum[<options>]{<paragraphs>}[<name>]`, frames Lorem ipsum given
@@ -40,7 +43,7 @@ See PDF documentation (in chinese) for more details.
Please note the frame functions of this package currently do need many TeX
computation, so the compiling maybe very slow.
-Currently, only support XeTeX.
+Support XeTeX and LuaTeX, but the function in LuaTeX is limited.
## Dependence:
@@ -50,10 +53,10 @@ is very experimental, some interfaces maybe cannot use later.
Need not `pgf` or `pstricks`.
## TODO:
-- faster and less resource
+- **faster and less resource**
+- **optimize line breaking algorithm**
- optimize `background` module
-- support LuaTeX
-- support pinyin
+- optimize LuaTeX supporting
- more grid
- more transformation
- support more character Classes
diff --git a/macros/xetex/latex/zitie/doc/zitie-cn.pdf b/macros/xetex/latex/zitie/doc/zitie-cn.pdf
index fef8c4afec..23c40336e1 100644
--- a/macros/xetex/latex/zitie/doc/zitie-cn.pdf
+++ b/macros/xetex/latex/zitie/doc/zitie-cn.pdf
Binary files differ
diff --git a/macros/xetex/latex/zitie/doc/zitie-cn.tex b/macros/xetex/latex/zitie/doc/zitie-cn.tex
index e310b6f930..f88fcb266d 100644
--- a/macros/xetex/latex/zitie/doc/zitie-cn.tex
+++ b/macros/xetex/latex/zitie/doc/zitie-cn.tex
@@ -2,31 +2,46 @@
\documentclass{ctxdoc}
\usepackage[enable-zhlipsum,enable-background]{zitie}
\usepackage{geometry}
+\usepackage{xcoffins}
+
+\def\zitieversion{1.4.0}
+\def\zitiedate{农历二〇二一年八月廿五}
+\def\zitieframetitle{
+ \framezi[width=3\ccwd,fillcolor=black,charcolor=red!75!black,font=文征明行草简繁,anchor=west]{字}%
+ \framezi[width=3\ccwd,fillcolor=black,charcolor=red!75!black,font=文征明行草简繁,position*={\TypesetCoffin##1[l,vc](-.4pt,0pt)}]{帖}%
+ \framezi[width=1.5\ccwd,font=楷体,position*={\TypesetCoffin##1[l,b](-.2pt,-.2pt)}]{宏}%
+ \framezi[width=1.5\ccwd,font=楷体,position*={\TypesetCoffin##1[r,t](0pt,.2pt)}]{包}%
+}
+\def\zitietexttitle{zitie宏包}
+\def\emptyframe#1{\framezi[#1,charstroke=invisible]{ }}
+\let\emptyCJKchar= % U+3000
\NewDocumentCommand{\init}{+v}{\hspace{\fill}初始值~=~\textcolor{blue}{\bfseries#1}}
-\IfFontExistsTF{KaiTi}{\zitienewfont{{楷体}{KaiTi}}}{}
-\IfFontExistsTF{FZSunGuoTingCaoShuFU}{\zitienewfont{{孙过庭草繁}{FZSunGuoTingCaoShuFU}{FallBack=SimSun}}}{}
-\IfFontExistsTF{FZWenZhengMingXingCaoJF}{\zitienewfont{{文征明行草简繁}{FZWenZhengMingXingCaoJF}{FallBack=KaiTi}}}{}
+\IfFontExistsTF{KaiTi}{\zitienewfont{{楷体}{KaiTi}}}{\typeout{KaiTi not exist.}}
+\IfFontExistsTF{FZSunGuoTingCaoShuFU}{\zitienewfont{{孙过庭草繁}{FZSunGuoTingCaoShuFU}{FallBack=SimSun}}}{\typeout{FZSunGuoTingCaoShuFU not exist.}}
+\IfFontExistsTF{FZWenZhengMingXingCaoJF}{\zitienewfont{{文征明行草简繁}{FZWenZhengMingXingCaoJF}{FallBack=KaiTi}}}{\typeout{FZWenZhengMingXingCaoJF not exist.}}
\zitiesetup{
framecolor=green!60!black,charcolor=red!65!black,
resize=square,frametype=咪,font,savefontname,
}
-\def\zitieversion{1.1}
-\title{\texorpdfstring{\framezi[width=3\ccwd,fillcolor=black,charcolor=red!75!black,font=文征明行草简繁]{字帖}\framezi[width=2\ccwd,font=楷体]{宏包}}{zitie宏包}}
-\date{\texorpdfstring{\framezi[width=2\ccwd,font=文征明行草简繁]{农历二〇二一年八月十五}}{农历二〇二一年八月十五} v\zitieversion}
-\author{陈文建(Longaster)}
+\title{\texorpdfstring{\zitieframetitle}{\zitietexttitle}}
+\date{\texorpdfstring{\framezi*[width=2\ccwd,font=文征明行草简繁,anchor=west]{\zitiedate}}{\zitiedate} v\zitieversion}
+\author{雾月, Longaster (\texttt{longaster@163.com})}
\begin{document}
-\newgeometry{textheight=27cm,textwidth=17cm,bottom=1.7cm}
+\newgeometry{nomarginpar,textheight=27cm,textwidth=17cm,bottom=1.7cm}
+
+\zitiesetup{holdbasecharheight=true}
+
\maketitle
\thispagestyle{empty}
\parskip=0pt \parindent=0pt \lineskip=0pt \raggedright
\framezi[
- width=1.8cm,punctuation=onlast,
+ width=1.8cm,punctuation=onlast,holdbasecharheight,
fillcolor=black,charcolor=red!75!black,font=文征明行草简繁,
]{
我欲乘風向北行,
@@ -36,19 +51,20 @@
我欲踏云千萬裏,
廟堂龍吟奈我何。}%
\framezi[
- width=1.8cm,punctuation=onlast,charstroke=whitesolid,
+ width=1.8cm,punctuation=onlast,charstroke=whitesolid,holdbasecharheight,
fillcolor=black,charcolor=red!75!black,font=文征明行草简繁,
]{
昆侖之巔沐日光,
滄海絕境見青山。
長風萬裏燕歸來,
- 不見天涯人不回。}
+ 不見天涯人不回。
+ \emptyCJKchar\emptyCJKchar}
\bigskip
\zitienewrule{punctuation}{package1}{\makebox[\zitiewidth][l]{ \zitieCJKfamily{\zitiefontname} #1}}
\framezi[
- width=2.5\ccwd,linewidth=.2pt,
+ width=2.5\ccwd,linewidth=.2pt,holdbasecharheight,
dashpattern={1mm,.5mm},punctuation=package1,
fillcolor={},framecolor=red,charcolor=black,
font=孙过庭草繁,
@@ -65,7 +81,8 @@
不見天涯人不回。
}\hfill ——《少年歌行》
-{\heiti\small 注:本文档中的非商业的字体版权为原字体公司(北京方正有限公司及其它相关公司),此处使用该字体仅为显示该宏包的排版效果,不作商业用途。本文档\pkg{zitie.tex}和相应的\pkg{zitie.sty}源文件使用 \href{https://www.latex-project.org/lppl/lppl-1-3c/}{LPPL 1.3c 协议。}}
+{\heiti\small 注:本文档中的非商业的字体版权为原字体公司(北京方正有限公司及其它相关公司),此处使用该字体仅为显示该宏包的排版效果,不作商业用途。本文档\pkg{zitie.tex}和相应的\pkg{zitie.sty}源文件使用 \href{https://www.latex-project.org/lppl/lppl-1-3c/}{LPPL 1.3c 协议} 开源。}
+\zitiesetup{holdbasecharheight=false}
\clearpage
\restoregeometry
@@ -77,61 +94,70 @@
colboxes=20,rowboxes=30,
]
-\pkg{zitie} 宏包是用纯 \LaTeX3 模块编写的(即,不加载 \pkg{pgf}、\pkg{pstricks} 等绘图宏包),来生成网格化的字、生成网格化的背景的宏包。绘图功能完全依赖 \pkg{l3draw},但应注意 \pkg{l3draw} 目前仍然是实验性的,其接口在后续版本可能无法使用。
+\pkg{zitie} 宏包是用纯 \LaTeX3 模块编写的(即,不加载 \pkg{pgf}、\pkg{pstricks} 等绘图宏包),也不使用 \pkg{xcolor} 宏包,来生成网格化的字、生成网格化的背景的宏包。绘图功能完全依赖 \pkg{l3draw},但应注意 \pkg{l3draw} 目前仍然是实验性的,其接口在后续版本可能无法使用。
\LaTeXe 版本应在 2020-10-01 及以后。
-目前仅支持 \XeTeX,待后续版本支持 \LuaTeX,不支持 \pdfTeX。
+\changes{v1.3}{2021/09/25}{开始支持 \LuaTeX。}
+目前支持 \XeTeX、\LuaTeX,不支持 \pdfTeX。应注意由于 \LuaTeX{} 处理中文字符和 \XeTeX{} 不同,使用 \XeTeX{} 和 \LuaTeX{} 编译效果会有不同,最好使用 \XeTeX{} 编译。
\tableofcontents
\section{\pkg{zitie} 宏包的加载和基本命令}\label{sec:basics}
-加载宏包:\tn{usepackage}\oarg{key-val}\verb|{zitie}|。\meta{key-val} 选项见以下几节。
+加载宏包:\tn{usepackage}\oarg{key-val}\verb|{zitie}|。\meta{key-val} 选项见第 \ref{sec:options} 节。
-若要加载 \pkg{ctex} 宏包,请先加载 \pkg{ctex} 然后再加载 \pkg{zitie} 宏包。若加载本宏包时未加载 \pkg{ctex} 宏包,
-则会加载 \pkg{xeCJK} 宏包和 \pkg{ctexsize} 宏包。如果是Windows平台,还将设置宋体为主字体。
+\changes{v1.2}{2021/09/23}{不再加载 \opt{ctexsize} 宏包。不再设置宋体为主字体}
+使用 \XeTeX 将加载 \pkg{xeCJK} 宏包\cite{pkg-xeCJK}。使用 \LuaTeX{} 将加载 \pkg{ctex} 宏包。
\begin{function}{\zitienewfont,\zitieCJKfamily}
\begin{syntax}
\cs{zitienewfont} \{ \marg{font family} \marg{font name} , ... \}
- \cs{zitienewfont} \{ \marg{font family} \marg{font name} \marg{features} , ... \}
- \cs{zitienewfont} * \marg{font family} \marg{font name} \marg{font feature}
+ \cs{zitienewfont} \{ \marg{font family} \marg{font name} \marg{font features} , ... \}
+ \cs{zitienewfont} * \marg{font family} \marg{font name} \marg{font features}
\cs{zitieCJKfamily} \marg{font family}
- \cs{zitieCJKfamily}+ \marg{font family}
- \cs{zitieCJKfamily}- \marg{font family}
+ \cs{zitieCJKfamily} + \marg{font family}
+ \cs{zitieCJKfamily} - \marg{font family}
\end{syntax}
- 这个命令用来加载和设置需要的字体,\meta{font family} 为在 \cs{framezi} 等命令的 \opt{font} 选项中使用的名字,也可通过 \cs{zitieCJKfamily} 来在文档中使用该字体。\meta{font name} 为字体的名字,\meta{features},为 \pkg{fontspec} 宏包和 \pkg{xeCJK} 宏包支持的字体特性。
+ 这个命令用来加载和设置需要的字体,\meta{font family} 为在 \cs{framezi} 等命令的 \opt{font} 选项中使用的名字,也可通过 \cs{zitieCJKfamily} 来在文档中使用该字体。\meta{font name} 为字体的名字,\meta{features},为 \pkg{fontspec} 宏包\cite{pkg-fontspec},\pkg{xeCJK} 宏包(\XeTeX 中)或 \pkg{luatexja} 宏包(\LuaTeX 中)支持的字体特性。
\cs{zitieCJKfamily} 和 \pkg{xeCJK} 宏包的 \cs{CJKfamily} 作用完全相同,只不过首先判断该 \meta{font family} 是否被 \cs{zitienewfont} 声明,若没有,则再使用 \cs{CJKfamily} 进行处理。
\end{function}
-\begin{function}{\framezi,\framerange,\framezifile}
+\changes{v1.3.2}{2021/09/26}{单个range可达3200字。}
+\changes{v1.4.0}{2021/10/01}{新增 \cs{framesingle} 命令。}
+\begin{function}{\framesingle,\framezi,\framerange,\framezifile}
\begin{syntax}
+ \cs{framesingle} \oarg{key-val} \marg{字}
\cs{framezi} * \oarg{key-val} \marg{字或词句}
\cs{framerange} \oarg{key-val} \marg{逗号分隔的16进制序列}
\cs{framezifile} * \oarg{key-val} \marg{文件名}
\end{syntax}
以上命令用来生成网格化的字。
+
+ \meta{key-val} 为第 \ref{sec:options} 节定义的键。
\meta{字或词句} 应仅包含类代码为 11 或 12 的字符,即正常情况下输入的字符,不应包含 \TeX 控制序列即其它特殊字符。\cs{framezi} 带星号的版本接收一个控制序列,这个序列包含想要网格化的字。
- \meta{逗号分隔的16进制序列} 应使用如下的形式:\verb|"4E00 -> "4E27, "4E30| 或 \verb|`一 -> `丢, `丰|,与其它设置字符序列的宏包相似(如 \pkg{xeCJK} 宏包的 \cs{xeCJKDeclareSubCJKBlock})。注意,由于网格化操作需要大量的计算,因此单个 \meta{range} 不应太大,依据编译环境而定,一般不应超过 1000 个,否则可能无法成功编译。其它命令中也是如此。
+ \meta{逗号分隔的16进制序列} 应使用如下的形式:\verb|"4E00 -> "4E27, "4E30| 或 \verb|`一 -> `丢, `丰|,与其它设置字符序列的宏包相似(如 \pkg{xeCJK} 宏包的 \cs{xeCJKDeclareSubCJKBlock})。注意,由于网格化操作需要大量的计算,因此单个 \meta{range} 不应太大,依据编译环境而定,一般不应超过 3200 个,否则可能无法成功编译。其它命令中也是如此。若要使用大量字符,则可以使用 \cs{frametallrange}、\cs{framezitallfile} 等 \verb|tall| 型命令,或 \pkg{background} 模块及其 \opt{xrange}、\opt{yrange} 特性。
- \meta{文件名} 为想要网格化的文字的文件名。\cs{framezifile} 带 \verb|*| 的版本,可在 \meta{key-val} 中使用 \opt{filepath} 设置文件搜索路径,详见后节的说明。带星号和不带星号的版本实现略有差异,速度也可能不一样。
+ \meta{文件名} 为想要网格化的文字的文件名。\cs{framezifile} 带 \verb|*| 的版本,可在 \meta{key-val} 中使用 \opt{filepath} 设置文件搜索路径,详见第 \ref{sec:options} 节的说明。带星号和不带星号的版本实现略有差异,速度也可能不一样。
- 当连续多次使用 \cs{framezi} 等命令时,为去掉后面的空白,可使用 \opt{\%}。
+ 当连续多次使用 \cs{framezi} 等命令时,为去掉后面的空白,可使用 \opt{\%} 注释符。
+
+ \cs{framesingle} 专门用于制作单个字的方框。
\end{function}
\begin{function}{
+ zitie/framesingle/before, zitie/framesingle/after,
zitie/framezi/before, zitie/framezi/after,
zitie/framerange/before, zitie/framerange/after,
zitie/framerange/range,
- zitie/framezifile/before, zitie/framezifile/after
+ zitie/framezifile/before, zitie/framezifile/after,
}
这三个命令还各自定义了钩子(hook),其中带有 \verb|after| 为 \verb|reversed|,即先添加的后执行。\verb|before| 为选项设置完成后执行,\verb|after| 为整个命令执行完之后执行。其中 \verb|zitie/framerange/range| 为每一个列表均执行一次,包括无效的和最后一次。
- 可以通过 \cs{AddToHook}、\cs{AddToHookNext}、\cs{RemoveFromHook} 来添加和执行,详细请参考 \pkg{source2e.pdf} 或 \pkg{lthooks} 的说明文档。
+ 可以通过 \cs{AddToHook}、\cs{AddToHookNext}、\cs{RemoveFromHook} 来添加和移除,详细请参考 \pkg{source2e.pdf}\cite{pdf-source2e} 或 \pkg{lthooks}\cite{pkg-lthooks} 的说明文档。
\end{function}
\begin{function}{zitieframe,
@@ -153,18 +179,70 @@
\verb|zitie/zitieframe/par| 钩子为环境中的每个段落分段后要执行的命令。
\end{function}
+\begin{function}{
+ \frametallrange,
+ \framezitallfile,
+ zitie/frametallrange/before,
+ zitie/frametallrange/after,
+ zitie/frametallrange/range,
+ zitie/framezitallfile/before,
+ zitie/framezitallfile/after
+}
+ \begin{syntax}
+ \cs{frametallrange} \oarg{key-val} \marg{逗号分隔的16进制序列}
+ \cs{framezitallfile} * \oarg{key-val} \marg{文件名}
+ \end{syntax}
+ 一般情况下 \pkg{zitie} 宏包的方框化命令只能容纳不超过3200词。但 \cs{frametallrange} 和 \cs{framezitallfile} 却摆脱了这种限制,即使是2万词也不在话下。不过在这种情况下,编译是十分慢的。若要保证速度,可以使用 \pkg{background} 模块及其 \opt{xrange}、\opt{yrange} 特性。
+\end{function}
+
+\begin{texnote}
+ \verb|tall| 类型命令隐式地在固定词数后进行分段,这个词数由 \opt{tallheight} 选项来控制,见第 \ref{sec:options} 节。
+
+ 为了执行速度,\opt{tallheight} 需要手动控制。
+\end{texnote}
+
\section{选项}\label{sec:options}
以下选项在方框化命令的宏中是局部设置的。
-\begin{function}{basechar,zihao}
+\changes{v1.2}{2021/09/23}{新增 \opt{fontsize} 选项,不再使用 \opt{zihao} 选项作为默认字号选项。}
+\begin{function}{basechar,fontsize,zihao}
\begin{syntax}
basechar = \meta{CJK char} \init{好}
- zihao = \meta{字号} \init{4}
+ fontsize = \meta{fontsize command} \init{\normalsize}
+ zihao = \meta{字号}
\end{syntax}
\opt{basechar} 设置当 \opt{resize} 为 \opt{base} 类时的基字符,这个用来计算缩放比例,基字符不同时,即使给定相同的缩放比例,其实际缩放比例也可能不同。
- \opt{zihao} 设置计算缩放比例时的字号大小。
+ \opt{fontsize} 设置计算基字符时的字大小,默认值也为 \tn{normalsize}。\opt{zihao} 设置计算缩放比例时的字号大小,必须加载 \pkg{ctexsize} 或 \pkg{ctex} 宏包才可使用。
+\end{function}
+
+\changes{v1.3}{2021/09/25}{新增 \opt{position}、\opt{position*}、\opt{anchor} 键。}
+\begin{function}{position,position*,anchor}
+ \begin{syntax}
+ position = <...>
+ position*= \marg{replace}
+ anchor = <east|southeast|south|southwest|west|northwest|
+ ~~~~~~~~~~~~north|northeast|center|...> \init{southwest}
+ \end{syntax}
+ \opt{anchor} 设置当前点与方框化盒子的哪个锚点重合。初始值为 \opt{southwest},即当前点与盒子的西南角点重合:
+ \verb|\framezi[anchor=southwest]|\framezi[width=1.5\ccwd,anchor=southwest]{好},
+ \verb|\framezi[anchor=center]{好}|\framezi[width=1.5\ccwd,anchor=center]{好}。
+
+ \opt{position} 键用于引用 \opt{position} 处理器定义的值,\opt{position} 处理器接收当前方框化的盒子作为其参数。使用 \pkg{xcoffins} 宏包,
+ \opt{position} 处理器还可以对已经构造好的盒子进行任意变换,如旋转、重设大小等,只是最后不要忘记使用 \cs{TypesetCoffin} 命令将其输出。
+ 该盒子为一个 \verb|coffin|。关于 \verb|coffin| 详见 \pkg{xcoffins}\cite{pkg-xcoffins} 宏包的说明。关于“处理器”,详细介绍请看第 \ref{sec:processors} 节。
+
+ \opt{position} 处理器预先定义了 \opt{anchor-east}、\opt{anchor-south} … 等规则,实际上,\verb|anchor=east| 就是 \verb|position=anchor-east| 的简写,
+ \opt{anchor} 的其它可选值也是如此。因此,只要 \opt{position} 的规则具有 \verb|anchor-|\meta{anchor value} 形式,就可以使用 \verb|anchor=|\meta{anchor value}
+ 来引用它。
+
+ 还可使用 \cs{zitienewrule} 定义新的标点符号处理方式。详见 \cs{zitienewrule} 命令的说明和第 \ref{sec:processors} 节。
+
+ \opt{position*} 键将 \opt{position} 处理器定义为其值,接收当前方框化的盒子作为其参数。
+
+ 使用 \pkg{xcoffins} 宏包,则设置 \verb|position*={\TypesetCoffin#1[l,b](0pt,0pt)}| 就相当于
+ 设置了 \verb|anchor=southwest| 或 \verb|position=anchor-southwest|。
\end{function}
\begin{function}{punctuation, punctuation*}
@@ -185,33 +263,57 @@
若 \opt{punctuation} 并不存在,则将其值视为已定义的宏。如,假设 \verb|@gobble| 值并不存在,若使用 \verb|punctuation=@gobble|,则标点符号处理命令为 \tn{@gobble},这是 \LaTeXe 定义的命令,其作用与 \verb|punctuation=ignore| 相同。
- 还可使用 \cs{zitienewrule} 定义新的标点符号处理方式。详见 \cs{zitienewrule} 命令的说明。
+ 还可使用 \cs{zitienewrule} 定义新的标点符号处理方式。详见 \cs{zitienewrule} 命令的说明和第 \ref{sec:processors} 节。
实际上,\opt{onlast} 和 \opt{scale} 就是由 \cs{zitienewrule} 定义的,这个键的处理器接收一个标点符号作为其参数。
- 具体的定义见 \cs{zitienewrule} 命令的说明。
+ 具体的定义第 \ref{sec:processors} 节。
\end{function}
+
\begin{texnote}
按照 \pkg{xeCJK} 宏包的字符分类,\pkg{zitie} 宏包将字符类别为 \verb|FullLeft|、\verb|FullRight|、\verb|HalfLeft|、\verb|HalfRight| 视为标点符号。将 \verb|CJK|视为CJK字符。
+
+于是可以通过修改标点符号的字符类别为 \opt{CJK} 来使用CJK的处理规则,但是要注意,一般标点符号的宽高与常用字符的宽高并不一致。某些字符也不是全高的,这时,可用后文介绍的 \opt{holdbasecharheight} 键来保证至少有 \opt{basechar} 字符的高度。
+\begin{verbatim}
+ \xeCJKDeclareCharClass{CJK}{`。}
+ \framezi[resize=real,punctuation=leave,holdbasecharheight=false]{好的。一点、}
+ \framezi[resize=real,punctuation=leave,holdbasecharheight]{好的。一点、}
+ \xeCJKResetPunctClass
+ \framezi[resize=real,punctuation=leave,holdbasecharheight=false]{好的。一点、}
+ \framezi[resize=real,punctuation=leave,holdbasecharheight]{好的。一点、}
+\end{verbatim}
+
+\xeCJKDeclareCharClass{CJK}{`。}
+\framezi[width=1cm,resize=real,punctuation=leave,holdbasecharheight=false]{好的。一点、}
+\framezi[width=1cm,resize=real,punctuation=leave,holdbasecharheight]{好的。一点、}
+\xeCJKResetPunctClass
+
+\framezi[width=1cm,resize=real,punctuation=leave,holdbasecharheight=false]{好的。一点、}
+\framezi[width=1cm,resize=real,punctuation=leave,holdbasecharheight]{好的。一点、}
+
+由于 \LuaTeX-ja 的实现问题,目前这一方法在 \LuaTeX{} 中效果并不好。
\end{texnote}
+\changes{v1.4.0}{2021/10/01}{修改了方框的行为,使得当使用设置 \opt{framearc} 时,arc外的线将隐藏。}
\begin{function}{frametype,resize}
\begin{syntax}
- frametype = <none|口|十|田|米|咪|...> \init{none}
+ frametype = <none|口|十|田|×|米|咪|...> \init{none}
resize = <none|real|base|square|...> \init{none}
\end{syntax}
- \opt{frametype} 设置方框样式。可用值的效果正如选项值:\verb|口|--仅方框,\verb|十|--仅中间的横线和竖线,\verb|田|--常见的田字格,\verb|米|--十字格再加上斜的两条线,\verb|咪|--常见的米字格。还可自定义方框,详见第 \ref{sec:interface} 节。
+ \opt{frametype} 设置方框样式。可用值的效果正如选项值:\verb|口|--仅方框,\verb|十|--仅中间的横线和竖线,\verb|田|--常见的田字格,\verb|×|--斜的两条线,\verb|米|--十字格再加上斜的两条线,\verb|咪|--常见的米字格。还可自定义方框,详见第 \ref{sec:interface} 节。以下 \opt{frametype} 分别为 \verb|none|,\verb|口|,\verb|十|,\verb|田|,\verb|×|、\verb|米|,\verb|咪|。
{\zitiesetup{font=楷体,width=1cm,resize=square,framecolor=black,linewidth=.7pt}
\framezi[frametype=none]{无}
\framezi[frametype=口]{口}
\framezi[frametype=十]{十}
\framezi[frametype=田]{田}
+ \framezi[frametype=×]{叉}
\framezi[frametype=米]{米}
\framezi[frametype=咪]{咪}}
\opt{resize} 设置缩放方式。\opt{real},使用字符实际宽高缩放,\opt{base},使用 \opt{basechar} 设置的字符的宽高缩放,\opt{square},使得字符的宽高相等再进行缩放。还可自定义缩放方式,详见第 \ref{sec:interface} 节。
- 以下为宽度设置为 1cm 时的缩放情况。
+ 以下为宽度设置为 1cm,\opt{resize} 分别为 \verb|none|,\verb|real|,\verb|base|,\verb|square|时的缩放情况。
+
{\zitiesetup{font=楷体,width=1cm,frametype=咪,framecolor=black}
\framezi[resize=none]{无}
\framezi[resize=real]{实}
@@ -219,6 +321,7 @@
\framezi[resize=square]{方}}
\end{function}
+\changes{v1.2}{2021/09/23}{新增 \opt{holdbasecharwidth}、\opt{holdbasecharheight}、\opt{holdbasechar} 选项。}
\begin{function}{
xscale,yscale,scale,
width,height
@@ -229,12 +332,17 @@
scale = \meta{scale ratio}
width = \meta{dim}
height = \meta{dim}
+ holdbasecharheight = \TTF \init{false}
+ holdbasecharwidth = \TTF \init{false}
+ holdbasechar = \TTF
\end{syntax}
设置缩放比例和盒子宽高。
宽高具有更高的优先级,即若比例和宽高都设置了,则使用宽高来计算。宽高为二者都为0cm视为未设置,二者有一大于0cm,视为设置了宽高。
此处的宽高和最终的宽高可能略有差异,最终的宽高保存在 \tn{zitiewidth} 和 \tn{zitieheight} dim寄存器中。
+
+ \opt{holdbasecharheight}设置为 \opt{true} 时,将保证单个盒子至少有 \opt{basechar} 的高度,\opt{holdbasecharwidth} 设置为 \opt{true} 时,将设置盒子宽度为 \opt{basechar} 的宽度。\opt{holdbasechar} 将同时设置二者的值。
\end{function}
\begin{function}{
@@ -245,19 +353,19 @@
}
\begin{syntax}
linewidth = \meta{dim} \init{0.4pt}
- dashpattern = \{ \meta{ dim1, dim2, ... } \}
+ dashpattern = \{ \meta{dim1}, \meta{dim2}, ... \}
framearc = \meta{dim}
- framearc* = \{ \marg{dim1} \marg{dim2} \}
+ framearc* = \marg{dim1} \marg{dim2}
\end{syntax}
\end{function}
{\zitiesetup{width=2cm,framecolor=black,font=楷体}
\verb|linewidth=1pt|:\framezi[linewidth=1pt]{好} \\
\verb|dashpattern={1mm,2mm,3mm,4mm}|:\framezi[dashpattern={1.5mm,1mm,2mm,1.5mm}]{好} \\
-\verb|framearc=3mm,frametype=口|:\framezi[framearc=3mm,frametype=口]{好} \\
-\verb|framearc=3mm,frametype=咪|:\framezi[framearc=3mm,frametype=咪]{好} \\
-\verb|framearc*={3mm}{6mm},frametype=口|:\framezi[framearc*={3mm}{6mm},frametype=口]{好} \\
-\verb|framearc*={3mm}{6mm},frametype=咪|:\framezi[framearc*={3mm}{6mm},frametype=咪]{好}
+\verb|framearc=3mm,frametype=|\verb|口|:\framezi[framearc=3mm,frametype=口]{好} \\
+\verb|framearc=3mm,frametype=|\verb|咪|:\framezi[framearc=3mm,frametype=咪]{好} \\
+\verb|framearc*={3mm}{6mm},frametype=|\verb|口|:\framezi[framearc*={3mm}{6mm},frametype=口]{好} \\
+\verb|framearc*={3mm}{6mm},frametype=|\verb|咪|:\framezi[framearc*={3mm}{6mm},frametype=咪]{好}
}
\begin{function}{
@@ -276,18 +384,21 @@
fillcolor = \meta{color expr}
fillcolor* = \marg{model(s)} \marg{value(s)}
\end{syntax}
- 命名的颜色仅支持 \LaTeX3 定义的 black, white, red, green, blue, cyan, magenta 和 yellow。颜色模型和表达式也应使用 \LaTeX3 支持的模型和表达式,详见 \pkg{interface3.pdf} 文档。
+ 命名的颜色仅支持 \LaTeX3 定义的 black, white, red, green, blue, cyan, magenta 和 yellow。颜色模型和表达式也应使用 \LaTeX3 支持的模型和表达式,详见 \pkg{interface3.pdf}\cite{pdf-interface3} 文档。
若要去掉 \opt{fillcolor},应将其设置为空,即 \verb|fillcolor={}|,而不是将其设置为白色。
\end{function}
+\changes{v1.2}{2021/09/23}{\opt{charstroke} 新增 \opt{invisible} 值。}
+\changes{v1.3}{2021/09/25}{新增带 \opt{thick} 前缀的值。}
\begin{function}{
charstroke,
charstrokespecial,
\zitiestrokechars
}
\begin{syntax}
- charstroke = <none|solid|dashed|whitesolid|whitedashed|...> \init{none}
+ charstroke = <none|solid|dashed|whitesolid|whitedashed|thicksolid|thickdashed|
+ ~~~~~~~~~~~~~~thickwhitesolid|thickwhitedashed|invisible|...> \init{none}
charstrokespecial = \meta{pdf literal}
\cs{zitiestrokechars} \marg{pdf literal} \marg{typeset material}
\end{syntax}
@@ -297,24 +408,38 @@
初始值 \opt{none} 什么也不做。\opt{solid} 设置外轮廓为 0.25bp 的实线,\opt{dashed} 设置外轮廓为 0.25bp 的虚线。这两个
不会进行填充操作,即背景色是什么颜色,则字显示的就是背景,字轮廓的颜色为 \opt{charcolor} 的颜色。\opt{whitesolid} 和
\opt{whitedashed} 在 \opt{solid} 和 \opt{dashed} 的基础上将字填充为白色。
+ 带 \opt{thick} 的值将线宽设为 0.15bp,其它的与不带 \opt{thick} 的一致。\opt{invisible} 将字符设置为不可见,但不影响背景和网格的显示,隐藏的字仍然可被复制。
\opt{charstrokespecial} 将 \meta{pdf literal} 为用在 \tn{special}\verb|{pdf:code ...}| 中 pdf 的指令,
其中,\verb|charstroke=solid| 相当于 \verb|charstrokespecial={1 Tr 0.25 w [] 0 d 1 J}|,
\verb|charstroke=dashed| 相当于 \verb|charstrokespecial={1 Tr 0.25 w [0.8] 0 d 1 J}|,
\verb|charstroke=whitesolid| 相当于 \verb|charstrokespecial={2 Tr 0.25 w [] 0 d 1 J 1 1 1 rg}|,
\verb|charstroke=whitedashed| 相当于 \verb|charstrokespecial={2 Tr 0.25 w [0.8] 0 d 1 J 1 1 1 rg}|。
+
+ \meta{pdf literal} 可用的算符参考 \pkg{pdf reference}\cite{pdfreference}。
+\end{function}
+
+于是可将字符渲染模式设置为3来隐藏字:\\
+\verb|\framezi[charstroke=solid]{字}|:\framezi[width=1cm,charstroke=solid]{字}, \\
+\verb|\framezi[charstrokespecial={3 Tr}]{字}|:\framezi[width=1cm,charstrokespecial={3 Tr}]{字}。
- 还可使用 \cs{zitienewrule} 来定义新的 \opt{charstroke} 处理规则。这个键的处理器接收当前的 \meta{CJK char} 作为其参数。
- 具体的定义见 \cs{zitienewrule} 的说明。
+还可使用 \cs{zitienewrule} 来定义新的 \opt{charstroke} 处理规则。这个键的处理器接收当前的 \meta{CJK char} 作为其参数。
+具体的定义见 \cs{zitienewrule} 的说明和第 \ref{sec:processors} 节。
- \cs{zitiestrokechars} 使用 \meta{pdf literal} 处理 \meta{typeset material}。
-\end{function}
+\cs{zitiestrokechars} 使用 \meta{pdf literal} 处理 \meta{typeset material}。
+
+于是上述隐藏字的效果可用 \cs{zitienewrule} 和 \cs{zitiestrokechars} 来定义一个 \opt{invisible} 规则:
+\begin{verbatim}
+ \zitienewrule{charstroke}{invisible}{\zitiestrokechars{3 Tr}{#1}}
+ \framezi[width=1cm,charstroke=invisible]{字}
+\end{verbatim}
+ \framezi[width=1cm,charstroke=invisible]{字}。这与上面的效果是相同的。实际上,\pkg{zitie} 就是这样实现的。
\begin{function}{
font,savefontname,
fallback,
fontbackfont,
- fontbackfont*
+ fontbackfont+
}
\begin{syntax}
font = \meta{font family} \init{宋体}
@@ -325,36 +450,85 @@
\end{syntax}
\opt{font} 设置盒子中使用的字体,若将其设置为空,即 \verb|font={}| 或 \verb|font|,则将使用正文字体。
- \opt{savefontname} 设置是否保存字体名字,以便在后文使用,如在标点符号的处理中。
+ \opt{savefontname} 设置是否保存字体名字,若设置为真,则将 \opt{font} 键指定的字体名字保存在 \tn{zitiefontname} 中,以便在后文使用,如在标点符号的处理中或页眉页脚中。
\opt{fallbackfont} 设置当当前字体中不存在此字形时,要使用哪些字体,字体必须被 \cs{zitienewfont} 或 \cs{newCJKfontfamily} 声明。
- \opt{fallbackfont+} 将 \marg{fallback font list} 添加的之前的 \meta{fallback font list} 中。
+ \opt{fallbackfont+} 将 \marg{fallback font list} 局部的添加到之前的 \meta{fallback font list} 中。
+
+ 该特性仅可在 \XeTeX{} 中使用。
- 注意,\opt{fallbackfont} 特性和 \pkg{xeCJK} 的 \verb|FallBack| 并不冲突,当 \opt{fallback font list} 中的所有字体没有对应的字形时,才会使用 \verb|FallBack| 定义的字体。这一特性可通过 \verb|fallback=false| 来关闭。
+ 注意,\opt{fallbackfont} 特性和 \pkg{xeCJK} 的 \verb|FallBack| 并不冲突,当 \opt{fallback font list} 中的所有字体没有对应的字形时,才会使用 \verb|FallBack| 定义的字体。这一特性可通过设置 \verb|fallback=false| 来关闭。
\end{function}
如在 \verb|FZSunGuoTingCaoShuFU|(方正孙过庭草书)字体中没有“丂丄”,
-虽然在在导言区使用 \verb|\zitienewfont{ {孙过庭草繁}{FZSunGuoTingCaoShuFU}{FallBack=SimSun} }| 设置其 \verb|FallBack| 字体为 \verb|SimSun|(宋体),但若设置 \verb|fallbackfont={楷体},fallback=true| 则会在楷体中查找是否有该字形,然后再在宋体中查找:
+虽然在在导言区使用 \verb|\zitienewfont{ {孙过庭草繁}{FZSunGuoTingCaoShuFU}{FallBack=SimSun} }| 设置其 \verb|FallBack| 字体为 \verb|SimSun|(宋体),但若设置 \verb|fallbackfont={楷体},fallback=true| 则会在楷体中查找是否有该字形,然后才在宋体中查找:
\begin{verbatim}
- \framezi[fallbackfont={楷体},width=1cm,font=孙过庭草繁,fallback]{一丁丂七丄}
+ \framezi[fallbackfont={楷体},width=1cm,font=孙过庭草繁,fallback,holdbasecharheight]{一丁丂七丄}
\end{verbatim}
-\framezi[fallbackfont={楷体},width=1cm,font=孙过庭草繁,fallback,framecolor=black]{一丁丂七丄}
+\framezi[fallbackfont={楷体},width=1cm,font=孙过庭草繁,fallback,framecolor=black,holdbasecharheight]{一丁丂七丄}
\begin{verbatim}
- \framezi[width=1cm,font=孙过庭草繁,fallback]{一丁丂七丄}
+ \framezi[width=1cm,font=孙过庭草繁,fallback,holdbasecharheight]{一丁丂七丄}
\end{verbatim}
-\framezi[width=1cm,font=孙过庭草繁,fallback,framecolor=black]{一丁丂七丄}
+\framezi[width=1cm,font=孙过庭草繁,fallback,framecolor=black,holdbasecharheight]{一丁丂七丄}
\begin{function}{
filepath,
filepath+
}
\begin{syntax}
- filepath = <filepath1, filepath2, ...>
+ filepath = \{ <filepath1>, <filepath2>, ... \}
\end{syntax}
- \opt{filepath} 为 \cs{framefile}\verb|*| 添加文件搜索路径。其值为逗号分隔的列表。
- \opt{filepath+} 将新的搜索路径添加到原有的路径上。
+ \opt{filepath} 为 \cs{framezifile}\verb|*| 添加文件搜索路径。其值为逗号分隔的列表。
+ \opt{filepath+} 将新的搜索路径局部地添加到原有的路径上。
+\end{function}
+
+\changes{v1.3}{2021/09/25}{新增 \opt{repeat} 功能。}
+\changes{v1.3.2}{2021/09/26}{新增 \opt{break}、\opt{tolerance} 功能。}
+\begin{function}{
+ repeat,
+ break,
+ tolerance,
+ zitie/repeat
+}
+ \begin{syntax}
+ repeat = <integer> \init{1}
+ break = <default|allowbreak|...> \init{allowbreak}
+ tolerance = <dim> \init{1em}
+ \end{syntax}
+ 设置 \cs{framezi} 等命令中的字符重复次数。注意是将整体重复 \meta{integer} 次,而不是将单个字符重复 \meta{integer} 次,再进行下一个字符的处理。
+
+ \verb|zitie/repeat| 钩子,只在两两间执行,执行次数为 $\meta{integer}-1$。
+ 这个钩子的内容在执行完毕后不会被清除,因此,若不自行清除,则在不同的方框化命令中都会执行(如果 $\opt{repeat}>1$)。可将 \cs{RemoveFromHook}\verb|{zitie/repeat}|\oarg{label} 放入 \verb|zitie/.../after| 钩子来清除。
+
+ \begin{verbatim}
+ \framezi[width=1cm,repeat=3]{好的}
+ \end{verbatim}
+ \framezi[width=1cm,repeat=3]{好的}
+
+ \opt{break} 设置单个字符后的断行方法。默认为 \opt{allowbreak},即将 \tn{allowbreak} 插入到构造好的盒子后。
+ \opt{tolerance} 设置断行的允许值,影响 \opt{break} 值为 \opt{default} 时的断行效果,\opt{tolerance} 大,则可能造成 Overfull。
+
+ \opt{break} 和 \opt{tolerance} 仍是实验性的。
+\end{function}
+
+\changes{v1.4.0}{2021/10/01}{新增 \opt{tallheight} 选项。}
+\begin{function}{tallheight}
+ \begin{syntax}
+ tallheight = <integer> \init{1000}
+ \end{syntax}
+ \opt{tallheight} 选项控制 \verb|tall| 型命令隐式地在 \meta{integer} 个词后进行分段。因此,为了保证排版美观,\opt{tallheight} 最好为每行能容纳词数的倍数。而且这个值也受单个最大能处理的词数的限制,即不能超过3200。
+\end{function}
+
+\changes{v1.4.0}{2021/10/01}{新增 \opt{validateglyph} 选项。}
+\begin{function}{validateglyph}
+ \begin{syntax}
+ validateglyph = \TTF \init{false}
+ \end{syntax}
+ 这个选项设置为真时,将先判断使用的字体是否包含该字形,若不包含,则忽略该字符。判断字形时不会考虑 FallBack 字体。
+
+ 目前这个选项仅在 \cs{framesingle} 命令中有效。
\end{function}
\begin{function}{
@@ -365,49 +539,28 @@
\cs{zitiesetup} \marg{key-val}
\cs{zitiecolorlet} \marg{name} \oarg{model} \marg{value}
\end{syntax}
- 用于设置选项,定义新的颜色。注意,若加载 \pkg{xcolor} 不能使用 \tn{colorlet}命令,必须使用 \cs{zitiecolorlet} 来设置颜色。
+ \cs{zitiesetup} 为 \pkg{zitie} 宏包的设置命令,这个命令设置的值在当前组中有效。\cs{zitiecolorlet} 定义新的颜色。注意,若加载 \pkg{xcolor} 宏包,使用 \tn{colorlet} 命令定义的颜色无法在 \pkg{zitie} 宏包的选项中使用,必须使用 \cs{zitiecolorlet} 来定义颜色。
\end{function}
-\begin{function}{\zitienewrule}
+\begin{function}{\zitienewprocessorrule,\zitienewrule,\zitieuseprocessorrule}
\begin{syntax}
- \cs{zitienewrule} \oarg{arg nums} \marg{option key} \marg{rule} \marg{replace}
+ \cs{zitienewprocessorrule} \oarg{arg nums} \marg{processor} \marg{rule} \marg{replace}
+ \cs{zitieuseprocessorrule} \oarg{arg nums} \marg{processor} \marg{rule} \meta{args}
\end{syntax}
- 为 \pkg{zitie} 宏包的键 \meta{option key} 定义新的处理规则。将忽略 \meta{option key} 和 \meta{rule} 两端的空格。
+ \cs{zitienewprocessorrule} 为 \pkg{zitie} 宏包的处理器 \meta{processor} 定义新的处理规则。将忽略 \meta{option key} 和 \meta{rule} 两端的空格。
+ \cs{zitienewrule} 与 \cs{zitienewprocessorrule} 的作用相同。
+
+ \cs{zitieuseprocessorrule} 使用 \meta{processor} 的 \meta{rule} 规则,\meta{args} 为 \meta{processor} 处理器的参数。
+
+ 关于处理器和规则,见第 \ref{sec:processors} 节。
\meta{arg nums} 为键预先定义的参数数目。若未设置 \meta{arg nums},则将其设置为1。
\end{function}
-\pkg{zitie} 宏包使用了
-\begin{verbatim}
- \zitienewrule{punctuation}{onlast}
- {\penalty10000 \smash{\makebox[0pt]{%
- \color{zitiecharcolor}\zitieCJKfamily{\zitiefontname}#1}}}
-\end{verbatim}
-和
-\begin{verbatim}
- \zitienewrule{punctuation}{scale}{
- \hbox_set:Nn \l_tmpa_box
- { \color_select:n { zitiecharcolor } \zitieCJKfamily{\zitiefontname} #1 }
- \box_scale:Nnn \l_tmpa_box \zitiexscaleratio \zitieyscaleratio
- \box_use_drop:N \l_tmpa_box
- }
-\end{verbatim}
-定义了两个 \opt{punctuation} 处理规则:\opt{onlast} 和 \opt{scale},这样就可以使用 \verb|punctuation=onlast| 和 \verb|punctuation=scale| 来对标点符号进行处理。
-
-使用
-\begin{verbatim}
- \zitienewrule {charstroke} {solid}
- { \zitiestrokechars { 1 Tr 0.25 w [] 0 d 1 J } {#1} }
- \zitienewrule {charstroke} {dashed}
- { \zitiestrokechars { 1 Tr 0.25 w [0.8] 0 d 1 J } {#1} }
- \zitienewrule {charstroke} {whitesolid}
- { \zitiestrokechars { 2 Tr 0.25 w [] 0 d 1 J 1 1 1 rg } {#1} }
- \zitienewrule {charstroke} {whitedashed}
- { \zitiestrokechars { 2 Tr 0.25 w [0.8] 0 d 1 J 1 1 1 rg } {#1} }
-\end{verbatim}
-定义了四个 \opt{charstroke} 处理规则,这样就可以使用 \verb|charstroke=solid, ...| 来处理字符。
-
\begin{function}{
+ \zitiebasechar,
+ \zitiebasecharwidth,
+ \zitiebasecharheight,
\zitiewidth,
\zitieheight,
\zitieboxwd,
@@ -417,7 +570,7 @@
\zitiexscaleratio,
\zitieyscaleratio,
}
- 这些命令为全局设置的接口。
+ \cs{zitiebasechar}、\cs{zitiebasecharwidth}、\cs{zitiebasecharheight} 为局部设置的。其余的命令为全局设置的接口。
\end{function}
\begin{function}{
@@ -425,7 +578,7 @@
zitiecharcolor,
zitiefillcolor,
}
- 这些是全局保存的颜色名,可在 \pkg{xcolor} 宏包的 \tn{color} 命令 和 \LaTeX3 命令 \cs{color_select:n} 中使用。
+ 这些是全局保存的颜色名,可在 \pkg{xcolor} 宏包的 \tn{color} 命令和 \LaTeX3 \cs{color_select:n} 命令中使用。
\end{function}
@@ -466,7 +619,7 @@
\end{syntax}
设置背景格子的大小。
- \opt{boxwidth} 和 \opt{boxheight} 具有更高的优先级,若设置了,则背景每个格子的宽高为所设置的值,否则,使用 \meta{framewidth}、\meta{frameheight} 及 \meta{colboxes}、\meta{rowboxes} 来计算大小。
+ \opt{boxwidth} 和 \opt{boxheight} 具有更高的优先级,若设置了,则背景每个格子的宽高为所设置的值,否则,使用 \opt{framewidth}、\opt{frameheight} 及 \opt{colboxes}、\opt{rowboxes} 来计算大小。
\opt{onpaper} 设置 \verb|frameheight=\paperheight, framewidth=\paperwidth|,
\opt{ontext} 设置 \verb|frameheigh=\textheight, framewidth=\textwidth|。
@@ -481,19 +634,32 @@
fillcolor*,
dashpattern
}
- 和 \cs{framezi} 等命令的选项相同,但二者互不影响。
+ \begin{syntax}
+ frametype = <none|口|十|田|×|米|咪|二|(||)> \init{none}
+ linewidth = <dim> \init{0.4pt}
+ framecolor = <color expr> \init{black}
+ framecolor = \marg{model(s)} \marg{value(s)}
+ fillcolor = <color expr>
+ fillcolor* = \marg{model(s)} \marg{value(s)}
+ dashpattern = \{ <dim1>, <dim2>, ... \}
+ \end{syntax}
+ 和 \cs{framezi} 等命令的选项作用相同,但二者互不影响。
+
+ 其中 \opt{frametype} 的值 \verb|二| 为画外侧方框和横线,\opt{frametype} 的值 \verb=||= 为画外侧方框和竖线。
颜色分别保存在 \verb|zitiebackgroundframecolor|,\verb|zitiebackgroundfillcolor| 颜色名中。可在 \tn{color} 中直接使用,也可在 \cs{color_select:n} 中使用。
\end{function}
\begin{function}{xrange,yrange}
\begin{syntax}
- xrange = \{ \meta{left} , \meta{right} \}
- yrange = \{ \meta{top} , \meta{bottom} \}
+ xrange = \{ \meta{left} , \meta{right} \} \init{{0cm, \paperwidth}}
+ yrange = \{ \meta{top} , \meta{bottom} \} \init{{0cm, \paperheight}}
\end{syntax}
- 设置网格显示的范围。注意这是实验性的,效果可能并不好。
+ 设置网格显示的范围。\meta{left}、\meta{right} 为距页面左端的距离。\meta{top}、\meta{bottom} 为距页面顶端的距离。
\end{function}
+也可以使用 \verb|\zitiesetup{background={|\meta{background key-val}\verb|}}| 来设置键。
+
本文档的设置为:
\begin{verbatim}
\zitiebackground[
@@ -505,7 +671,7 @@
\section{zhlipsum, 中文乱数假文}
-\pkg{zitie} 宏包完全兼容 \pkg{zhlipsum} 宏包。使用 \cs{newzhlipsum} 命令定义的假文也可使用。
+\pkg{zitie} 宏包完全兼容 \pkg{zhlipsum} 宏包\cite{pkg-zhlipsum}。使用 \cs{newzhlipsum} 命令定义的假文也可使用。
在加载宏包时使用 \opt{enable-zhlipsum} 以启用该特性。
@@ -524,13 +690,72 @@
\end{function}
+\changes{v1.3}{2021/09/25}{新增处理器和规则一节。}
+\section{处理器和规则}\label{sec:processors}
+
+\emph{处理器}实际上就是一个宏,这个宏可以使用指定的\emph{规则}来处理其参数。
+
+规则可以接收给定的参数,这些参数数目及传入顺序是由对应的处理器指定的。例如 \pkg{zitie} 就定义了 \opt{position}、\opt{punctuation}、\opt{charstroke} 等处理器。
+它们使用指定的规则对给定参数进行处理。
+
+处理器可以使用 \cs{zitienewprocessorrule} 来定义新的规则。\pkg{zitie} 宏包为 \opt{position}、\opt{punctuation}、\opt{charstroke} 等处理器预先定义了一些规则:
+
+使用
+\begin{verbatim}
+ \zitie_new_process_rule:nnn { position } { anchor-center }
+ { \coffin_typeset:Nnnnn #1 { hc } { vc } { 0pt } { 0pt } }
+ \zitie_new_process_rule:nnn { position } { anchor-east }
+ { \coffin_typeset:Nnnnn #1 { r } { vc } { 0pt } { 0pt } }
+ \zitie_new_process_rule:nnn { position } { anchor-southeast }
+ { \coffin_typeset:Nnnnn #1 { r } { b } { 0pt } { 0pt } }
+ ...
+\end{verbatim}
+定义了 \opt{position} 处理规则:\opt{anchor-center}、\opt{anchor-east} 等,这样就可使用 \verb|position=anchor-center| 来引用它们。
+
+使用
+\begin{verbatim}
+ \zitienewrule{punctuation}{onlast}
+ {\penalty10000 \smash{\makebox[0pt]{%
+ \color{zitiecharcolor}\zitieCJKfamily{\zitiefontname}#1}}}
+ \zitienewrule{punctuation}{scale}{
+ \hbox_set:Nn \l_tmpa_box
+ { \color_select:n { zitiecharcolor } \zitieCJKfamily{\zitiefontname} #1 }
+ \box_scale:Nnn \l_tmpa_box \zitiexscaleratio \zitieyscaleratio
+ \box_use_drop:N \l_tmpa_box
+ }
+\end{verbatim}
+定义了两个 \opt{punctuation} 处理规则:\opt{onlast} 和 \opt{scale},这样就可以使用 \verb|punctuation=onlast| 和 \verb|punctuation=scale| 来对标点符号进行处理。
+
+使用
+\begin{verbatim}
+ \zitienewrule {charstroke} {solid}
+ { \zitiestrokechars { 1 Tr 0.25 w [] 0 d 1 J } {#1} }
+ \zitienewrule {charstroke} {dashed}
+ { \zitiestrokechars { 1 Tr 0.25 w [0.8] 0 d 1 J } {#1} }
+ \zitienewrule {charstroke} {whitesolid}
+ { \zitiestrokechars { 2 Tr 0.25 w [] 0 d 1 J 1 1 1 rg } {#1} }
+ \zitienewrule {charstroke} {whitedashed}
+ { \zitiestrokechars { 2 Tr 0.25 w [0.8] 0 d 1 J 1 1 1 rg } {#1} }
+ \zitienewrule {charstroke} {thicksolid}
+ { \zitiestrokechars { 1 Tr 0.15 w [] 0 d 1 J } {#1} }
+ \zitienewrule {charstroke} {invisible} { \zitiestrokechars {3 Tr} {#1} }
+ ...
+\end{verbatim}
+定义了 \opt{charstroke} 处理规则,这样就可以使用 \verb|charstroke=solid, ...| 来处理字符。
+
+规则的定义中还可以使用 \cs{zitieuseprocessorrule} 来引用已经定义好的规则。
+
\section{编程接口}\label{sec:interface}
+\changes{v1.2}{2021/09/23}{将 \cs{zitie_color_select:..} 改为 \cs{zitie_color_set:..}。}
+\changes{v1.3}{2021/09/25}{新增 \cs{...set_eq:nn}。}
\begin{function}{
\zitie_new_frame_construct:nn,
\zitie_frame_type:n,
\zitie_frame_type_c:n,
+ \zitie_frame_type_set_eq:nn,
\zitie_new_resize_method:nn,
+ \zitie_resize_method_set_eq:nn,
\zitie_new_font:n,
\zitie_new_font:nnn,
}
@@ -549,8 +774,8 @@
\end{function}
\begin{function}{
- \zitie_color_select:nn,
- \zitie_color_select:nnn,
+ \zitie_color_set:nn,
+ \zitie_color_set:nnn,
}
颜色选择。
\end{function}
@@ -561,7 +786,7 @@
\zitie_token_class_dispatch_o:Nnnnn,
\zitie_token_class_dispatch_f:Nnnnn,
}
- 字形选择和字符类别判断。
+ 字形选择和字符类别判断。仅在 \XeTeX 中有效。
\end{function}
\begin{function}[TF]{
@@ -569,12 +794,15 @@
\zitie_token_if_punctuation_o:N,
\zitie_token_if_punctuation_f:N,
}
- 是否为标点符号。
+ 是否为标点符号。仅在 \XeTeX 中有效。
\end{function}
+\changes{v1.4.0}{2021/10/01}{新增 \cs{zitie_single_validate_glyph_construct:N}、\cs{zitie_single_validate_glyph_construct:nN}。}
\begin{function}{
\zitie_single_construct:N,
\zitie_single_construct:nN,
+ \zitie_single_validate_glyph_construct:N,
+ \zitie_single_validate_glyph_construct:nN,
}
构造单个字的方框。
\end{function}
@@ -583,6 +811,7 @@
\zitie_background_new_frame_construct:nn,
\zitie_background_frame_type:n,
\zitie_background_frame_type_c:n,
+ \zitie_background_frame_type_set_eq:nn
}
创建和使用新的 background frame 类型。
\end{function}
@@ -591,7 +820,8 @@
\begin{itemize}
\item 实现更快的、消耗资源更少的版本。
- \item 支持 \LuaTeX。
+ \item 修改断行算法。
+ \item 优化对 \LuaTeX{} 的支持。
\item 优化背景模块。
\item 增加间距功能。
\item 更多网格效果。
@@ -601,6 +831,41 @@
\item 等。
\end{itemize}
+
+\begin{thebibliography}{9}
+\bibitem{pkg-xeCJK}
+\href{http://www.ctex.org}{CTEX.ORG},
+\newblock \textit{\pkg{xeCJK} 宏包}
+\bibitem{pkg-fontspec}
+\textsc{WILL ROBERTSON},
+\newblock With contributions by Khaled Hosny, Philipp Gesang, Joseph Wright, and others.
+\newblock \textit{The fontspec package}
+\bibitem{pdf-source2e}
+\textsc{Johannes Braams,
+David Carlisle,
+Alan Jeffrey,
+Leslie Lamport,
+Frank Mittelbach,
+Chris Rowley,
+Rainer Schöpf},
+\newblock \textit{The {\LaTeXe} Sources}
+\bibitem{pkg-lthooks}
+\textsc{Frank Mittelbach},
+\newblock \textit{The lthooks package}
+\bibitem{pdf-interface3}
+\textsc{The {\LaTeX} Project},
+\newblock \textit{The {\LaTeX3} Interfaces}
+\bibitem{pkg-xcoffins}
+\textsc{The \LaTeX{} Project},
+\newblock \textit{The xcoffins package}
+\bibitem{pkg-zhlipsum}
+{\kaishu 曾祥东},
+\newblock \textit{zhlipsum: 中文乱数假文(Lorem ipsum)}
+\bibitem{pdfreference}
+\textsc{Adobe® Systems Incorporated},
+\newblock \textit{Adobe® Portable Document Format}
+\end{thebibliography}
+
\IndexLayout
\zitiebackground[off]
\PrintChanges
diff --git a/macros/xetex/latex/zitie/tex/zitie.luatex.def b/macros/xetex/latex/zitie/tex/zitie.luatex.def
new file mode 100644
index 0000000000..9a31201987
--- /dev/null
+++ b/macros/xetex/latex/zitie/tex/zitie.luatex.def
@@ -0,0 +1,90 @@
+% maybe use pdf_literal will be better
+\cs_new:Npn \zitie_stroke_chars:nn #1#2
+ { \special { pdf:code ~ q ~ #1 } #2 \special { pdf:code ~ Q } }
+\cs_new:Npn \zitiestrokechars { \zitie_stroke_chars:nn }
+
+% \RequirePackage {luatexja-fontspec} % using ctex currently
+%%% require on ctex
+\RequirePackage {ctex}
+%% copy from xeCJK
+\prg_new_conditional:Npnn \__zitie_if_blank_x:n #1 { p , T , F , TF }
+ {
+ \if_case:w \tex_strcmp:D { } {#1} \exp_stop_f:
+ \prg_return_true:
+ \else:
+ \if_case:w \tex_strcmp:D { ~ } {#1} \exp_stop_f:
+ \prg_return_true: \else: \prg_return_false: \fi:
+ \fi:
+ }
+\cs_new_protected:Npn \__zitie_check_num_range:nnNN #1#2#3#4
+ {
+ \bool_lazy_or:nnTF
+ { \__zitie_if_blank_x_p:n {#1} }
+ { \__zitie_if_blank_x_p:n {#2} }
+ {
+ \int_set:Nn #3 { \__zitie_if_blank_x:nTF {#1} {#2} {#1} }
+ \int_set_eq:NN #3 #4
+ }
+ {
+ \int_set:Nn #3 { \int_min:nn {#1} { \tl_if_novalue:nTF {#2} {#1} {#2} } }
+ \int_set:Nn #4 { \int_max:nn {#1} { \tl_if_novalue:nTF {#2} {#1} {#2} } }
+ }
+ }
+% dosen't work
+\prg_new_conditional:Npnn \zitie_glyph_if_exist:N #1 { p , T , F , TF }
+ { \prg_return_true: }
+\cs_set_eq:NN \__zitie_int_until_do:nn \int_until_do:nn
+%%
+
+\tl_new:N \l__zitie_cfg_tmp_tl
+\str_new:N \l__zitie_cfg_tmp_str
+\newfontfeature{FallBack}{}
+\NewDocumentCommand \zitierawCJKfamily { t+ t- m } { \CJKfamily {#3} }
+\prg_new_protected_conditional:Npnn \zitie_family_if_exist:n #1 { T , F , TF }
+ {
+ \prop_if_in:NnTF \g__ctex_ltj_family_name_prop {#1}
+ { \prg_return_true: }
+ {
+ \cs_if_exist_use:cTF { \__ctex_ltj_family_csname:n {#1} }
+ { \prg_return_true: } { \prg_return_false: }
+ }
+ }
+\cs_new:Npn \__zitie_font_select:nN #1
+ {
+ \exp_args:Nx \zitie_family_if_exist:nTF { \c_zitie_font_name_prefix_tl #1 }
+ { \fontfamily { \c_zitie_font_name_prefix_tl #1 } }
+ { \fontfamily {#1} }
+ % { \zitierawCJKfamily { \c_zitie_font_name_prefix_tl #1 } }
+ % { \zitierawCJKfamily {#1} }
+ }
+\NewDocumentCommand \zitieCJKfamily { t+ t- m }
+ { \__zitie_font_select:nN {#3} }
+\cs_generate_variant:Nn \ctex_ltj_set_family:nnn { onn }
+\cs_new:Npn \__zitie_new_font_family:nnn #1#2#3
+ {
+ \tl_set:Nx \l__zitie_cfg_tmp_tl { \c_zitie_font_name_prefix_tl #1 }
+ \__ctex_ltj_pass_args:nnnn
+ { \ctex_ltj_set_family:onn { \l__zitie_cfg_tmp_tl } } {#3} {#2}
+ { }
+ }
+\cs_new:Npn \__zitie_new_font_family_validate:nnn #1#2#3
+ {
+ \zitie_font_if_exist:nTF {#2} { \__zitie_new_font_family:nnn {#1} {#2} {#3} }
+ { \msg_warning:nnn { zitie } { font-exist } {#2} }
+ }
+%%%
+
+%% to support luatex without ctex, need to implement those functions:
+\cs_new_protected:Npn \xeCJKResetPunctClass { }
+\cs_new:Npn \zitie_token_class_dispatch:Nnnnn #1#2#3#4#5
+ { \use_ii:nnnn }
+\prg_new_conditional:Npnn \zitie_token_if_punctuation:N #1 { p, T, F, TF }
+ { \prg_return_false: }
+\cs_new:Npn \xeCJKDeclareCharClass #1#2 { }
+% \cs_new:Npn \zitierawCJKfamily { } %\CJKfamily
+% \prg_new_conditional:Npnn \zitie_family_if_exist:n #1 { T, F, TF } { }
+% \cs_new_nopar:Nn \__zitie_font_select:nN #1#2 { }
+% \NewDocumentCommand \zitieCJKfamily { t+ t- m } { }
+% \cs_new:Nn \__zitie_new_font_family:nnn #1#2#3 { }
+% \cs_new:Nn \__zitie_new_font_family_validate:nnn #1#2#3 { }
+%% \ No newline at end of file
diff --git a/macros/xetex/latex/zitie/tex/zitie.sty b/macros/xetex/latex/zitie/tex/zitie.sty
index 0dfe9d137c..a61d19d710 100644
--- a/macros/xetex/latex/zitie/tex/zitie.sty
+++ b/macros/xetex/latex/zitie/tex/zitie.sty
@@ -2,42 +2,44 @@
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{ xparse , l3keys2e }
\RequirePackage{ l3draw }
-\ProvidesExplPackage {zitie} {2021/09/23} {v1.1} {CJK character calligraphy sheet}
-\RequirePackage { xeCJK }
-\@ifpackageloaded { ctex } { }
- { \RequirePackage { ctexsize } \sys_if_platform_windows:T { \setCJKmainfont {SimSun} } }
+\ProvidesExplPackage {zitie} {2021/10/01} {v1.4.0} {CJK character calligraphy sheet}
\@ifpackageloaded { xcolor }
{
- \cs_set_nopar:Npn \zitie_color_select:nn #1#2 { \colorlet{#1}{#2} \color_set:nn {#1} {#2} }
- \cs_set_nopar:Npn \zitie_color_select:nnn #1#2#3 { \colorlet{#1}[#2]{#3} \color_set:nnn {#1} {#2} {#3} }
+ \cs_set_nopar:Npn \zitie_color_set:nn #1#2 { \colorlet{#1}{#2} \color_set:nn {#1} {#2} }
+ \cs_set_nopar:Npn \zitie_color_set:nnn #1#2#3 { \colorlet{#1}[#2]{#3} \color_set:nnn {#1} {#2} {#3} }
}
{
\hook_gput_code:nnn { package/after/xcolor } { package }
{
- \cs_set_nopar:Npn \zitie_color_select:nn #1#2 { \colorlet{#1}{#2} \color_set:nn {#1} {#2} }
- \cs_set_nopar:Npn \zitie_color_select:nnn #1#2#3 { \colorlet{#1}[#2]{#3} \color_set:nnn {#1} {#2} {#3} }
+ \cs_set_nopar:Npn \zitie_color_set:nn #1#2 { \colorlet{#1}{#2} \color_set:nn {#1} {#2} }
+ \cs_set_nopar:Npn \zitie_color_set:nnn #1#2#3 { \colorlet{#1}[#2]{#3} \color_set:nnn {#1} {#2} {#3} }
}
- \cs_set_nopar:Npn \zitie_color_select:nn #1#2 { \color_set:nn {#1} {#2} }
- \cs_set_nopar:Npn \zitie_color_select:nnn #1#2#3 { \color_set:nnn {#1} {#2} {#3} }
+ \cs_set_nopar:Npn \zitie_color_set:nn #1#2 { \color_set:nn {#1} {#2} }
+ \cs_set_nopar:Npn \zitie_color_set:nnn #1#2#3 { \color_set:nnn {#1} {#2} {#3} }
}
\NewDocumentCommand \zitiecolorlet { m o m }
- { \IfNoValueTF {#2} { \zitie_color_select:nn {#1} {#3} } { \zitie_color_select:nnn {#1} {#2} {#3} } }
+ { \IfNoValueTF {#2} { \zitie_color_set:nn {#1} {#3} } { \zitie_color_set:nnn {#1} {#2} {#3} } }
+\tl_new:N \zitiebasechar
+\tl_new:N \l__zitie_basechar_fontsize_tl
\box_new:N \l_zitie_basebox_box
\tl_new:N \l_zitie_frame_type_tl
\tl_new:N \l_zitie_resize_method_tl
\clist_new:N \g__zitie_frame_list_clist
\clist_new:N \g__zitie_resize_method_clist
-\dim_new:N \l__zitie_char_width_dim
-\dim_new:N \l__zitie_char_height_dim
\dim_new:N \l__zitie_box_width_dim
\dim_new:N \l__zitie_box_height_dim
\coffin_new:N \l__zitie_box_coffin
\dim_new:N \l__zitie_linewidth_dim
\cs_new_nopar:Nn \__zitie_aux_color_fill: { }
\ior_new:N \g__zitie_file_read_ior
-\clist_new:N \g__zitie_fallback_font_clist
+\clist_new:N \l__zitie_fallback_font_clist
+\int_new:N \l__zitie_repeat_int
+\dim_new:N \l__zitie_tolerance_dim
+\int_new:N \l__zitie_tallheight_int
+\dim_new:N \zitiebasecharwidth
+\dim_new:N \zitiebasecharheight
\dim_new:N \zitiewidth
\dim_new:N \zitieheight
\dim_new:N \zitieboxwd
@@ -58,58 +60,19 @@
\tl_const:Nn \c_zitie_font_name_prefix_tl { 字帖@ }
-%%% fontspec, xeCJK, xetex
-\cs_new:Npn \zitie_stroke_chars:nn #1#2 % operator, chars
- { \special { pdf:code ~ q ~ #1 } #2 \special { pdf:code ~ Q } }
-\cs_new:Npn \zitiestrokechars { \zitie_stroke_chars:nn }
-\prg_set_eq_conditional:NNn \zitie_font_if_exist:n \fontspec_font_if_exist:n { T, F, TF }
-\cs_new_nopar:Npn \__zitie_zihao:n #1 { \zihao {#1} }
-\cs_set_eq:NN \__zitie_check_num_range:nnNN \__xeCJK_check_num_range:nnNN
-\cs_set_eq:NN \__zitie_int_until_do:nn \xeCJK_int_until_do:nn
-\cs_new_nopar:Npn \__zitie_font_select:nN #1
- {
- \xeCJK_family_if_exist:nTF { \c_zitie_font_name_prefix_tl #1 }
- { \CJKfamily+ { \c_zitie_font_name_prefix_tl #1 } }
- { \CJKfamily+ {#1} }
- }
-\NewDocumentCommand \zitieCJKfamily { t+ t- m }
+\sys_if_engine_xetex:TF { \tex_input:D zitie.xetex.def \prg_do_nothing: }
{
- \xeCJK_family_if_exist:nTF { \c_zitie_font_name_prefix_tl #3 }
- { \xeCJK_family:NNx #1 #2 { \c_zitie_font_name_prefix_tl #3 } }
- { \xeCJK_family:NNx #1 #2 {#3} }
- \tex_ignorespaces:D
+ \sys_if_engine_luatex:TF { \tex_input:D zitie.luatex.def \prg_do_nothing: }
+ { \msg_fatal:nnx { zitie } { engine } { \c_sys_engine_str } }
}
+\prg_set_eq_conditional:NNn \zitie_font_if_exist:n \fontspec_font_if_exist:n { T, F, TF }
+\cs_new_nopar:Npn \__zitie_zihao:n #1 { \zihao {#1} }
+\msg_new:nnn { zitie } { engine } { Engine~ must~ be~ `xetex'~ or~ `luatex', while~ you~ use~ `#1'. }
\msg_new:nnn { zitie } { font-exist } { Font~ `#1'~ not~ exist, has~ been~ ignored. }
-\cs_new:Npn \__zitie_new_font_family:nnn #1#2#3 % family name, font name, feature
- { \__xeCJK_pass_args:nnnn { \xeCJK_set_family:nnn { \c_zitie_font_name_prefix_tl #1 } } {#3} {#2} { } }
-\cs_new:Npn \__zitie_new_font_family_validate:nnn #1#2#3
- {
- \zitie_font_if_exist:nTF {#2} { \__zitie_new_font_family:nnn {#1} {#2} {#3} }
- { \msg_warning:nnn { zitie } { font-exist } {#2} }
- }
-\cs_new:Npn \zitie_token_class_dispatch:Nnnnn #1
- {
- \if_case:w \xeCJK_token_value_class:N #1 \exp_stop_f:
- \exp_after:wN \use_none:nnn % other
- \or: \exp_after:wN \use_i:nnnn % CJK
- \or: \exp_after:wN \use_ii:nnnn % FullLeft
- \or: \exp_after:wN \use_iii:nnnn % FullRight
- \else: \exp_after:wN \use_none:nnn % other
- \fi:
- }
\cs_new:Npn \zitie_token_class_dispatch_o:Nnnnn #1
{ \exp_after:wN \zitie_token_class_dispatch:Nnnnn #1 }
\cs_new:Npn \zitie_token_class_dispatch_f:Nnnnn #1
{ \exp_args:Nf \zitie_token_class_dispatch:Nnnnn #1 }
-\prg_new_conditional:Npnn \zitie_token_if_punctuation:N #1 { p, T, F, TF }
- {
- \int_compare:nNnTF { \xeCJK_token_value_class:N #1 } > 1
- {
- \int_compare:nNnTF { \xeCJK_token_value_class:N #1 } < 6
- { \prg_return_true: } { \prg_return_false: }
- }
- { \prg_return_false: }
- }
\cs_set:Npn \zitie_token_if_punctuation_o:NTF
{ \exp_after:wN \zitie_token_if_punctuation:NTF }
\cs_set:Npn \zitie_token_if_punctuation_o:NT
@@ -134,9 +97,34 @@
}
\cs_new:Npn \__zitie_calc_basechar_w_h:
{
- \dim_set:Nn \l__zitie_char_width_dim { \box_wd:N \l_zitie_basebox_box }
- \dim_set:Nn \l__zitie_char_height_dim { \box_ht_plus_dp:N \l_zitie_basebox_box }
+ \hbox_set:Nn \l_zitie_basebox_box { \l__zitie_basechar_fontsize_tl \zitiebasechar }
+ \dim_set:Nn \zitiebasecharwidth { \box_wd:N \l_zitie_basebox_box }
+ \dim_set:Nn \zitiebasecharheight { \box_ht_plus_dp:N \l_zitie_basebox_box }
+ }
+\dim_new:N \l__zitie_linetotal_dim
+\dim_new:N \l__zitie_linemax_dim
+\cs_new:Npn \__zitie_break_max_calc:
+ {
+ \dim_set:Nn \l__zitie_linemax_dim
+ {
+ .5\paperwidth + .5\textwidth
+ - \marginparwidth - \marginparsep
+ + \l__zitie_tolerance_dim
+ }
}
+\cs_new_protected:Npn \__zitie_break_default:
+ {
+ \if_dim:w \l__zitie_linemax_dim > \l__zitie_linetotal_dim
+ \tex_advance:D \l__zitie_linetotal_dim by 1.1\zitieboxwd
+ \if_dim:w \l__zitie_linemax_dim < \l__zitie_linetotal_dim
+ \dim_zero:N \l__zitie_linetotal_dim \break
+ \else: \nobreak
+ \fi:
+ \else:
+ \dim_zero:N \l__zitie_linetotal_dim \break
+ \fi:
+ }
+
\cs_new_nopar:Npn \zitie_frame_type:n #1 { __zitie_frame_construct_type_ #1 :nnnnnn } % x1, y1, x2, y2, x times, y times
\cs_new_nopar:Npn \zitie_frame_type_c:n #1 { \use:c { __zitie_frame_construct_type_ #1 :nnnnnn } }
\cs_new_nopar:Npn \__zitie_resize:n #1 { __zitie_processor_resize_ #1 :n }
@@ -166,17 +154,17 @@
}
\cs_new_nopar:Npn \__zitie_cjk_glyph_use_aux:N #1
{
- \exp_args:Nf \xeCJK_glyph_if_exist:NTF #1 {#1}
+ \exp_args:Nf \zitie_glyph_if_exist:NTF #1 {#1}
{
- \clist_pop:NNTF \g__zitie_fallback_font_clist \l__zitie_tmpa_tl
+ \clist_pop:NNTF \l__zitie_fallback_font_clist \l__zitie_tmpa_tl
{
- \xeCJK_family_if_exist:nTF { \c_zitie_font_name_prefix_tl \l__zitie_tmpa_tl }
+ \zitie_family_if_exist:nTF { \c_zitie_font_name_prefix_tl \l__zitie_tmpa_tl }
{
- \CJKfamily+ { \c_zitie_font_name_prefix_tl \l__zitie_tmpa_tl }
+ \zitierawCJKfamily+ { \c_zitie_font_name_prefix_tl \l__zitie_tmpa_tl }
\__zitie_cjk_glyph_use_aux:N #1
}
{
- \CJKfamily+ { \l__zitie_tmpa_tl }
+ \zitierawCJKfamily+ { \l__zitie_tmpa_tl }
\__zitie_cjk_glyph_use_aux:N #1
}
}
@@ -200,12 +188,16 @@
\keys_define:nn { zitie }
{
- basechar .code:n = { \tl_gset:Nx \c_zitie_basechar_tl {#1} \__zitie_calc_basechar_w_h: } ,
- zihao .code:n =
- {
- \hbox_gset:Nn \l_zitie_basebox_box { \__zitie_zihao:n {#1} \c_zitie_basechar_tl }
- \__zitie_calc_basechar_w_h:
- } ,
+ basechar .code:n = { \tl_set:Nx \zitiebasechar {#1} \__zitie_calc_basechar_w_h: } ,
+ basechar .initial:n = 好 ,
+ basecharfontsize .code:n = { \tl_set:Nn \l__zitie_basechar_fontsize_tl {#1} \__zitie_calc_basechar_w_h: } ,
+ basecharfontsize .initial:n = \normalsize ,
+ basecharfontsize .default:n = \normalsize ,
+ zihao .meta:n = { basecharfontsize = \__zitie_zihao:n {#1} } ,
+ position .choice: ,
+ position / unknown .code:n = { \cs_set_eq:cc { \zitie_processor:n { position } } {#1} } ,
+ position* .cs_set:cp = { \zitie_processor:n { position } } #1 ,
+ anchor .meta:n = { position = anchor-#1 } ,
punctuation .choice: ,
punctuation / ignore .code:n = { \cs_set_eq:cN { \zitie_processor:n { punctuation } } \use_none:n } ,
punctuation / leave .code:n = { \cs_set_eq:cN { \zitie_processor:n { punctuation } } \use:n } ,
@@ -227,7 +219,7 @@
} ,
font .tl_set:N = \l__zitie_font_tl ,
font .initial:n = 宋体 ,
- font .default:n = { } , % { \l_xeCJK_family_tl } ,
+ font .default:n = { } ,
xscale .tl_set:N = \l__zitie_x_scale_tl ,
xscale .initial:n = 1 ,
yscale .tl_set:N = \l__zitie_y_scale_tl ,
@@ -237,26 +229,33 @@
height .dim_set:N = \l__zitie_box_height_dim ,
linewidth .dim_set:N = \l__zitie_linewidth_dim ,
linewidth .initial:n = 0.4pt ,
- framecolor .code:n = { \zitie_color_select:nn { zitieframecolor } {#1} } ,
+ holdbasecharwidth .bool_set:N = \l__zitie_holdbasechar_width_bool ,
+ holdbasecharwidth .default:n = true ,
+ holdbasecharheight .bool_set:N = \l__zitie_holdbasechar_height_bool ,
+ holdbasecharheight .default:n = true ,
+ holdbasechar .meta:n = { holdbasecharwidth = #1 , holdbasecharheight = #1 } ,
+ holdbasechar .initial:n = false ,
+ holdbasechar .default:n = true ,
+ framecolor .code:n = { \zitie_color_set:nn { zitieframecolor } {#1} } ,
framecolor .initial:n = black ,
- framecolor* .code:n = { \zitie_color_select:nnn { zitieframecolor } #1 } ,
- charcolor .code:n = { \zitie_color_select:nn { zitiecharcolor } {#1} } ,
+ framecolor* .code:n = { \zitie_color_set:nnn { zitieframecolor } #1 } ,
+ charcolor .code:n = { \zitie_color_set:nn { zitiecharcolor } {#1} } ,
charcolor .initial:n = black ,
- charcolor* .code:n = { \zitie_color_select:nnn { zitieframecolor } {#1} } ,
+ charcolor* .code:n = { \zitie_color_set:nnn { zitieframecolor } {#1} } ,
color .meta:n = { framecolor = #1, charcolor = #1 } ,
color* .meta:n = { framecolor* = #1, charcolor* = #1 } ,
fillcolor .code:n =
{
\exp_args:Nx \tl_if_empty:nTF {#1}
- { \zitie_color_select:nn { zitiefillcolor } { white } \cs_set_nopar:Npn \__zitie_aux_color_fill: { } }
+ { \zitie_color_set:nn { zitiefillcolor } { white } \cs_set_nopar:Npn \__zitie_aux_color_fill: { } }
{
- \zitie_color_select:nn { zitiefillcolor } {#1}
+ \zitie_color_set:nn { zitiefillcolor } {#1}
\cs_set_nopar:Npn \__zitie_aux_color_fill: { \color_fill:n {#1} }
}
} ,
fillcolor* .code:n =
{
- \zitie_color_select:nnn { zitiefillcolor } #1
+ \zitie_color_set:nnn { zitiefillcolor } #1
\cs_set_nopar:Npn \__zitie_aux_color_fill: { \color_fill:nn #1 }
} ,
dashpattern .tl_set:N = \l__zitie_dash_pattern_tl ,
@@ -283,22 +282,37 @@
debug .bool_set:N = \l__zitie_debug_bool ,
debug .initial:n = false ,
debug .default:n = true ,
+ repeat .int_set:N = \l__zitie_repeat_int ,
+ repeat .initial:n = 1 ,
+ tolerance .dim_set:N = \l__zitie_tolerance_dim ,
+ tolerance .initial:n = 1em ,
+ break .choice: ,
+ break / default .code:n = { \cs_set_eq:NN \__zitie_break: \__zitie_break_default: } ,
+ break / allowbreak .code:n = { \cs_set_eq:NN \__zitie_break: \allowbreak } ,
+ break / unknown .code:n = { \cs_set_eq:NN \__zitie_break: #1 } ,
+ break .initial:n = allowbreak ,
+ tallheight .int_set:N = \l__zitie_tallheight_int ,
+ tallheight .initial:n = 1000 ,
+
savefontname .bool_set:N = \l__zitie_savefontname_bool ,
savefontname .initial:n = false ,
savefontname .default:n = true ,
fallback .bool_set:N = \l__zitie_font_fallback_bool ,
fallback .initial:n = false ,
fallback .default:n = true ,
- fallbackfont .clist_set:N = \g__zitie_fallback_font_clist ,
+ fallbackfont .clist_set:N = \l__zitie_fallback_font_clist ,
fallbackfont .initial:n = { 宋体 } ,
- fallbackfont+ .code:n = { \clist_put_right:Nn \g__zitie_fallback_font_clist {#1} } ,
+ fallbackfont+ .code:n = { \clist_put_right:Nn \l__zitie_fallback_font_clist {#1} } ,
+ validateglyph .bool_set:N = \l__zitie_validate_glyph_bool ,
+ validateglyph .initial:n = false ,
+ validateglyph .default:n = true ,
}
\hook_new_pair:nn { zitie/processor/before } { zitie/processor/after }
\cs_new:Npn \zitie_new_process_rule:nnn #1#2#3 % processor, id, code
{
- \cs_set:cpn { __zitie_processor_ #1 @ #2 :n } ##1
- { \hook_use:n { zitie/processor/before } #3 \hook_use:n { zitie/processor/after } }
+ \cs_set:cpn { __zitie_processor_ #1 @ #2 :n } ##1 {#3}
+ % { \hook_use:n { zitie/processor/before } #3 \hook_use:n { zitie/processor/after } }
\keys_define:nn { zitie }
{ #1/#2 .code:n = { \cs_set_eq:cc { \zitie_processor:n {#1} } { __zitie_processor_ #1 @ #2 :n } } }
}
@@ -309,8 +323,11 @@
\keys_define:nn { zitie }
{ #1/#2 .code:n = { \cs_set_eq:cc { \zitie_processor:n {#1} } { \zitie_processor:nnn {#1} {#2} {#3} } } }
}
-\NewDocumentCommand \zitienewrule { O{1} >{\TrimSpaces} m > {\TrimSpaces} m m }
+\NewDocumentCommand \zitienewprocessorrule { O{1} >{\TrimSpaces} m > {\TrimSpaces} m m }
{ \zitie_new_process_rule:nnnn {#2} {#3} {#1} {#4} }
+\cs_new_protected:Npn \zitienewrule { \zitienewprocessorrule }
+\NewDocumentCommand \zitieuseprocessorrule { O{1} m m }
+ { \zitie_processor_c:nnn {#1} {#2} {#3} }
\zitie_new_process_rule:nnn { punctuation } { onlast }
{ \tex_penalty:D 10000\smash{ \makebox[0pt]{ \color_select:n { zitiecharcolor } \zitieCJKfamily{\zitiefontname} #1 } } }
\zitie_new_process_rule:nnn { punctuation } { scale }
@@ -326,6 +343,37 @@
{ \zitie_stroke_chars:nn { 2 ~ Tr ~ 0.25 ~ w ~ [] ~ 0 ~ d ~ 1 ~ J ~ 1 ~ 1 ~ 1 ~ rg } {#1} }
\zitie_new_process_rule:nnn { charstroke } { whitedashed }
{ \zitie_stroke_chars:nn { 2 ~ Tr ~ 0.25 ~ w ~ [.8] ~ 0 ~ d ~ 1 ~ J ~ 1 ~ 1 ~ 1 ~ rg } {#1} }
+\zitie_new_process_rule:nnn { charstroke } { thicksolid }
+ { \zitie_stroke_chars:nn { 1 ~ Tr ~ 0.15 ~ w ~ [] ~ 0 ~ d ~ 1 ~ J } {#1} }
+\zitie_new_process_rule:nnn { charstroke } { thickdashed }
+ { \zitie_stroke_chars:nn { 1 ~ Tr ~ 0.15 ~ w ~ [.8] ~ 0 ~ d ~ 1 ~ J } {#1} }
+\zitie_new_process_rule:nnn { charstroke } { thickwhitesolid }
+ { \zitie_stroke_chars:nn { 2 ~ Tr ~ 0.15 ~ w ~ [] ~ 0 ~ d ~ 1 ~ J ~ 1 ~ 1 ~ 1 ~ rg } {#1} }
+\zitie_new_process_rule:nnn { charstroke } { thickwhitedashed }
+ { \zitie_stroke_chars:nn { 2 ~ Tr ~ 0.15 ~ w ~ [.8] ~ 0 ~ d ~ 1 ~ J ~ 1 ~ 1 ~ 1 ~ rg } {#1} }
+\zitie_new_process_rule:nnn { charstroke } { invisible }
+ { \zitie_stroke_chars:nn { 3 ~ Tr } {#1} }
+%% position processor need new first
+\cs_new:cpn { \zitie_processor:n { position } } #1
+ { \coffin_typeset:Nnnnn #1 { l } { b } { 0pt } { 0pt } }
+\zitie_new_process_rule:nnn { position } { anchor-center }
+ { \coffin_typeset:Nnnnn #1 { hc } { vc } { 0pt } { 0pt } }
+\zitie_new_process_rule:nnn { position } { anchor-east }
+ { \coffin_typeset:Nnnnn #1 { r } { vc } { 0pt } { 0pt } }
+\zitie_new_process_rule:nnn { position } { anchor-southeast }
+ { \coffin_typeset:Nnnnn #1 { r } { b } { 0pt } { 0pt } }
+\zitie_new_process_rule:nnn { position } { anchor-south }
+ { \coffin_typeset:Nnnnn #1 { hc } { b } { 0pt } { 0pt } }
+\zitie_new_process_rule:nnn { position } { anchor-southwest }
+ { \coffin_typeset:Nnnnn #1 { l } { b } { 0pt } { 0pt } }
+\zitie_new_process_rule:nnn { position } { anchor-west }
+ { \coffin_typeset:Nnnnn #1 { l } { vc } { 0pt } { 0pt } }
+\zitie_new_process_rule:nnn { position } { anchor-northwest }
+ { \coffin_typeset:Nnnnn #1 { l } { t } { 0pt } { 0pt } }
+\zitie_new_process_rule:nnn { position } { anchor-north }
+ { \coffin_typeset:Nnnnn #1 { hc } { t } { 0pt } { 0pt } }
+\zitie_new_process_rule:nnn { position } { anchor-northeast }
+ { \coffin_typeset:Nnnnn #1 { r } { t } { 0pt } { 0pt } }
\cs_new:Npn \__zitie_new_font_family:nn #1#2 { \__zitie_new_font_family:nnn {#1} {#2} { } }
@@ -367,6 +415,8 @@
\clist_put_right:Nn \g__zitie_resize_method_clist {#1}
\cs_new:cpn { \__zitie_resize:n {#1} }
}
+\cs_new:Npn \zitie_resize_method_set_eq:nn #1#2
+ { \cs_set_eq:cc { \__zitie_resize:n {#1} } { \__zitie_resize:n {#2} } }
\zitie_new_resize_method:nn { none } { }
\cs_new:Npn \zitie_new_frame_construct:nn #1
{
@@ -374,12 +424,12 @@
\cs_new:cn { \zitie_frame_type:n {#1} }
}
\zitie_new_frame_construct:nn { none } { }
+\cs_new:Npn \zitie_frame_type_set_eq:nn #1#2
+ { \cs_set_eq:cc { \zitie_frame_type:n {#1} } { \zitie_frame_type:n {#2} } }
\zitie_font_if_exist:nT { SimSun } { \zitie_new_font:n { {宋体}{SimSun} } }
\keys_set:nn { zitie }
{
- basechar = 好 ,
- zihao = 4 ,
frametype = none ,
resize = none ,
}
@@ -388,16 +438,66 @@
\cs_new:Npn \zitie_single_construct:nN #1#2
{
\group_begin:
+ \__zitie_calc_basechar_w_h:
\tl_if_empty:nF {#1} { \keys_set:nn { zitie } {#1} }
\tl_set:Nf \l__zitie_curr_char_tl {#2}
- \__zitie_single_construct_o:N \l__zitie_curr_char_tl
+ \hcoffin_set:Nn \l__zitie_box_coffin
+ { \__zitie_single_construct_o:N \l__zitie_curr_char_tl }
+ \zitie_processor_c:n { position } \l__zitie_box_coffin
\group_end:
}
+\cs_new_protected:Npn \zitie_single_construct_f:nN
+ { \exp_args:Nnf \zitie_single_construct:nN }
\cs_new:Npn \zitie_single_construct:N #1
{
\group_begin:
+ \__zitie_calc_basechar_w_h:
\tl_set:Nf \l__zitie_curr_char_tl {#1}
- \__zitie_single_construct_o:N \l__zitie_curr_char_tl
+ \hcoffin_gset:Nn \l__zitie_box_coffin
+ { \__zitie_single_construct_o:N \l__zitie_curr_char_tl }
+ \zitie_processor_c:n { position } \l__zitie_box_coffin
+ \group_end:
+ }
+\cs_new_protected:Npn \zitie_single_construct_f:N
+ { \exp_args:Nf \zitie_single_construct:N }
+\bool_new:N \g__zitie_glyph_exist_bool
+\cs_new:Npn \zitie_single_validate_glyph_construct:nN #1#2
+ {
+ \group_begin:
+ \tl_if_empty:nF {#1} { \keys_set:nn { zitie } {#1} }
+ {
+ \zitieCJKfamily+ { \l__zitie_font_tl }
+ \exp_after:wN \zitie_glyph_if_exist:NTF #2
+ { \bool_gset_true:N \g__zitie_glyph_exist_bool }
+ { \bool_gset_false:N \g__zitie_glyph_exist_bool }
+ }
+ \bool_if:NT \g__zitie_glyph_exist_bool
+ {
+ \__zitie_calc_basechar_w_h:
+ \tl_set:Nf \l__zitie_curr_char_tl {#2}
+ \hcoffin_set:Nn \l__zitie_box_coffin
+ { \__zitie_single_construct_o:N \l__zitie_curr_char_tl }
+ \zitie_processor_c:n { position } \l__zitie_box_coffin
+ }
+ \group_end:
+ }
+\cs_new:Npn \zitie_single_validate_glyph_construct:N #1
+ {
+ \group_begin:
+ {
+ \zitieCJKfamily+ { \l__zitie_font_tl }
+ \exp_after:wN \zitie_glyph_if_exist:NTF #1
+ { \bool_gset_true:N \g__zitie_glyph_exist_bool }
+ { \bool_gset_false:N \g__zitie_glyph_exist_bool }
+ }
+ \bool_if:NT \g__zitie_glyph_exist_bool
+ {
+ \__zitie_calc_basechar_w_h:
+ \tl_set:Nf \l__zitie_curr_char_tl {#1}
+ \hcoffin_gset:Nn \l__zitie_box_coffin
+ { \__zitie_single_construct_o:N \l__zitie_curr_char_tl }
+ \zitie_processor_c:n { position } \l__zitie_box_coffin
+ }
\group_end:
}
\cs_new:Npn \__zitie_single_construct:N #1
@@ -405,19 +505,29 @@
\zitie_token_if_punctuation_f:NTF #1
{ \zitie_processor_c:n { punctuation } {#1} }
{
- \hcoffin_set:Nn \l__zitie_box_coffin
+ \hcoffin_set:Nn \l__zitie_tmpb_coffin
{
+ \bool_if:NT \l__zitie_holdbasechar_height_bool { \vphantom \zitiebasechar }
\color_select:n { zitiecharcolor }
- \zitie_processor_c:n { charstroke }
- { \zitie_cjk_glyph_use:nN { \l__zitie_font_tl } \l__zitie_curr_char_tl }
+ \bool_if:NTF \l__zitie_holdbasechar_width_bool
+ {
+ \makebox [ \dim_use:N \zitiebasecharwidth ] [c] {
+ \zitie_processor_c:n { charstroke }
+ { \zitie_cjk_glyph_use:nN { \l__zitie_font_tl } \l__zitie_curr_char_tl }
+ }
+ }
+ {
+ \zitie_processor_c:n { charstroke }
+ { \zitie_cjk_glyph_use:nN { \l__zitie_font_tl } \l__zitie_curr_char_tl }
+ }
}
- \tl_set:Nx \zitiexscaleratio { \dim_to_decimal:n { \coffin_wd:N \l__zitie_box_coffin} }
- \tl_set:Nx \zitieyscaleratio { \dim_to_decimal:n { \__zitie_coffin_ht_plus_dp:N \l__zitie_box_coffin } }
+ \tl_set:Nx \zitiexscaleratio { \dim_to_decimal:n { \coffin_wd:N \l__zitie_tmpb_coffin} }
+ \tl_set:Nx \zitieyscaleratio { \dim_to_decimal:n { \__zitie_coffin_ht_plus_dp:N \l__zitie_tmpb_coffin } }
\__zitie_resize_c:n { \l_zitie_resize_method_tl }
- \dim_gset:Nn \zitiewidth { \coffin_wd:N \l__zitie_box_coffin }
+ \dim_gset:Nn \zitiewidth { \coffin_wd:N \l__zitie_tmpb_coffin }
\dim_gset_eq:NN \zitieboxwd \zitiewidth
- \dim_gset:Nn \zitieboxht { \coffin_ht:N \l__zitie_box_coffin }
- \dim_gset:Nn \zitieboxdp { \coffin_dp:N \l__zitie_box_coffin }
+ \dim_gset:Nn \zitieboxht { \coffin_ht:N \l__zitie_tmpb_coffin }
+ \dim_gset:Nn \zitieboxdp { \coffin_dp:N \l__zitie_tmpb_coffin }
\dim_gset:Nn \zitieheight { \zitieboxht + \zitieboxdp }
\tl_gset:Nx \zitiexscaleratio { \fp_eval:n { \dim_to_fp:n { \zitiewidth } / \zitiexscaleratio } }
\tl_gset:Nx \zitieyscaleratio { \fp_eval:n { \dim_to_fp:n { \zitieheight } / \zitieyscaleratio } }
@@ -457,54 +567,54 @@
\zitie_new_resize_method:nn { real }
{
\__zitie_force_size_dispatch:nnnn
- { \coffin_resize:Nnn \l__zitie_box_coffin \l__zitie_box_width_dim \l__zitie_box_height_dim }
+ { \coffin_resize:Nnn \l__zitie_tmpb_coffin \l__zitie_box_width_dim \l__zitie_box_height_dim }
{
- \coffin_scale:Nnn \l__zitie_box_coffin
- { \dim_ratio:nn { \l__zitie_box_height_dim } { \__zitie_coffin_ht_plus_dp:N \l__zitie_box_coffin } }
- { \dim_ratio:nn { \l__zitie_box_height_dim } { \__zitie_coffin_ht_plus_dp:N \l__zitie_box_coffin } }
+ \coffin_scale:Nnn \l__zitie_tmpb_coffin
+ { \dim_ratio:nn { \l__zitie_box_height_dim } { \__zitie_coffin_ht_plus_dp:N \l__zitie_tmpb_coffin } }
+ { \dim_ratio:nn { \l__zitie_box_height_dim } { \__zitie_coffin_ht_plus_dp:N \l__zitie_tmpb_coffin } }
}
{
- \coffin_scale:Nnn \l__zitie_box_coffin
- { \dim_ratio:nn { \l__zitie_box_width_dim } { \coffin_wd:N \l__zitie_box_coffin } }
- { \dim_ratio:nn { \l__zitie_box_width_dim } { \coffin_wd:N \l__zitie_box_coffin } }
+ \coffin_scale:Nnn \l__zitie_tmpb_coffin
+ { \dim_ratio:nn { \l__zitie_box_width_dim } { \coffin_wd:N \l__zitie_tmpb_coffin } }
+ { \dim_ratio:nn { \l__zitie_box_width_dim } { \coffin_wd:N \l__zitie_tmpb_coffin } }
}
- { \coffin_scale:Nnn \l__zitie_box_coffin { \l__zitie_x_scale_tl } { \l__zitie_y_scale_tl } }
+ { \coffin_scale:Nnn \l__zitie_tmpb_coffin { \l__zitie_x_scale_tl } { \l__zitie_y_scale_tl } }
}
\zitie_new_resize_method:nn { base }
{
\__zitie_force_size_dispatch:nnnn
- { \coffin_resize:Nnn \l__zitie_box_coffin \l__zitie_box_width_dim \l__zitie_box_height_dim }
+ { \coffin_resize:Nnn \l__zitie_tmpb_coffin \l__zitie_box_width_dim \l__zitie_box_height_dim }
{
- \coffin_resize:Nnn \l__zitie_box_coffin
- { \l__zitie_char_width_dim * \dim_ratio:nn { \l__zitie_box_height_dim } { \__zitie_coffin_ht_plus_dp:N \l__zitie_box_coffin } }
+ \coffin_resize:Nnn \l__zitie_tmpb_coffin
+ { \zitiebasecharwidth * \dim_ratio:nn { \l__zitie_box_height_dim } { \__zitie_coffin_ht_plus_dp:N \l__zitie_tmpb_coffin } }
{ \l__zitie_box_height_dim }
}
{
- \coffin_resize:Nnn \l__zitie_box_coffin
+ \coffin_resize:Nnn \l__zitie_tmpb_coffin
{ \l__zitie_box_width_dim }
- { \l__zitie_char_height_dim * \dim_ratio:nn { \l__zitie_box_width_dim } { \coffin_wd:N \l__zitie_box_coffin } }
+ { \zitiebasecharheight * \dim_ratio:nn { \l__zitie_box_width_dim } { \coffin_wd:N \l__zitie_tmpb_coffin } }
}
{
- \coffin_resize:Nnn \l__zitie_box_coffin
- { \l__zitie_x_scale_tl \l__zitie_char_width_dim }
- { \l__zitie_y_scale_tl \l__zitie_char_height_dim }
+ \coffin_resize:Nnn \l__zitie_tmpb_coffin
+ { \l__zitie_x_scale_tl \zitiebasecharwidth }
+ { \l__zitie_y_scale_tl \zitiebasecharheight }
}
}
\zitie_new_resize_method:nn { square }
{
- \hcoffin_set:Nn \l__zitie_tmpa_coffin { \phantom { \c_zitie_basechar_tl } }
- \dim_set:Nn \zitiewidth { \coffin_wd:N \l__zitie_box_coffin }
- \dim_set:Nn \zitieheight { \__zitie_coffin_ht_plus_dp:N \l__zitie_box_coffin }
+ \hcoffin_set:Nn \l__zitie_tmpa_coffin { \phantom { \zitiebasechar } }
+ \dim_set:Nn \zitiewidth { \coffin_wd:N \l__zitie_tmpb_coffin }
+ \dim_set:Nn \zitieheight { \__zitie_coffin_ht_plus_dp:N \l__zitie_tmpb_coffin }
\__zitie_resize_method_square_aux:
\tl_set:Nx \zitiexscaleratio { \dim_to_decimal:n \zitiewidth }
\tl_set_eq:NN \zitieyscaleratio \zitiexscaleratio
\__zitie_force_size_dispatch:nnnn
- { \coffin_resize:Nnn \l__zitie_box_coffin \l__zitie_box_width_dim \l__zitie_box_height_dim }
- { \coffin_resize:Nnn \l__zitie_box_coffin \l__zitie_box_height_dim \l__zitie_box_height_dim }
- { \coffin_resize:Nnn \l__zitie_box_coffin \l__zitie_box_width_dim \l__zitie_box_width_dim }
- { \coffin_scale:Nnn \l__zitie_box_coffin \l__zitie_x_scale_tl \l__zitie_y_scale_tl }
+ { \coffin_resize:Nnn \l__zitie_tmpb_coffin \l__zitie_box_width_dim \l__zitie_box_height_dim }
+ { \coffin_resize:Nnn \l__zitie_tmpb_coffin \l__zitie_box_height_dim \l__zitie_box_height_dim }
+ { \coffin_resize:Nnn \l__zitie_tmpb_coffin \l__zitie_box_width_dim \l__zitie_box_width_dim }
+ { \coffin_scale:Nnn \l__zitie_tmpb_coffin \l__zitie_x_scale_tl \l__zitie_y_scale_tl }
}
\cs_new:Npn \__zitie_resize_method_square_aux:
{
@@ -512,15 +622,15 @@
\coffin_resize:Nnn \l__zitie_tmpa_coffin
{ ( \zitieheight - \zitiewidth ) / 2 }
{ \zitieheight }
- \coffin_join:NnnNnnnn \l__zitie_box_coffin { r } { vc } \l__zitie_tmpa_coffin { l } { vc } { 0pt } { 0pt }
- \coffin_join:NnnNnnnn \l__zitie_box_coffin { l } { vc } \l__zitie_tmpa_coffin { r } { vc } { 0pt } { 0pt }
+ \coffin_join:NnnNnnnn \l__zitie_tmpb_coffin { r } { vc } \l__zitie_tmpa_coffin { l } { vc } { 0pt } { 0pt }
+ \coffin_join:NnnNnnnn \l__zitie_tmpb_coffin { l } { vc } \l__zitie_tmpa_coffin { r } { vc } { 0pt } { 0pt }
\dim_set_eq:NN \zitiewidth \zitieheight
\else: \if_dim:w \zitiewidth > \zitieheight
\coffin_resize:Nnn \l__zitie_tmpa_coffin
{ \zitiewidth }
{ ( \zitiewidth - \zitieheight ) / 2 }
- \coffin_join:NnnNnnnn \l__zitie_box_coffin { hc } { t } \l__zitie_tmpa_coffin { hc } { b } { 0pt } { 0pt }
- \coffin_join:NnnNnnnn \l__zitie_box_coffin { hc } { b } \l__zitie_tmpa_coffin { hc } { t } { 0pt } { 0pt }
+ \coffin_join:NnnNnnnn \l__zitie_tmpb_coffin { hc } { t } \l__zitie_tmpa_coffin { hc } { b } { 0pt } { 0pt }
+ \coffin_join:NnnNnnnn \l__zitie_tmpb_coffin { hc } { b } \l__zitie_tmpa_coffin { hc } { t } { 0pt } { 0pt }
\dim_set_eq:NN \zitieheight \zitiewidth
\fi: \fi:
}
@@ -530,25 +640,28 @@
{
\draw_begin:
\draw_linewidth:n { \l__zitie_linewidth_dim }
- \__zitie_aux_color_fill:
\color_stroke:n { zitieframecolor }
\tl_if_empty:NF \l__zitie_dash_pattern_tl { \exp_args:No \draw_dash_pattern:nn { \l__zitie_dash_pattern_tl } { 0pt } }
\exp_after:wN \draw_path_corner_arc:nn \l__zitie_frame_arc_tl
+ \cs_if_eq:NNF \__zitie_aux_color_fill: \c_empty_tl
+ {
+ \__zitie_aux_color_fill:
+ \draw_path_rectangle_corners:nn { 0 , 0 } { \zitiewidth , \zitieheight }
+ \draw_path_use_clear:n { fill }
+ }
\zitie_frame_type_c:n { \l_zitie_frame_type_tl } { 0 } { 0 } { \zitiewidth } { \zitieheight } { 1 } { 1 }
- \draw_coffin_use:Nnn \l__zitie_box_coffin { l } { b }
+ \draw_coffin_use:Nnn \l__zitie_tmpb_coffin { l } { b }
\draw_end:
}
\zitie_new_frame_construct:nn { 口 }
{
\draw_path_rectangle_corners:nn { #1 , #2 } { #3 , #4 }
- \cs_if_eq:NNTF \__zitie_aux_color_fill: \c_empty_tl
- { \draw_path_use_clear:n { stroke } }
- { \draw_path_use_clear:n { stroke , fill } }
+ \draw_path_use_clear:n { stroke , clip }
}
\zitie_new_frame_construct:nn { 十 }
{
\draw_path_moveto:n { (#3)/2 , #2 }
- \draw_path_lineto:n { #3/2 , #4 }
+ \draw_path_lineto:n { (#3)/2 , #4 }
\draw_path_moveto:n { #1 , (#4)/2 }
\draw_path_lineto:n { #3 , (#4)/2 }
\draw_path_use_clear:n { stroke }
@@ -578,19 +691,68 @@
\zitie_frame_type_c:n { 十 } {#1} {#2} {#3} {#4} {#5} {#6}
}
+\cs_new:Npn \zitie_repeat:Nnn #1#2#3 % repeat, code, mid
+ {
+ \if_int_compare:w #1 = 1 \exp_stop_f: #2
+ \else:
+ \if_int_compare:w #1 > 1 \exp_stop_f:
+ #2 #3 \int_decr:N #1
+ \zitie_repeat:Nnn {#1} {#2} {#3}
+ \fi:
+ \fi:
+ }
+
\NewDocumentCommand \zitienewfont { s } { \IfBooleanTF {#1} { \zitie_new_font:nnn } { \zitie_new_font:n } }
+\hook_new:n { zitie/repeat }
+\hook_new_pair:nn { zitie/framesingle/before } { zitie/framesingle/after }
+\NewDocumentCommand \framesingle { O{} m }
+ {
+ \group_begin:
+ \keys_set_filter:nnn { zitie } { geometry } {#1}
+ \hook_use:n { zitie/framesingle/before }
+ \bool_if:NTF \l__zitie_savefontname_bool
+ { \tl_gset_eq:NN \zitiefontname \l__zitie_font_tl }
+ { \tl_gset_eq:NN \zitiefontname \c_empty_tl }
+ \bool_if:NTF \l__zitie_validate_glyph_bool
+ {
+ \zitieCJKfamily+ { \l__zitie_font_tl }
+ \exp_args:Nf \zitie_glyph_if_exist:NT #2
+ {
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ { \zitie_single_construct_f:N #2 }
+ { \hook_use:n { zitie/repeat } }
+ }
+ }
+ {
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ { \zitie_single_construct_f:N #2 }
+ { \hook_use:n { zitie/repeat } }
+ }
+ \hook_use:n { zitie/framesingle/after }
+ \group_end:
+ }
\hook_new_pair:nn { zitie/framezi/before } { zitie/framezi/after }
\NewDocumentCommand \framezi { s O{} m }
{
\group_begin:
\tl_if_empty:nF {#2} { \keys_set_filter:nnn { zitie } { geometry } {#2} }
+ \tex_pretolerance:D = 10000
+ \__zitie_break_max_calc:
\hook_use:n { zitie/framezi/before }
\bool_if:NTF \l__zitie_savefontname_bool
{ \tl_gset_eq:NN \zitiefontname \l__zitie_font_tl }
{ \tl_gset_eq:NN \zitiefontname \c_empty_tl }
\IfBooleanTF {#1}
- { \tl_map_inline:Nn #3 { \zitie_single_construct:N ##1 \allowbreak } }
- { \tl_map_inline:nn {#3} { \zitie_single_construct:N ##1 \allowbreak } }
+ {
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ { \tl_map_inline:Nn #3 { \zitie_single_construct:N ##1 \__zitie_break: } }
+ { \hook_use:n { zitie/repeat } }
+ }
+ {
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ { \tl_map_inline:nn {#3} { \zitie_single_construct:N ##1 \__zitie_break: } }
+ { \hook_use:n { zitie/repeat } }
+ }
\hook_use:n { zitie/framezi/after }
\group_end:
}
@@ -600,36 +762,100 @@
{
\group_begin:
\tl_if_empty:nF {#1} { \keys_set_filter:nnn { zitie } { geometry } {#1} }
+ \tex_pretolerance:D = 10000
+ \__zitie_break_max_calc:
\hook_use:n { zitie/framerange/before }
\bool_if:NTF \l__zitie_savefontname_bool
{ \tl_gset_eq:NN \zitiefontname \l__zitie_font_tl }
{ \tl_gset_eq:NN \zitiefontname \c_empty_tl }
- \clist_map_inline:nn {#2}
+ \zitie_repeat:Nnn \l__zitie_repeat_int
{
- \str_if_eq:nnF {##1} { -> }
- {
- \__zitie_frame_range_aux:Nnw \__zitie_check_num_range:nnNN {##1}
- \l__zitie_begin_int \l__zitie_end_int
- \__zitie_int_until_do:nn { \l__zitie_begin_int > \l__zitie_end_int }
- {
- \group_begin:
- \tl_set:Nf \l__zitie_curr_char_tl { \tex_Uchar:D \l__zitie_begin_int }
- \__zitie_single_construct_o:N \l__zitie_curr_char_tl
- \group_end: \allowbreak
- \int_incr:N \l__zitie_begin_int
- }
+ \clist_map_inline:nn {#2}
+ {
+ \str_if_eq:nnF {##1} { -> }
+ {
+ \__zitie_frame_range_aux:Nnw \__zitie_check_num_range:nnNN {##1}
+ \l__zitie_begin_int \l__zitie_end_int
+ \__zitie_int_until_do:nn { \l__zitie_begin_int > \l__zitie_end_int }
+ {
+ \group_begin:
+ \tl_set:Nf \l__zitie_curr_char_tl { \tex_Uchar:D \l__zitie_begin_int }
+ \zitie_single_construct_f:N \l__zitie_curr_char_tl
+ \group_end: \__zitie_break:
+ \int_incr:N \l__zitie_begin_int
+ }
+ }
+ \hook_use:n { zitie/framerange/range }
}
- \hook_use:n { zitie/framerange/range }
}
+ { \hook_use:n { zitie/repeat } }
\hook_use:n { zitie/framerange/after }
\group_end:
}
\NewDocumentCommand \__zitie_frame_range_aux:Nnw { m >{ \SplitArgument { 1 } { -> } } m } { #1 #2 }
+\hook_new_pair:nn { zitie/frametallrange/before } { zitie/frametallrange/after }
+\hook_new:n { zitie/frametallrange/range }
+\int_new:N \l__zitie_tall_tmp_int
+\NewDocumentCommand \frametallrange { O{} m }
+ {
+ \group_begin:
+ \tl_if_empty:nF {#1} { \keys_set_filter:nnn { zitie } { geometry } {#1} }
+ \tex_pretolerance:D = 10000
+ \__zitie_break_max_calc:
+ \hook_use:n { zitie/frametallrange/before }
+ \bool_if:NTF \l__zitie_savefontname_bool
+ { \tl_gset_eq:NN \zitiefontname \l__zitie_font_tl }
+ { \tl_gset_eq:NN \zitiefontname \c_empty_tl }
+ \int_decr:N \l__zitie_tallheight_int
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ {
+ \clist_map_inline:nn {#2}
+ {
+ \str_if_eq:nnF {##1} { -> }
+ {
+ \__zitie_frame_range_aux:Nnw \__zitie_check_num_range:nnNN {##1}
+ \l__zitie_begin_int \l__zitie_end_int
+ \__zitie_split_range:nnnNn \l__zitie_begin_int \l__zitie_end_int { \l__zitie_tallheight_int }
+ \__zitie_tallrange_split_do:nn
+ { \__zitie_tall_par: }
+ }
+ \hook_use:n { zitie/frametallrange/range }
+ }
+ }
+ { \hook_use:n { zitie/repeat } }
+ \hook_use:n { zitie/frametallrange/after }
+ \group_end:
+ }
+\cs_new:Npn \__zitie_tallrange_split_do:nn #1#2
+ {
+ \int_set:Nn \l__zitie_tall_tmp_int {#1}
+ \int_until_do:nn { \l__zitie_tall_tmp_int > #2 }
+ {
+ \group_begin:
+ \tl_set:Nf \l__zitie_curr_char_tl { \tex_Uchar:D \l__zitie_tall_tmp_int }
+ \zitie_single_construct_f:N \l__zitie_curr_char_tl
+ \group_end: \__zitie_break:
+ \int_incr:N \l__zitie_tall_tmp_int
+ }
+ }
+\cs_new:Npn \__zitie_split_range:nnnNn #1#2#3#4#5
+ {
+ \int_set:Nn \l__zitie_begin_int {#1}
+ \int_compare:nNnTF { \l__zitie_begin_int + #3 } > {#2}
+ { #4 { \l__zitie_begin_int } {#2} #5 }
+ {
+ #4 { \l__zitie_begin_int } { \l__zitie_begin_int + #3 }
+ #5
+ \__zitie_split_range:nnnNn { \l__zitie_begin_int + #3 + 1 } {#2} {#3} #4 {#5}
+ }
+ }
+\cs_new:Npn \__zitie_tall_par: % TeXbook 14.15
+ { {\parfillskip=0pt\par\parskip=0pt\noindent} }
\cs_new:Npn \__zitie_construct_loop:N #1
{
\tl_if_eq:nnTF #1 \par { \par \hook_use:n { zitie/zitieframe/par } \__zitie_construct_loop:N }
- { \quark_if_nil:nF {#1} { \zitie_single_construct:N #1 \allowbreak \__zitie_construct_loop:N } }
+ { \quark_if_nil:nF {#1} { \zitie_single_construct:N #1 \__zitie_break: \__zitie_construct_loop:N } }
}
\hook_new_pair:nn { zitie/zitieframe/before } { zitie/zitieframe/after }
\hook_new:n { zitie/zitieframe/par }
@@ -638,12 +864,16 @@
\group_begin:
\lineskip=0pt \parindent=0pt \parskip=0pt \raggedright
\tl_if_empty:nF {#2} { \keys_set:nn { zitie } {#2} }
+ \tex_pretolerance:D = 10000
+ \__zitie_break_max_calc:
\hook_use:n { zitie/zitieframe/before }
#1
\bool_if:NTF \l__zitie_savefontname_bool
{ \tl_gset_eq:NN \zitiefontname \l__zitie_font_tl }
{ \tl_gset_eq:NN \zitiefontname \c_empty_tl }
- \__zitie_construct_loop:N #3 \q_nil
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ { \__zitie_construct_loop:N #3 \q_nil }
+ { \hook_use:n { zitie/repeat } }
} { \hook_use:n { zitie/zitieframe/after } \group_end: }
\hook_new_pair:nn { zitie/framezifile/before } { zitie/framezifile/after }
@@ -651,6 +881,8 @@
{
\group_begin:
\tl_if_empty:nF {#2} { \keys_set_filter:nnn { zitie } { geometry } {#2} }
+ \tex_pretolerance:D = 10000
+ \__zitie_break_max_calc:
\hook_use:n { zitie/framezifile/before }
\bool_if:NTF \l__zitie_savefontname_bool
{ \tl_gset_eq:NN \zitiefontname \l__zitie_font_tl }
@@ -658,17 +890,85 @@
\IfBooleanTF {#1}
{
\file_get:nnN {#3} { } \l__zitie_file_chars_tl
- \tl_map_inline:Nn \l__zitie_file_chars_tl { \zitie_single_construct:N ##1 \allowbreak }
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ { \tl_map_inline:Nn \l__zitie_file_chars_tl { \zitie_single_construct:N ##1 \__zitie_break: } }
+ { \hook_use:n { zitie/repeat } }
}
{
\ior_open:Nn \g__zitie_file_read_ior {#3}
- \ior_map_inline:Nn \g__zitie_file_read_ior
- { \tl_map_inline:nn {##1} { \zitie_single_construct:N ####1 \allowbreak } }
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ {
+ \ior_map_inline:Nn \g__zitie_file_read_ior
+ { \tl_map_inline:nn {##1} { \zitie_single_construct:N ####1 \__zitie_break: } }
+ }
+ { \hook_use:n { zitie/repeat } }
\ior_close:N \g__zitie_file_read_ior
}
\hook_use:n { zitie/framezifile/after }
\group_end:
}
+\hook_new_pair:nn { zitie/framezitallfile/before } { zitie/framezitallfile/after }
+\NewDocumentCommand \framezitallfile { s O{} m }
+ {
+ \group_begin:
+ \tl_if_empty:nF {#2} { \keys_set_filter:nnn { zitie } { geometry } {#2} }
+ \tex_pretolerance:D = 10000
+ \__zitie_break_max_calc:
+ \hook_use:n { zitie/framezitallfile/before }
+ \bool_if:NTF \l__zitie_savefontname_bool
+ { \tl_gset_eq:NN \zitiefontname \l__zitie_font_tl }
+ { \tl_gset_eq:NN \zitiefontname \c_empty_tl }
+ \int_decr:N \l__zitie_tallheight_int
+ \IfBooleanTF {#1}
+ {
+ \file_get:nnN {#3} { } \l__zitie_file_chars_tl
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ { \__zitie_tallfile_get_aux:N \l__zitie_file_chars_tl }
+ { \hook_use:n { zitie/repeat } }
+ }
+ {
+ \ior_open:Nn \g__zitie_file_read_ior {#3}
+ \zitie_repeat:Nnn \l__zitie_repeat_int
+ { \__zitie_tallfile_ior_aux:N \g__zitie_file_read_ior }
+ { \hook_use:n { zitie/repeat } }
+ \ior_close:N \g__zitie_file_read_ior
+ }
+ \hook_use:n { zitie/framezitallfile/after }
+ \group_end:
+ }
+\cs_new:Npn \__zitie_tallfile_get_aux:N #1
+ {
+ \int_zero:N \l__zitie_tall_tmp_int
+ \tl_map_inline:Nn #1
+ {
+ \zitie_single_construct:N ##1
+ \if_int_compare:w \l__zitie_tall_tmp_int < \l__zitie_tallheight_int
+ \int_incr:N \l__zitie_tall_tmp_int
+ \__zitie_break:
+ \else:
+ \int_zero:N \l__zitie_tall_tmp_int
+ \__zitie_tall_par:
+ \fi:
+ }
+ }
+\cs_new:Npn \__zitie_tallfile_ior_aux:N #1
+ {
+ \int_zero:N \l__zitie_tall_tmp_int
+ \ior_map_inline:Nn #1
+ {
+ \tl_map_inline:nn {##1}
+ {
+ \zitie_single_construct:N ####1
+ \if_int_compare:w \l__zitie_tall_tmp_int < \l__zitie_tallheight_int
+ \int_incr:N \l__zitie_tall_tmp_int
+ \__zitie_break:
+ \else:
+ \int_zero:N \l__zitie_tall_tmp_int
+ \__zitie_tall_par:
+ \fi:
+ }
+ }
+ }
\if_bool:N \g__zitie_enable_background_bool
@@ -774,23 +1074,23 @@
} ,
frametype .tl_gset:N = \g__zitie_background_frametype_tl ,
linewidth .dim_gset:N = \g__zitie_background_linewidth_dim ,
- framecolor .code:n = { \zitie_color_select:nn { zitiebackgroundframecolor } {#1} } ,
- framecolor* .code:n = { \zitie_color_select:nnn { zitiebackgroundframecolor } #1 } ,
+ framecolor .code:n = { \zitie_color_set:nn { zitiebackgroundframecolor } {#1} } ,
+ framecolor* .code:n = { \zitie_color_set:nnn { zitiebackgroundframecolor } #1 } ,
fillcolor .code:n =
{
\exp_args:Nx \tl_if_empty:nTF {#1}
{
- \zitie_color_select:nn { zitiebackgroundfillcolor } { white }
+ \zitie_color_set:nn { zitiebackgroundfillcolor } { white }
\cs_gset_nopar:Npn \__zitie_background_aux_color_fill: { }
}
{
- \zitie_color_select:nn { zitiebackgroundfillcolor } {#1}
+ \zitie_color_set:nn { zitiebackgroundfillcolor } {#1}
\cs_gset_nopar:Npn \__zitie_background_aux_color_fill: { \color_fill:n {#1} }
}
} ,
fillcolor* .code:n =
{
- \zitie_color_select:nnn { zitiebackgroundfillcolor } #1
+ \zitie_color_set:nnn { zitiebackgroundfillcolor } #1
\cs_gset_nopar:Npn \__zitie_background_aux_color_fill: { \color_fill:nn #1 }
} ,
dashpattern .tl_gset:N = \g__zitie_background_dash_pattern_tl ,
@@ -849,10 +1149,10 @@
\hook_gput_code:nnn { shipout/#1 } { zitie/background }
{ \put ( \dim_eval:n {#2} , \dim_eval:n {#3} ) { \__zitie_background_construct_draw: } }
}
-\cs_new_protected:Npn \__zitie_background_construct:nnnn #1#2#3#4
+\cs_new_protected:Npn \__zitie_background_construct:nnnnn #1#2#3#4#5
{
\hook_gput_code:nnn { shipout/#1 } { zitie/background/#2 }
- { \put ( \dim_eval:n {#3} , \dim_eval:n {#4} ) { \__zitie_background_construct_draw: } }
+ { \put ( \dim_eval:n {#3} , \dim_eval:n {#4} ) {#5} }
}
\cs_new_protected:Npn \__zitie_background_next_construct:nnn #1#2#3
{
@@ -871,18 +1171,29 @@
\tl_if_empty:NF \g__zitie_background_dash_pattern_tl
{ \exp_args:No \draw_dash_pattern:nn { \g__zitie_background_dash_pattern_tl } { 0pt } }
\draw_linewidth:n { \g__zitie_background_linewidth_dim }
- \__zitie_background_aux_color_fill:
+ \draw_path_rectangle_corners:nn
+ { 0cm - .5\g__zitie_background_linewidth_dim , 0cm - .5\g__zitie_background_linewidth_dim }
+ {
+ \g__zitie_background_x_right_dim - \g__zitie_background_x_left_dim + .5\g__zitie_background_linewidth_dim ,
+ \g__zitie_background_y_bottom_dim - \g__zitie_background_y_top_dim + .5\g__zitie_background_linewidth_dim
+ }
+ \cs_if_eq:NNTF \__zitie_background_aux_color_fill: \c_empty_tl
+ { \draw_path_use_clear:n { clip } }
+ { \color_fill:n { zitiebackgroundfillcolor } \draw_path_use_clear:n { clip , fill } }
\color_stroke:n { zitiebackgroundframecolor }
\zitie_background_frame_type_c:n { \g__zitie_background_frametype_tl }
- { 0cm } { 0cm }
- { \g__zitie_background_x_right_dim - \g__zitie_background_x_left_dim }
- { \g__zitie_background_y_bottom_dim - \g__zitie_background_y_top_dim }
+ { 0cm - .5\g__zitie_background_linewidth_dim }
+ { 0cm - .5\g__zitie_background_linewidth_dim }
+ { \g__zitie_background_x_right_dim - \g__zitie_background_x_left_dim + .5\g__zitie_background_linewidth_dim }
+ { \g__zitie_background_y_bottom_dim - \g__zitie_background_y_top_dim + .5\g__zitie_background_linewidth_dim }
{ \g__zitie_background_boxwidth_dim }
{ \g__zitie_background_boxheight_dim }
\draw_end:
}
\cs_new:Npn \zitie_background_new_frame_construct:nn #1
{ \cs_set:cn { \zitie_background_frame_type:n {#1} } }
+\cs_new:Npn \zitie_background_frame_type_set_eq:nn #1#2
+ { \cs_set_eq:cc { \zitie_background_frame_type:n {#1} } { \zitie_background_frame_type:n {#2} } }
\int_new:N \l__zitie_background_tmpa_int
\int_new:N \l__zitie_background_tmpb_int
\fp_new:N \l__zitie_background_tmpa_fp
@@ -890,13 +1201,7 @@
\zitie_background_new_frame_construct:nn { none } { }
\zitie_background_new_frame_construct:nn { 口 }
{
- \cs_if_eq:NNF \__zitie_background_aux_color_fill: \c_empty_tl
- {
- \draw_path_rectangle_corners:nn { #1 , #2 } { #3 , #4 }
- \draw_path_use_clear:n { stroke , fill }
- }
- \draw_path_grid:nnnn { #5 } { #6 } { #1 , #2 }
- { #3+\g__zitie_background_linewidth_dim, #4+\g__zitie_background_linewidth_dim }
+ \draw_path_grid:nnnn { #5 } { #6 } { #1 , #2 } { #3 , #4 }
\draw_path_use_clear:n { stroke }
}
\zitie_background_new_frame_construct:nn { 十 }
@@ -924,10 +1229,12 @@
\int_set:Nn \l__zitie_background_tmpb_int { \fp_to_int:n { ceil( \dim_ratio:nn {(#4)-(#2)} {#6} ) } }
\if_int_compare:w \l__zitie_background_tmpa_int < \l__zitie_background_tmpb_int
\__zitie_background_frame_construct_aux_cross:nnnnnnnn
- {#1} {#2} {#3} {#4} {#5} {#6} { \l__zitie_background_tmpb_int } { }
+ {#1+\g__zitie_background_linewidth_dim} {#2+\g__zitie_background_linewidth_dim}
+ {#3} {#4} {#5} {#6} { \l__zitie_background_tmpb_int } { }
\else:
\__zitie_background_frame_construct_aux_cross:nnnnnnnn
- {#1} {#2} {#3} {#4} {#5} {#6} { \l__zitie_background_tmpa_int } { }
+ {#1+\g__zitie_background_linewidth_dim} {#2+\g__zitie_background_linewidth_dim}
+ {#3} {#4} {#5} {#6} { \l__zitie_background_tmpa_int } { }
\fi:
\draw_path_use_clear:n { stroke }
}
@@ -936,7 +1243,7 @@
\int_step_inline:nn {#7}
{
\draw_path_moveto:n { #1 , #2 + ##1*(#6) }
- \draw_path_lineto:n { #1 + ##1*#5 , #2 }
+ \draw_path_lineto:n { #1 + ##1*(#5) , #2 }
}
\int_step_inline:nn {#7}
{
@@ -945,12 +1252,12 @@
}
\int_step_inline:nn {#7}
{
- \draw_path_moveto:n { #1+#7*(#5)-##1 #5 , #2 }
+ \draw_path_moveto:n { #1+#7*(#5)-##1*(#5) , #2 }
\draw_path_lineto:n { #1+#7*(#5) , #2+(##1)*#6 }
}
\int_step_inline:nn {#7}
{
- \draw_path_moveto:n { #1 , #2+#7*#6-##1*(#6) }
+ \draw_path_moveto:n { #1 , #2+#7*(#6)-##1*(#6) }
\draw_path_lineto:n { #1+##1*(#5) , #2+#7*(#6) }
}
}
@@ -965,6 +1272,16 @@
\zitie_background_frame_type_c:n { 十 } {#1} {#2} {#3} {#4} {#5} {#6}
\zitie_background_frame_type_c:n { × } {#1} {#2} {#3} {#4} {#5} {#6}
}
+\zitie_background_new_frame_construct:nn { 二 }
+ {
+ \draw_path_grid:nnnn { #3-#1 } { #6 } { #1 , #2 } { #3 , #4 }
+ \draw_path_use_clear:n { stroke }
+ }
+\zitie_background_new_frame_construct:nn { || }
+ {
+ \draw_path_grid:nnnn { #5 } { #4-#2 } { #1 , #2 } { #3 , #4 }
+ \draw_path_use_clear:n { stroke }
+ }
%%% end of background
\else:
\msg_new:nnn { zitie } { background }
@@ -985,23 +1302,29 @@
\zhlipsum_if_exist:nTF {#3}
{
\tl_if_empty:nF {#1} { \keys_set_filter:nnn { zitie } { geometry } {#1} }
+ \tex_pretolerance:D = 10000
+ \__zitie_break_max_calc:
\hook_use:n { zitie/framezhlipsum/before }
\bool_if:NTF \l__zitie_savefontname_bool
{ \tl_gset_eq:NN \zitiefontname \l__zitie_font_tl }
{ \tl_gset_eq:NN \zitiefontname \c_empty_tl }
- \__zhlipsum_parse_par:nn {#3} {#2}
- \seq_if_empty:NF \l__zhlipsum_par_num_seq
+ \zitie_repeat:Nnn \l__zitie_repeat_int
{
- \seq_pop_right:NN \l__zhlipsum_par_num_seq \l__zhlipsum_tmpa_tl
- \seq_map_inline:Nn \l__zhlipsum_par_num_seq
+ \__zhlipsum_parse_par:nn {#3} {#2}
+ \seq_if_empty:NF \l__zhlipsum_par_num_seq
{
- \tl_map_inline:cn { \__zitie_zhlipsum_paras:nn {#3} {##1} }
- { \zitie_single_construct:N ####1 \allowbreak }
- \hook_use:n { zitie/framezhlipsum/paragraph }
+ \seq_pop_right:NN \l__zhlipsum_par_num_seq \l__zhlipsum_tmpa_tl
+ \seq_map_inline:Nn \l__zhlipsum_par_num_seq
+ {
+ \tl_map_inline:cn { \__zitie_zhlipsum_paras:nn {#3} {##1} }
+ { \zitie_single_construct:N ####1 \__zitie_break: }
+ \hook_use:n { zitie/framezhlipsum/paragraph }
+ }
+ \tl_map_inline:cn { \__zitie_zhlipsum_paras:nn {#3} { \l__zhlipsum_tmpa_tl } }
+ { \zitie_single_construct:N ##1 \__zitie_break: }
}
- \tl_map_inline:cn { \__zitie_zhlipsum_paras:nn {#3} { \l__zhlipsum_tmpa_tl } }
- { \zitie_single_construct:N ##1 \allowbreak }
}
+ { \hook_use:n { zitie/repeat } }
\hook_use:n { zitie/framezhlipsum/after }
}
{ \__zhlipsum_error:nn { invalid-name } {#3} }
diff --git a/macros/xetex/latex/zitie/tex/zitie.xetex.def b/macros/xetex/latex/zitie/tex/zitie.xetex.def
new file mode 100644
index 0000000000..fcb7dfa69b
--- /dev/null
+++ b/macros/xetex/latex/zitie/tex/zitie.xetex.def
@@ -0,0 +1,52 @@
+\RequirePackage { xeCJK }
+\bool_lazy_and:nnT { \sys_if_platform_windows_p: }
+ { \tl_if_eq_p:NN \CJK@family \c_empty_tl }
+ { \setCJKmainfont {SimSun} }
+\cs_new:Npn \zitie_stroke_chars:nn #1#2 % operator, chars
+ { \special { pdf:code ~ q ~ #1 } #2 \special { pdf:code ~ Q } }
+\cs_new:Npn \zitiestrokechars { \zitie_stroke_chars:nn }
+
+\cs_set_eq:NN \__zitie_check_num_range:nnNN \__xeCJK_check_num_range:nnNN
+\cs_set_eq:NN \__zitie_int_until_do:nn \xeCJK_int_until_do:nn
+\cs_set_eq:NN \zitierawCJKfamily \CJKfamily
+\prg_set_eq_conditional:NNn \zitie_family_if_exist:n \xeCJK_family_if_exist:n { T, F, TF }
+\prg_set_eq_conditional:NNn \zitie_glyph_if_exist:N \xeCJK_glyph_if_exist:N { p, T, F, TF }
+\cs_new_nopar:Npn \__zitie_font_select:nN #1
+ {
+ \zitie_family_if_exist:nTF { \c_zitie_font_name_prefix_tl #1 }
+ { \zitierawCJKfamily+ { \c_zitie_font_name_prefix_tl #1 } }
+ { \zitierawCJKfamily+ {#1} }
+ }
+\NewDocumentCommand \zitieCJKfamily { t+ t- m }
+ {
+ \zitie_family_if_exist:nTF { \c_zitie_font_name_prefix_tl #3 }
+ { \xeCJK_family:NNx #1 #2 { \c_zitie_font_name_prefix_tl #3 } }
+ { \xeCJK_family:NNx #1 #2 {#3} }
+ \tex_ignorespaces:D
+ }
+\cs_new:Npn \__zitie_new_font_family:nnn #1#2#3 % family name, font name, feature
+ { \__xeCJK_pass_args:nnnn { \xeCJK_set_family:nnn { \c_zitie_font_name_prefix_tl #1 } } {#3} {#2} { } }
+\cs_new:Npn \__zitie_new_font_family_validate:nnn #1#2#3
+ {
+ \zitie_font_if_exist:nTF {#2} { \__zitie_new_font_family:nnn {#1} {#2} {#3} }
+ { \msg_warning:nnn { zitie } { font-exist } {#2} }
+ }
+\cs_new:Npn \zitie_token_class_dispatch:Nnnnn #1
+ {
+ \if_case:w \xeCJK_token_value_class:N #1 \exp_stop_f:
+ \exp_after:wN \use_none:nnn % other
+ \or: \exp_after:wN \use_i:nnnn % CJK
+ \or: \exp_after:wN \use_ii:nnnn % FullLeft
+ \or: \exp_after:wN \use_iii:nnnn % FullRight
+ \else: \exp_after:wN \use_none:nnn % other
+ \fi:
+ }
+\prg_new_conditional:Npnn \zitie_token_if_punctuation:N #1 { p, T, F, TF }
+ {
+ \int_compare:nNnTF { \xeCJK_token_value_class:N #1 } > 1
+ {
+ \int_compare:nNnTF { \xeCJK_token_value_class:N #1 } < 6
+ { \prg_return_true: } { \prg_return_false: }
+ }
+ { \prg_return_false: }
+ } \ No newline at end of file