texlive[60594] Master/texmf-dist: hanzibox (23sep21)

commits+karl at tug.org commits+karl at tug.org
Thu Sep 23 22:15:16 CEST 2021


Revision: 60594
          http://tug.org/svn/texlive?view=revision&revision=60594
Author:   karl
Date:     2021-09-23 22:15:15 +0200 (Thu, 23 Sep 2021)
Log Message:
-----------
hanzibox (23sep21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/xelatex/hanzibox/README.md
    trunk/Master/texmf-dist/doc/xelatex/hanzibox/hanzibox.pdf
    trunk/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx
    trunk/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty

Modified: trunk/Master/texmf-dist/doc/xelatex/hanzibox/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/xelatex/hanzibox/README.md	2021-09-23 20:14:53 UTC (rev 60593)
+++ trunk/Master/texmf-dist/doc/xelatex/hanzibox/README.md	2021-09-23 20:15:15 UTC (rev 60594)
@@ -1,5 +1,5 @@
 hanzibox
-LaTeX3 Chinese Character package, v1.01
+LaTeX3 Chinese Character package, v1.1.0
 =======
 
 `hanzibox` is a LaTeX package written to simplify the input of Chinese
@@ -17,11 +17,11 @@
 
 You can read the package manual (in Chinese) for more detailed explanations.
 
-Gitee repository: https://gitee.com/nwafu_nan/hanzibox-l3.
-
 Contributing
 ------------
 
+Gitee repository: https://gitee.com/nwafu_nan/hanzibox-l3.
+
 Issues and pull requests are welcome.
 
 Copyright and Licence

Modified: trunk/Master/texmf-dist/doc/xelatex/hanzibox/hanzibox.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx
===================================================================
--- trunk/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx	2021-09-23 20:14:53 UTC (rev 60593)
+++ trunk/Master/texmf-dist/source/xelatex/hanzibox/hanzibox.dtx	2021-09-23 20:15:15 UTC (rev 60594)
@@ -5,7 +5,7 @@
 %</internal>
 %<*readme>
 hanzibox
-LaTeX3 Chinese Character package, v1.01
+LaTeX3 Chinese Character package, v1.1.0
 =======
 
 `hanzibox` is a LaTeX package written to simplify the input of Chinese
@@ -23,11 +23,11 @@
 
 You can read the package manual (in Chinese) for more detailed explanations.
 
-Gitee repository: https://gitee.com/nwafu_nan/hanzibox-l3.
-
 Contributing
 ------------
 
+Gitee repository: https://gitee.com/nwafu_nan/hanzibox-l3.
+
 Issues and pull requests are welcome.
 
 Copyright and Licence
@@ -87,7 +87,7 @@
 
     This work has the LPPL maintenance status "maintained".
 
-    The Current Maintainer of this work is Nan Geng Nan Geng.
+    The Current Maintainer of this work is Nan Geng.
 
 --------------------------------------------------------------------------
 
@@ -114,14 +114,14 @@
   {
 %</install>
 %<*internal>
-    \usedir{source/latex/hanzibox}
+    \usedir{source/xelatex/hanzibox}
     \file{hanzibox.ins} {\from{\jobname.dtx}{install}}
 %</internal>
 %<*install>
-    \usedir{tex/latex/hanzibox}
+    \usedir{xetex/xelatex/hanzibox}
     \file{hanzibox.sty} {\from{\jobname.dtx}{package}}
     \nopreamble\nopostamble
-    \usedir{doc/latex/hanzibox}
+    \usedir{doc/xelatex/hanzibox}
     \file{README.md}   {\from{\jobname.dtx}{readme}}
   }
 
@@ -132,7 +132,7 @@
 %</internal>
 %<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01]
 %<package>\RequirePackage{expl3}
-%<+package>\GetIdInfo$Id: hanzibox.dtx 1.0.0 2021-09-18 20:00:00Z +0800 Nan Geng <nangeng at nwafu.edu.cn> $
+%<+package>\GetIdInfo$Id: hanzibox.dtx 1.1.0 2021-09-23 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
 %<package>  {Boxed Chinese characters with Pinyin above and translation below.}
 %<package>\ProvidesExplPackage{\ExplFileName}
 %<package>  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -141,7 +141,6 @@
 \usepackage{listings}
 \usepackage{xcolor}
 \usepackage{xcolor-material}
-\usepackage{xpinyin}
 \usepackage{hanzibox}
 \renewcommand*\marg[1]{\{\meta{#1}\}}
 \renewcommand*\oarg[1]{[\meta{#1}]}
@@ -161,7 +160,8 @@
 %
 % \changes{v1.0.0}{2021/09/18}{开始编写模板。}
 %
-% \CheckSum{0}
+% \CheckSum{420}
+% \GetFileId{hanzibox.sty}
 %
 % \CharacterTable
 %  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -179,7 +179,6 @@
 %   Grave accent  \`     Left brace    \{     Vertical bar  \|
 %   Right brace   \}     Tilde         \~}
 %
-% \GetFileId{hanzibox.sty}
 %
 % \title{\bfseries\pkg{hanzibox}:田字格-米字格汉字练习宏包}
 % \author{耿楠\\ \path{nangeng at nwafu.edu.cn}}
@@ -190,17 +189,24 @@
 %
 % \begin{abstract}
 %
-% \pkg{hanzibox} 是一个用\LaTeX3开发的 \LaTeX 宏包,提供了汉字学习中的田字格
-% 或米字格功能,并可以根据需要在汉字正上方显示拼音,在正下方显示需要的译文。
+% \pkg{hanzibox} 是一个用\LaTeX3开发的 \LaTeX 宏包,它提供了\tn{hanzidialog}和\tn{hanzibox}
+% 两个命令。这两个命令用于输出汉字学习中的田字格或米字格,并可以根据需要在汉字正上方显示拼音,
+% 在正下方显示需要的译文。其中,\tn{hanzidialog}命令的注音功能通过手动插入\pkg{xpinyin}宏包的
+% \tn{pinyin}命令实现。\tn{hanzibox}命令的注音功能自动调用\pkg{xpinyin}宏包的\tn{pinyin}命令实现,
+% 并且\tn{hanzibox}命令提供了\tn{hanzibox*}星号版本,该星号版本能够根据汉字自动调用
+% \pkg{xpinyin}宏包的\tn{xpinyin*}命令实现汉字注音。
 %
 % \end{abstract}
 %
 % \section{简要说明}
 %
-% 建议使用\pkg{hanzibox}宏包的\LaTeX 源文件总是采用 \texttt{UTF-8}。
+% \pkg{hanzibox} 是一个用于输出汉字学习中的田字格或米字格,并在汉字正上方显示拼音,
+% 在正下方显示需要的译文。同时,也可以根据需要隐藏拼音、汉字或译文。
 %
-% \pkg{hanzibox} 还依赖 \package{l3kernel} 和 \package{l3packages}。
+% 使用\pkg{hanzibox}宏包的\LaTeX 源文件需采用 \texttt{UTF-8}编码,并且需使用\XeLaTeX 进行编译。
 %
+% \pkg{hanzibox} 依赖 \package{l3kernel} 和 \package{l3packages}。
+%
 % \section{用户接口}
 %
 % \begin{function}[added=2021-09-18,updated=2021-09-19]{\hanzidialog}
@@ -234,7 +240,7 @@
 %   星号命令用于根据汉字自动在顶部排版拼音,在底部排版译文。\\
 %   此时,\oarg{拼音选项}中的拼音无效,可以留空,但若有译文则该选项不可省略;
 %   \oarg{译文选项}可以是任意文本。\\
-%   注意:此时的注意由\pkg{xpinyin}宏包实现,如需要设置多音字的拼音,请参阅其宏包说明。
+%   注意:此时的注音由\pkg{xpinyin}宏包实现,如需要设置多音字的拼音,请参阅其宏包说明。
 %   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.43\linewidth,gobble=5]
 %     \hanzibox*[inner=none,border=false]{我}[][me]
 %     \hanzibox*[inner=cross,border=true]{我}[][吾]
@@ -266,18 +272,36 @@
 %
 % 布尔型的参数 \kvopt{\meta{选项}}{true} 中的“|= true|”可以省略。
 %
+% \changes{v1.1.0}{2021/09/22}{添加外观选项设置命令示例代码。}
+%
+% \begin{frameverb}
+%   \hanziboxset{
+%     scale       = 0.8,       % 整体缩放比例
+%     inner       = star,      % 盒子内部图案
+%     border      = true,      % 是否有边框
+%     borderwidth = 1.5 pt,    % 边框宽度
+%     bordercolor = red,       % 边框颜色
+%     fgcolor     = red,       % 盒子前景色(文字颜色)
+%     bgcolor     = yellow!50, % 盒子背景色
+%     withpinyin  = false,     % 是否显示拼音
+%     withhanzi   = true,      % 是否显示汉字
+%     withtran    = true       % 是否显示译文
+%    }
+% \end{frameverb}
+%
 % 注:各选项也可以以相同的键值列表在汉字盒子命令的外观选项中进行设置。
 %
 % \subsection{缩放比例}
 %
-% \begin{function}[added=2021-09-20]{ratio}
+% \changes{v1.1.0}{2021/09/22}{将缩放比例键ratio改为scale。}
+%
+% \begin{function}[added=2021-09-20,updated=2021-09-22]{scale}
 %   \begin{syntax}
-%     ratio = \Arg{number}
+%     scale = \Arg{number}
 %   \end{syntax}
 %   设置\tn{hanzibox}命令绘制汉字盒子及其拼音和译文的整体缩放比例,默认值为\textbf{1.0}。
 % \end{function}
 %
-%
 % \subsection{汉字边框}
 %
 % \begin{function}[added=2021-09-20]{border}
@@ -301,6 +325,26 @@
 %   为\tn{hanzibox}命令设置汉字的边框颜色,默认值为\textbf{black}。该选项对\tn{hanzidialog}命令无效。
 % \end{function}
 %
+% \changes{v1.1.0}{2021/09/21}{添加前景颜色设置选项。}
+%
+% \begin{function}[added=2021-09-21]{fgcolor}
+%   \begin{syntax}
+%     fgcolor = \Arg{color}
+%   \end{syntax}
+%   为\tn{hanzibox}命令设置汉字盒子前景颜色(文字颜色),
+%   默认值为\textbf{black}。该选项对\tn{hanzidialog}命令无效。
+% \end{function}
+%
+% \changes{v1.1.0}{2021/09/21}{添加背景颜色设置选项。}
+%
+% \begin{function}[added=2021-09-21]{bgcolor}
+%   \begin{syntax}
+%     bgcolor = \Arg{color}
+%   \end{syntax}
+%   为\tn{hanzibox}命令设置汉字盒子背景颜色(填充颜色),
+%   默认值为\textbf{white}。该选项对\tn{hanzidialog}命令无效。
+% \end{function}
+%
 % \subsection{格子样式}
 %
 % \begin{function}[added=2021-09-20]{inner}
@@ -311,6 +355,65 @@
 %   默认值为\textbf{none}。该选项对\tn{hanzidialog}命令无效。
 % \end{function}
 %
+% \changes{v1.1.0}{2021/09/21}{添加隐藏拼音选项。}
+%
+% \subsection{内容隐藏}
+%
+% \begin{function}[added=2021-09-21]{withpinyin}
+%   \begin{syntax}
+%     withpinyin = <\TTF>
+%   \end{syntax}
+%   为\tn{hanzibox}命令选择是否输出拼音,默认值为\textbf{true}。该选项对\tn{hanzidialog}命令无效。
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=5]
+%     \hanzibox[inner=cross]{我}[wo3][吾]
+%     \hanzibox[withpinyin=false,inner=star]{我}[wo3][不才]
+%     \hanzibox[bordercolor=red]{我们}[wo3men5][吾辈]
+%   \end{SideBySideExample}
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=5]
+%     \hanzibox*[inner=cross]{我}[][吾]
+%     \hanzibox*[withpinyin=false,inner=star]{我}[wo3][不才]
+%     \hanzibox*[bordercolor=red]{我们}[wo3][吾辈]
+%   \end{SideBySideExample}
+% \end{function}
+%
+% \changes{v1.1.0}{2021/09/21}{添加隐藏汉字选项。}
+%
+% \begin{function}[added=2021-09-21]{withhanzi}
+%   \begin{syntax}
+%     withhanzi = <\TTF>
+%   \end{syntax}
+%   为\tn{hanzibox}命令选择是否输出汉字,默认值为\textbf{true}。该选项对\tn{hanzidialog}命令无效。
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=5]
+%     \hanzibox[inner=cross]{我}[wo3][吾]
+%     \hanzibox[withhanzi=false,inner=star]{我}[wo3][不才]
+%     \hanzibox[bordercolor=red]{我们}[wo3men5][吾辈]
+%   \end{SideBySideExample}
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=5]
+%     \hanzibox*[inner=cross]{我}[][吾]
+%     \hanzibox*[withhanzi=false,inner=star]{我}[wo3][不才]
+%     \hanzibox*[bordercolor=red]{我们}[wo3][吾辈]
+%   \end{SideBySideExample}
+% \end{function}
+%
+% \changes{v1.1.0}{2021/09/21}{添加隐藏译文选项。}
+%
+% \begin{function}[added=2021-09-21]{withtran}
+%   \begin{syntax}
+%     withtran = <\TTF>
+%   \end{syntax}
+%   为\tn{hanzibox}命令选择是否输出译文,默认值为\textbf{true}。该选项对\tn{hanzidialog}命令无效。
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=5]
+%     \hanzibox[inner=cross]{我}[wo3][吾]
+%     \hanzibox[withtran=false,inner=star]{我}[wo3][不才]
+%     \hanzibox[bordercolor=red]{我们}[wo3men5][吾辈]
+%   \end{SideBySideExample}
+%   \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=5]
+%     \hanzibox*[inner=cross]{我}[][吾]
+%     \hanzibox*[withtran=false,inner=star]{我}[wo3][不才]
+%     \hanzibox*[bordercolor=red]{我们}[wo3][吾辈]
+%   \end{SideBySideExample}
+% \end{function}
+%
 % \end{documentation}
 %
 % \StopEventually{}
@@ -374,15 +477,12 @@
 %    \begin{macrocode}
 \sys_if_engine_xetex:F
   {
-    \sys_if_engine_luatex:F
-      {
-        \msg_fatal:nnx { hanzibox } { unsupported-engine }
-          { \c_sys_engine_str }
-      }
+    \msg_fatal:nnx { hanzibox } { unsupported-engine }
+      { \c_sys_engine_str }
   }
 \msg_new:nnn { hanzibox } { unsupported-engine }
   {
-    The~ hanzibox~ packages~ requires~ either~ XeTeX~ or~ LuaTeX. \\\\
+    The~ hanzibox~ packages~ requires~ either~ XeTeX. \\\\
     "#1"~ is~ not~ supported~ at~ present.~ You~ must~ change \\
     your~ typesetting~ engine~ to~ "xelatex"~ or~ "lualatex".
   }
@@ -440,12 +540,16 @@
 %
 % \subsection{用户接口}
 %
+% \changes{v1.1.0}{2021/09/22}{为用户命令添加组限制。}
+%
 % \begin{macro}{\hanzidialog}
 % 手动汉字盒子命令。
 %    \begin{macrocode}
 \NewDocumentCommand{\hanzidialog}{ m O{} O{} }
   {
-    \@@_dialog:nnnn { #1 } { #2 } { #3 }
+    \group_begin:
+      \@@_dialog:nnnn { #1 } { #2 } { #3 }
+    \group_end:
   }
 
 %    \end{macrocode}
@@ -458,9 +562,13 @@
   {
     \IfBooleanTF{#1}
       {
-        \@@_star_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+        \group_begin:
+          \@@_asterisk_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+        \group_end:
       }{
-        \@@_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+        \group_begin:
+          \@@_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+        \group_end:
       }
   }
 
@@ -469,10 +577,18 @@
 %
 % \subsection{内部变量声明}
 %
-% \begin{variable}{\l_@@_inner_int,
+% \changes{v1.1.0}{2021/09/21}{添加缩放比例,前景/背景色,隐藏控制变量。}
+%
+% \begin{variable}{\fp_new:N \l_@@_scale_fp,
+%   \l_@@_inner_int,
 %   \l_@@_border_bool,
 %   \l_@@_borderwidth_dim,
 %   \l_@@_bordercolor_tl,
+%   \l_@@_fgcolor_tl,
+%   \l_@@_bgcolor_tl,
+%   \l_@@_pinyin_bool,
+%   \l_@@_hanzi_bool,
+%   \l_@@_tran_bool,
 %   \l_@@_pinyin_tl,
 %   \l_@@_character_tl,
 %   \l_@@_translation_tl,
@@ -481,12 +597,18 @@
 %   \l_@@_translation_int
 %  }
 % 临时变量。
+%
 %    \begin{macrocode}
-\fp_new:N \l_@@_ratio_fp
+\fp_new:N \l_@@_scale_fp
 \int_new:N \l_@@_inner_int
 \bool_new:N \l_@@_border_bool
 \dim_new:N \l_@@_borderwidth_dim
 \tl_new:N \l_@@_bordercolor_tl
+\tl_new:N \l_@@_fgcolor_tl
+\tl_new:N \l_@@_bgcolor_tl
+\bool_new:N \l_@@_pinyin_bool
+\bool_new:N \l_@@_hanzi_bool
+\bool_new:N \l_@@_tran_bool
 \tl_new:N \l_@@_pinyin_tl
 \tl_new:N \l_@@_character_tl
 \tl_new:N \l_@@_translation_tl
@@ -506,11 +628,13 @@
   {
 %    \end{macrocode}
 %
-% \begin{macro}{ratio}
+% \changes{v1.1.0}{2021/09/21}{添加缩放比例键。}
+%
+% \begin{macro}{scale}
 % 设置汉字及其拼音和译文的整体缩放比例。
 %    \begin{macrocode}
-    ratio .fp_set:N  = \l_@@_ratio_fp,
-    ratio .initial:n = 1.0,
+    scale .fp_set:N  = \l_@@_scale_fp,
+    scale .initial:n = 1.0,
 
 %    \end{macrocode}
 % \end{macro}
@@ -556,6 +680,65 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \changes{v1.1.0}{2021/09/21}{添加前景颜色键。}
+%
+% \begin{macro}{fgcolor}
+% 汉字盒子前景颜色(文字颜色),默认为black。
+%    \begin{macrocode}
+    fgcolor .tl_set:N  = \l_@@_fgcolor_tl,
+    fgcolor .initial:n = black,
+
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.1.0}{2021/09/21}{添加背景颜色键。}
+%
+% \begin{macro}{bgcolor}
+% 汉字盒子背景颜色,默认为black。
+%    \begin{macrocode}
+    bgcolor .tl_set:N  = \l_@@_bgcolor_tl,
+    bgcolor .initial:n = white,
+
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.1.0}{2021/09/21}{添加隐藏拼音键。}
+%
+% \begin{macro}{withpinyin}
+% 是否显示汉语拼音,默认为true。
+%    \begin{macrocode}
+    withpinyin .bool_set:N = \l_@@_pinyin_bool,
+    withpinyin .default:n = true,
+    withpinyin .initial:n = true,
+
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.1.0}{2021/09/21}{添加隐藏汉字键。}
+%
+% \begin{macro}{withhanzi}
+% 是否显示汉语拼音,默认为true。
+%    \begin{macrocode}
+    withhanzi .bool_set:N = \l_@@_hanzi_bool,
+    withhanzi .default:n = true,
+    withhanzi .initial:n = true,
+
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.1.0}{2021/09/21}{添加隐藏译文键。}
+%
+% \begin{macro}{withtran}
+% 是否显示汉语拼音,默认为true。
+%    \begin{macrocode}
+    withtran .bool_set:N = \l_@@_tran_bool,
+    withtran .default:n = true,
+    withtran .initial:n = true,
+
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % 处理未知选项。
 %    \begin{macrocode}
     unknown .code:n = { \@@_error:n { unknown-option } }
@@ -585,13 +768,13 @@
     \tl_set:Nx \l_@@_character_tl {#1}
     \tl_set:Nx \l_@@_pinyin_tl {#2}
     \tl_set:Nx \l_@@_translation_tl {#3}
-    \scalebox{\fp_use:N \l_@@_ratio_fp}{
+    \scalebox{\fp_use:N \l_@@_scale_fp}{
       \tikz[scale=0.5, every~node/.style={inner~sep=0,outer~sep=0}]{%
-        {\node[] at (1,1){\huge{\tl_use:N \l_@@_character_tl}}};
-        {\node[label={\strut\small\textbf{\tl_use:N \l_@@_pinyin_tl}},
+        {\node[] at (1,1){\huge{\l_@@_character_tl}}};
+        {\node[label={\strut\small\textbf{\l_@@_pinyin_tl}},
           text~height=1cm] (charr) at (1,1){};}%
         {\node[align=center] at (1,-0.5)
-          {\strut\small\textit{\tl_use:N \l_@@_translation_tl}};}%
+          {\strut\small\textit{\l_@@_translation_tl}};}%
       }%
     }%
   }
@@ -610,6 +793,11 @@
 % \end{macro}
 % \end{macro}
 %
+% \changes{v1.1.0}{2021/09/21}{添加整体缩放代码。}
+% \changes{v1.1.0}{2021/09/21}{添加按需要隐藏拼音、汉字或译文代码。}
+% \changes{v1.1.0}{2021/09/21}{将隐藏功能修正为用前景/背景色实现。}
+% \changes{v1.1.0}{2021/09/22}{将各部分绘制分解为函数实现。}
+%
 % \begin{macro}{\@@_draw:nnnn}
 % 自动汉字盒子排版内部命令,根据选项用TikZ实现绘制。
 %    \begin{macrocode}
@@ -647,75 +835,74 @@
         \tl_count:V \l_@@_translation_tl
       }
 
-    \scalebox{\fp_use:N \l_@@_ratio_fp}{
+    \scalebox{\fp_use:N \l_@@_scale_fp}{
     \tikz[scale=0.5, every~node/.style={inner~sep=0,outer~sep=0}]{%
-      \int_compare:nNnT { \l_@@_character_int } < {2}
+%    \end{macrocode}
+%
+% 根据汉字长度绘制汉字盒子背景,必须提前绘制
+%
+%    \begin{macrocode}
+      \@@_border_draw:n {0.0cm}
+%    \end{macrocode}
+%
+% 如果显示汉字,则内部格线应该提前绘制
+%
+%    \begin{macrocode}
+      \bool_if:NT \l_@@_hanzi_bool
         {
-          \int_case:nn {\l_@@_inner_int}
-            {
-              {1}{
-              }
-              {2}{
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l_@@_bordercolor_tl!50](0,0)--(2,2);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l_@@_bordercolor_tl!50](0,2)--(2,0);%
-
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l_@@_bordercolor_tl!50](0,1)--(2,1);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l_@@_bordercolor_tl!50](1,0)--(1,2);%
-              }
-              {3}{
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l_@@_bordercolor_tl!50](0,1)--(2,1);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l_@@_bordercolor_tl!50](1,0)--(1,2);%
-              }
-            }
+          \@@_frame_background:n {0.0cm}
         }
       \int_compare:nNnTF { \l_@@_character_int } = {0}
         {
-          \draw[line~width=\dim_use:N \l_@@_borderwidth_dim,
-                \tl_use:N \l_@@_bordercolor_tl] (0,0) rectangle(2,2);
-          \node[] at (1,1){\huge{\tl_use:N \l_@@_character_tl}};
-          \int_compare:nNnTF { \l_@@_pinyin_int } = {0}
-            { }
+          \bool_if:NTF \l_@@_hanzi_bool
             {
-              \node[label={\strut\small\@@_pinyinaux:x {\l_@@_pinyin_tl}},
-                text~height=1cm] (charr) at (1,1){};
+              \node[\l_@@_fgcolor_tl] at (1,1){\huge{\l_@@_character_tl}};
+            }{
+              \node[\l_@@_bgcolor_tl] at (1,1){\huge{\l_@@_character_tl}};
             }
-          \int_compare:nNnTF { \l_@@_translation_int } = {0}
-            { }
+          \bool_if:NTF \l_@@_pinyin_bool
             {
-              \node[align=center] at (1,-0.5)
-                {\strut\small\textit{\tl_use:N \l_@@_translation_tl}};
+              \node[label={[font=\small,text=\l_@@_fgcolor_tl]
+                           \strut\@@_pinyinaux:x {\l_@@_pinyin_tl}},
+                text~height=1cm] (charr) at (1,1){};
+            }{
+              \node[label={[font=\small,text=\l_@@_bgcolor_tl]
+                           \strut\@@_pinyinaux:x {\l_@@_pinyin_tl}},
+                text~height=1cm] (charr) at (1,1){};
             }
+          \@@_tran_draw:nn {1}{-0.5}
         }
         {
-          \bool_if:NTF \l_@@_border_bool
+          \bool_if:NTF \l_@@_hanzi_bool
             {
-              \draw[line~width=\dim_use:N \l_@@_borderwidth_dim,
-                \tl_use:N \l_@@_bordercolor_tl] (0,0) rectangle(2*\l_@@_character_int,2);
-            }{}
+              \node[\l_@@_fgcolor_tl] at (1*\l_@@_character_int,1)
+                {\huge\tl_use:N \l_@@_character_tl};
+            }{
+              \node[\l_@@_bgcolor_tl] at (1*\l_@@_character_int,1)
+                {\huge\tl_use:N \l_@@_character_tl};
+            }
 
-          \node[] at (1*\l_@@_character_int,1)
-            {\huge\tl_use:N \l_@@_character_tl};
-
-          \int_compare:nNnTF { \l_@@_pinyin_int } = {0}
-            { }
+          \bool_if:NTF \l_@@_pinyin_bool
             {
-              \node[label={\strut\small\@@_pinyinaux:x {\l_@@_pinyin_tl}},
+              \node[label={[font=\small,text=\l_@@_fgcolor_tl]
+                           \strut\@@_pinyinaux:x {\l_@@_pinyin_tl}},
                 text~height=1cm] (charr) at (1*\l_@@_character_int,1){};
+            }{
+              \node[label={[font=\small,text=\l_@@_bgcolor_tl]
+                           \strut\@@_pinyinaux:x {\l_@@_pinyin_tl}},
+                text~height=1cm] (charr) at (1*\l_@@_character_int,1){};
             }
-
-          \int_compare:nNnTF { \l_@@_translation_int } = {0}
-            { }
-            {
-              \node[align=center] at (1*\l_@@_character_int,-0.5)
-                {\strut\small\textit{\tl_use:N \l_@@_translation_tl}};
-            }
+          \@@_tran_draw:nn {\l_@@_character_int}{-0.5}
         }
+%    \end{macrocode}
+%
+% 如果不显示汉字,则内部格线应该最后绘制
+%
+%    \begin{macrocode}
+      \bool_if:NF \l_@@_hanzi_bool
+        {
+          \@@_frame_background:n {0.0cm}
+        }
     }%
     }%
   }
@@ -722,10 +909,15 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_star_draw:nnnn}
+% \changes{v1.1.0}{2021/09/21}{添加\tn{hanzibox*}星号命令的内部实现代码。}
+% \changes{v1.1.0}{2021/09/21}{添加按需要隐藏拼音、汉字或译文代码。}
+% \changes{v1.1.0}{2021/09/21}{将隐藏功能修正为用前景/背景色实现。}
+% \changes{v1.1.0}{2021/09/22}{将各部分绘制分解为函数实现。}
+%
+% \begin{macro}{\@@_asterisk_draw:nnnn}
 % 自动汉字拼音盒子排版内部命令,根据选项用TikZ实现绘制。
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_star_draw:nnnn #1#2#3#4
+\cs_new_protected:Npn \@@_asterisk_draw:nnnn #1#2#3#4
   {
 %    \end{macrocode}
 %
@@ -759,62 +951,87 @@
         \tl_count:V \l_@@_translation_tl
       }
 
-    \scalebox{\fp_use:N \l_@@_ratio_fp}{
+    \scalebox{\fp_use:N \l_@@_scale_fp}{
     \tikz[scale=0.5, every~node/.style={inner~sep=0,outer~sep=0}]{%
-      \int_compare:nNnT { \l_@@_character_int } < {2}
+%    \end{macrocode}
+%
+% 根据汉字长度绘制汉字盒子背景,必须提前绘制
+%
+%    \begin{macrocode}
+      \@@_border_draw:n {-0.5cm}
+%    \end{macrocode}
+%
+% 如果显示汉字,则内部格线应该提前绘制
+%
+%    \begin{macrocode}
+      \bool_if:NT \l_@@_hanzi_bool
         {
-          \int_case:nn {\l_@@_inner_int}
-            {
-              {1}{
-              }
-              {2}{
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l_@@_bordercolor_tl!50](0,0)--(2,2);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l_@@_bordercolor_tl!50](0,2)--(2,0);%
-
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l_@@_bordercolor_tl!50](0,1)--(2,1);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l_@@_bordercolor_tl!50](1,0)--(1,2);%
-              }
-              {3}{
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l_@@_bordercolor_tl!50](0,1)--(2,1);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l_@@_bordercolor_tl!50](1,0)--(1,2);%
-              }
-            }
+          \@@_frame_background:n {-0.5cm}
         }
       \int_compare:nNnTF { \l_@@_character_int } = {0}
         {
-          \draw[line~width=\dim_use:N \l_@@_borderwidth_dim, yshift=-0.5cm,
-                \tl_use:N \l_@@_bordercolor_tl] (0,0) rectangle(2,2);
-          \node[] at (1,1){\huge{\xpinyin*[vsep=0.85 cm]{\tl_use:N \l_@@_character_tl}}};
-          \int_compare:nNnTF { \l_@@_translation_int } = {0}
-            { }
+          \bool_if:NTF \l_@@_pinyin_bool
             {
-              \node[align=center] at (1,-1.0)
-                {\strut\small\textit{\tl_use:N \l_@@_translation_tl}};
+              \bool_if:NTF \l_@@_hanzi_bool
+                {
+                  \node[\l_@@_fgcolor_tl] at (1,1)
+                    {\huge{\xpinyin*[format={\small\color{\l_@@_fgcolor_tl}},
+                     vsep=0.90 cm]{\l_@@_character_tl}}};
+                }{
+                  \node[\l_@@_bgcolor_tl] at (1,1)
+                    {\huge{\xpinyin*[format={\small\color{\l_@@_fgcolor_tl}},
+                     vsep=0.90 cm]{\l_@@_character_tl}}};
+                }
+            }{
+              \bool_if:NTF \l_@@_hanzi_bool
+                {
+                  \node[\l_@@_fgcolor_tl] at (1,1)
+                    {\huge{\xpinyin*[format={\small\color{\l_@@_bgcolor_tl}},
+                     vsep=0.90 cm]{\l_@@_character_tl}}};
+                }{
+                  \node[\l_@@_fgcolor_tl] at (1,1)
+                    {\huge{\xpinyin*[format={\small\color{\l_@@_bgcolor_tl}},
+                     vsep=0.90 cm]{\l_@@_character_tl}}};
+                }
             }
+          \@@_tran_draw:nn {1}{-1.0}
         }
         {
-          \bool_if:NTF \l_@@_border_bool
+          \bool_if:NTF \l_@@_pinyin_bool
             {
-              \draw[line~width=\dim_use:N \l_@@_borderwidth_dim, yshift=-0.5cm,
-                \tl_use:N \l_@@_bordercolor_tl] (0,0) rectangle(2*\l_@@_character_int,2);
-            }{}
-
-          \node[] at (1*\l_@@_character_int,1)
-            {\huge{\xpinyin*[vsep=0.90 cm]{\tl_use:N \l_@@_character_tl}}};
-
-          \int_compare:nNnTF { \l_@@_translation_int } = {0}
-            { }
-            {
-              \node[align=center] at (1*\l_@@_character_int,-1.0)
-                {\strut\small\textit{\tl_use:N \l_@@_translation_tl}};
+              \bool_if:NTF \l_@@_hanzi_bool
+                {
+                  \node[\l_@@_fgcolor_tl] at (1*\l_@@_character_int,1)
+                    {\huge{\xpinyin*[format={\small\color{\l_@@_fgcolor_tl}},
+                     vsep=0.90 cm]{\l_@@_character_tl}}};
+                }{
+                  \node[\l_@@_bgcolor_tl] at (1*\l_@@_character_int,1)
+                    {\huge{\xpinyin*[format={\small\color{\l_@@_fgcolor_tl}},
+                     vsep=0.90 cm]{\l_@@_character_tl}}};
+                }
+            }{
+              \bool_if:NTF \l_@@_hanzi_bool
+                {
+                  \node[\l_@@_fgcolor_tl] at (1*\l_@@_character_int,1)
+                    {\huge{\xpinyin*[format={\small\color{\l_@@_bgcolor_tl}},
+                     vsep=0.90 cm]{\l_@@_character_tl}}};
+                }{
+                  \node[\l_@@_fgcolor_tl] at (1*\l_@@_character_int,1)
+                    {\huge{\xpinyin*[format={\small\color{\l_@@_bgcolor_tl}},
+                     vsep=0.90 cm]{\l_@@_character_tl}}};
+                }
             }
+            \@@_tran_draw:nn {\l_@@_character_int}{-1.0}
         }
+%    \end{macrocode}
+%
+% 如果不显示汉字,则内部格线应该最后绘制
+%
+%    \begin{macrocode}
+      \bool_if:NF \l_@@_hanzi_bool
+        {
+          \@@_frame_background:n {-0.5cm}
+        }
     }%
     }%
   }
@@ -821,7 +1038,110 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \changes{v1.1.0}{2021/09/22}{添加方格背景绘制内部函数。}
+%
+% \begin{macro}{\@@_frame_background:n}
+% TikZ米字格绘制代码。
 %    \begin{macrocode}
+\cs_new_protected:Npn \@@_frame_background:n #1
+  {
+    \int_compare:nNnT { \l_@@_character_int } < {2}
+      {
+        \int_case:nn {\l_@@_inner_int}
+          {
+            {1}{
+            }
+            {2}{
+              \@@_star_background:n {#1}
+            }
+            {3}{
+              \@@_cross_background:n {#1}
+            }
+          }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.1.0}{2021/09/22}{添加米字格内部函数。}
+%
+% \begin{macro}{\@@_star_background:n}
+% TikZ米字格绘制代码。
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_star_background:n #1
+  {
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l_@@_bordercolor_tl!50](0,0)--(2,2);%
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l_@@_bordercolor_tl!50](0,2)--(2,0);%
+
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l_@@_bordercolor_tl!50](0,1)--(2,1);%
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l_@@_bordercolor_tl!50](1,0)--(1,2);%
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.1.0}{2021/09/22}{添加田字格背景内部函数。}
+%
+% \begin{macro}{\@@_cross_background:n}
+% TikZ田字格绘制代码。
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_cross_background:n #1
+  {
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l_@@_bordercolor_tl!50](0,1)--(2,1);%
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l_@@_bordercolor_tl!50](1,0)--(1,2);%
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.1.0}{2021/09/22}{添加背景方格内部函数。}
+%
+% \begin{macro}{\@@_border_draw:n}
+% 绘制边框代码。
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_border_draw:n #1
+  {
+      \int_compare:nNnTF { \l_@@_character_int } = {0}
+        {
+          \draw[fill=\l_@@_bgcolor_tl,line~width=\l_@@_borderwidth_dim,
+            yshift=#1, draw=\l_@@_bordercolor_tl] (0,0) rectangle(2,2);
+        }
+        {
+          \bool_if:NTF \l_@@_border_bool
+            {
+              \draw[fill=\l_@@_bgcolor_tl,line~width=\l_@@_borderwidth_dim,
+                    yshift=#1, draw=\l_@@_bordercolor_tl] (0,0)
+                rectangle(2*\l_@@_character_int,2);
+            }{}
+        }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v1.1.0}{2021/09/22}{添加译文文本绘制内部函数。}
+%
+% \begin{macro}{\@@_tran_draw:nn}
+% 绘制译文文本。
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_tran_draw:nn #1#2
+  {
+    \bool_if:NTF \l_@@_tran_bool
+      {
+        \node[align=center,\l_@@_fgcolor_tl] at (1*#1,#2)
+          {\strut\small\textit{\l_@@_translation_tl}};
+      }{
+        \node[align=center,\l_@@_bgcolor_tl] at (1*#1,#2)
+          {\strut\small\textit{\l_@@_translation_tl}};
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+%    \begin{macrocode}
 %</package>
 %    \end{macrocode}
 %

Modified: trunk/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty
===================================================================
--- trunk/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty	2021-09-23 20:14:53 UTC (rev 60593)
+++ trunk/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty	2021-09-23 20:15:15 UTC (rev 60594)
@@ -21,13 +21,13 @@
 %% 
 %%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainer of this work is Nan Geng Nan Geng.
+%%     The Current Maintainer of this work is Nan Geng.
 %% 
 %% --------------------------------------------------------------------------
 %% 
 \NeedsTeXFormat{LaTeX2e}[2020/10/01]
 \RequirePackage{expl3}
-\GetIdInfo$Id: hanzibox.dtx 1.0.0 2021-09-18 20:00:00Z +0800 Nan Geng <nangeng at nwafu.edu.cn> $
+\GetIdInfo$Id: hanzibox.dtx 1.1.0 2021-09-23 08:00:00 +0800 Nan Geng <nangeng at nwafu.edu.cn> $
   {Boxed Chinese characters with Pinyin above and translation below.}
 \ProvidesExplPackage{\ExplFileName}
   {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -36,15 +36,12 @@
 
 \sys_if_engine_xetex:F
   {
-    \sys_if_engine_luatex:F
-      {
-        \msg_fatal:nnx { hanzibox } { unsupported-engine }
-          { \c_sys_engine_str }
-      }
+    \msg_fatal:nnx { hanzibox } { unsupported-engine }
+      { \c_sys_engine_str }
   }
 \msg_new:nnn { hanzibox } { unsupported-engine }
   {
-    The~ hanzibox~ packages~ requires~ either~ XeTeX~ or~ LuaTeX. \\\\
+    The~ hanzibox~ packages~ requires~ either~ XeTeX. \\\\
     "#1"~ is~ not~ supported~ at~ present.~ You~ must~ change \\
     your~ typesetting~ engine~ to~ "xelatex"~ or~ "lualatex".
   }
@@ -85,7 +82,9 @@
 
 \NewDocumentCommand{\hanzidialog}{ m O{} O{} }
   {
-    \__hanzibox_dialog:nnnn { #1 } { #2 } { #3 }
+    \group_begin:
+      \__hanzibox_dialog:nnnn { #1 } { #2 } { #3 }
+    \group_end:
   }
 
 \NewDocumentCommand{\hanzibox}{ s O{} m O{} O{} }
@@ -92,17 +91,26 @@
   {
     \IfBooleanTF{#1}
       {
-        \__hanzibox_star_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+        \group_begin:
+          \__hanzibox_asterisk_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+        \group_end:
       }{
-        \__hanzibox_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+        \group_begin:
+          \__hanzibox_draw:nnnn { #2 } { #3 } { #4 } { #5 }
+        \group_end:
       }
   }
 
-\fp_new:N \l__hanzibox_ratio_fp
+\fp_new:N \l__hanzibox_scale_fp
 \int_new:N \l__hanzibox_inner_int
 \bool_new:N \l__hanzibox_border_bool
 \dim_new:N \l__hanzibox_borderwidth_dim
 \tl_new:N \l__hanzibox_bordercolor_tl
+\tl_new:N \l__hanzibox_fgcolor_tl
+\tl_new:N \l__hanzibox_bgcolor_tl
+\bool_new:N \l__hanzibox_pinyin_bool
+\bool_new:N \l__hanzibox_hanzi_bool
+\bool_new:N \l__hanzibox_tran_bool
 \tl_new:N \l__hanzibox_pinyin_tl
 \tl_new:N \l__hanzibox_character_tl
 \tl_new:N \l__hanzibox_translation_tl
@@ -112,8 +120,8 @@
 
 \keys_define:nn { hanzibox }
   {
-    ratio .fp_set:N  = \l__hanzibox_ratio_fp,
-    ratio .initial:n = 1.0,
+    scale .fp_set:N  = \l__hanzibox_scale_fp,
+    scale .initial:n = 1.0,
 
     inner .choice:,
     inner .value_required:n = true,
@@ -132,6 +140,24 @@
     bordercolor .tl_set:N  = \l__hanzibox_bordercolor_tl,
     bordercolor .initial:n = black,
 
+    fgcolor .tl_set:N  = \l__hanzibox_fgcolor_tl,
+    fgcolor .initial:n = black,
+
+    bgcolor .tl_set:N  = \l__hanzibox_bgcolor_tl,
+    bgcolor .initial:n = white,
+
+    withpinyin .bool_set:N = \l__hanzibox_pinyin_bool,
+    withpinyin .default:n = true,
+    withpinyin .initial:n = true,
+
+    withhanzi .bool_set:N = \l__hanzibox_hanzi_bool,
+    withhanzi .default:n = true,
+    withhanzi .initial:n = true,
+
+    withtran .bool_set:N = \l__hanzibox_tran_bool,
+    withtran .default:n = true,
+    withtran .initial:n = true,
+
     unknown .code:n = { \__hanzibox_error:n { unknown-option } }
   }
 \msg_new:nnn { hanzibox } { unknown-option }
@@ -144,13 +170,13 @@
     \tl_set:Nx \l__hanzibox_character_tl {#1}
     \tl_set:Nx \l__hanzibox_pinyin_tl {#2}
     \tl_set:Nx \l__hanzibox_translation_tl {#3}
-    \scalebox{\fp_use:N \l__hanzibox_ratio_fp}{
+    \scalebox{\fp_use:N \l__hanzibox_scale_fp}{
       \tikz[scale=0.5, every~node/.style={inner~sep=0,outer~sep=0}]{%
-        {\node[] at (1,1){\huge{\tl_use:N \l__hanzibox_character_tl}}};
-        {\node[label={\strut\small\textbf{\tl_use:N \l__hanzibox_pinyin_tl}},
+        {\node[] at (1,1){\huge{\l__hanzibox_character_tl}}};
+        {\node[label={\strut\small\textbf{\l__hanzibox_pinyin_tl}},
           text~height=1cm] (charr) at (1,1){};}%
         {\node[align=center] at (1,-0.5)
-          {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};}%
+          {\strut\small\textit{\l__hanzibox_translation_tl}};}%
       }%
     }%
   }
@@ -176,79 +202,63 @@
         \tl_count:V \l__hanzibox_translation_tl
       }
 
-    \scalebox{\fp_use:N \l__hanzibox_ratio_fp}{
+    \scalebox{\fp_use:N \l__hanzibox_scale_fp}{
     \tikz[scale=0.5, every~node/.style={inner~sep=0,outer~sep=0}]{%
-      \int_compare:nNnT { \l__hanzibox_character_int } < {2}
+      \__hanzibox_border_draw:n {0.0cm}
+      \bool_if:NT \l__hanzibox_hanzi_bool
         {
-          \int_case:nn {\l__hanzibox_inner_int}
-            {
-              {1}{
-              }
-              {2}{
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](0,0)--(2,2);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](0,2)--(2,0);%
-
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
-              }
-              {3}{
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
-              }
-            }
+          \__hanzibox_frame_background:n {0.0cm}
         }
       \int_compare:nNnTF { \l__hanzibox_character_int } = {0}
         {
-          \draw[line~width=\dim_use:N \l__hanzibox_borderwidth_dim,
-                \tl_use:N \l__hanzibox_bordercolor_tl] (0,0) rectangle(2,2);
-          \node[] at (1,1){\huge{\tl_use:N \l__hanzibox_character_tl}};
-          \int_compare:nNnTF { \l__hanzibox_pinyin_int } = {0}
-            { }
+          \bool_if:NTF \l__hanzibox_hanzi_bool
             {
-              \node[label={\strut\small\__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}},
-                text~height=1cm] (charr) at (1,1){};
+              \node[\l__hanzibox_fgcolor_tl] at (1,1){\huge{\l__hanzibox_character_tl}};
+            }{
+              \node[\l__hanzibox_bgcolor_tl] at (1,1){\huge{\l__hanzibox_character_tl}};
             }
-          \int_compare:nNnTF { \l__hanzibox_translation_int } = {0}
-            { }
+          \bool_if:NTF \l__hanzibox_pinyin_bool
             {
-              \node[align=center] at (1,-0.5)
-                {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};
+              \node[label={[font=\small,text=\l__hanzibox_fgcolor_tl]
+                           \strut\__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}},
+                text~height=1cm] (charr) at (1,1){};
+            }{
+              \node[label={[font=\small,text=\l__hanzibox_bgcolor_tl]
+                           \strut\__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}},
+                text~height=1cm] (charr) at (1,1){};
             }
+          \__hanzibox_tran_draw:nn {1}{-0.5}
         }
         {
-          \bool_if:NTF \l__hanzibox_border_bool
+          \bool_if:NTF \l__hanzibox_hanzi_bool
             {
-              \draw[line~width=\dim_use:N \l__hanzibox_borderwidth_dim,
-                \tl_use:N \l__hanzibox_bordercolor_tl] (0,0) rectangle(2*\l__hanzibox_character_int,2);
-            }{}
+              \node[\l__hanzibox_fgcolor_tl] at (1*\l__hanzibox_character_int,1)
+                {\huge\tl_use:N \l__hanzibox_character_tl};
+            }{
+              \node[\l__hanzibox_bgcolor_tl] at (1*\l__hanzibox_character_int,1)
+                {\huge\tl_use:N \l__hanzibox_character_tl};
+            }
 
-          \node[] at (1*\l__hanzibox_character_int,1)
-            {\huge\tl_use:N \l__hanzibox_character_tl};
-
-          \int_compare:nNnTF { \l__hanzibox_pinyin_int } = {0}
-            { }
+          \bool_if:NTF \l__hanzibox_pinyin_bool
             {
-              \node[label={\strut\small\__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}},
+              \node[label={[font=\small,text=\l__hanzibox_fgcolor_tl]
+                           \strut\__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}},
                 text~height=1cm] (charr) at (1*\l__hanzibox_character_int,1){};
+            }{
+              \node[label={[font=\small,text=\l__hanzibox_bgcolor_tl]
+                           \strut\__hanzibox_pinyinaux:x {\l__hanzibox_pinyin_tl}},
+                text~height=1cm] (charr) at (1*\l__hanzibox_character_int,1){};
             }
-
-          \int_compare:nNnTF { \l__hanzibox_translation_int } = {0}
-            { }
-            {
-              \node[align=center] at (1*\l__hanzibox_character_int,-0.5)
-                {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};
-            }
+          \__hanzibox_tran_draw:nn {\l__hanzibox_character_int}{-0.5}
         }
+      \bool_if:NF \l__hanzibox_hanzi_bool
+        {
+          \__hanzibox_frame_background:n {0.0cm}
+        }
     }%
     }%
   }
-\cs_new_protected:Npn \__hanzibox_star_draw:nnnn #1#2#3#4
+\cs_new_protected:Npn \__hanzibox_asterisk_draw:nnnn #1#2#3#4
   {
     \keys_set:nn { hanzibox } { #1 }
     \tl_set:Nx \l__hanzibox_character_tl {#2}
@@ -267,65 +277,138 @@
         \tl_count:V \l__hanzibox_translation_tl
       }
 
-    \scalebox{\fp_use:N \l__hanzibox_ratio_fp}{
+    \scalebox{\fp_use:N \l__hanzibox_scale_fp}{
     \tikz[scale=0.5, every~node/.style={inner~sep=0,outer~sep=0}]{%
-      \int_compare:nNnT { \l__hanzibox_character_int } < {2}
+      \__hanzibox_border_draw:n {-0.5cm}
+      \bool_if:NT \l__hanzibox_hanzi_bool
         {
-          \int_case:nn {\l__hanzibox_inner_int}
-            {
-              {1}{
-              }
-              {2}{
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](0,0)--(2,2);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](0,2)--(2,0);%
-
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
-              }
-              {3}{
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
-                \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=-0.5cm,
-                      \tl_use:N \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
-              }
-            }
+          \__hanzibox_frame_background:n {-0.5cm}
         }
       \int_compare:nNnTF { \l__hanzibox_character_int } = {0}
         {
-          \draw[line~width=\dim_use:N \l__hanzibox_borderwidth_dim, yshift=-0.5cm,
-                \tl_use:N \l__hanzibox_bordercolor_tl] (0,0) rectangle(2,2);
-          \node[] at (1,1){\huge{\xpinyin*[vsep=0.85 cm]{\tl_use:N \l__hanzibox_character_tl}}};
-          \int_compare:nNnTF { \l__hanzibox_translation_int } = {0}
-            { }
+          \bool_if:NTF \l__hanzibox_pinyin_bool
             {
-              \node[align=center] at (1,-1.0)
-                {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};
+              \bool_if:NTF \l__hanzibox_hanzi_bool
+                {
+                  \node[\l__hanzibox_fgcolor_tl] at (1,1)
+                    {\huge{\xpinyin*[format={\small\color{\l__hanzibox_fgcolor_tl}},
+                     vsep=0.90 cm]{\l__hanzibox_character_tl}}};
+                }{
+                  \node[\l__hanzibox_bgcolor_tl] at (1,1)
+                    {\huge{\xpinyin*[format={\small\color{\l__hanzibox_fgcolor_tl}},
+                     vsep=0.90 cm]{\l__hanzibox_character_tl}}};
+                }
+            }{
+              \bool_if:NTF \l__hanzibox_hanzi_bool
+                {
+                  \node[\l__hanzibox_fgcolor_tl] at (1,1)
+                    {\huge{\xpinyin*[format={\small\color{\l__hanzibox_bgcolor_tl}},
+                     vsep=0.90 cm]{\l__hanzibox_character_tl}}};
+                }{
+                  \node[\l__hanzibox_fgcolor_tl] at (1,1)
+                    {\huge{\xpinyin*[format={\small\color{\l__hanzibox_bgcolor_tl}},
+                     vsep=0.90 cm]{\l__hanzibox_character_tl}}};
+                }
             }
+          \__hanzibox_tran_draw:nn {1}{-1.0}
         }
         {
-          \bool_if:NTF \l__hanzibox_border_bool
+          \bool_if:NTF \l__hanzibox_pinyin_bool
             {
-              \draw[line~width=\dim_use:N \l__hanzibox_borderwidth_dim, yshift=-0.5cm,
-                \tl_use:N \l__hanzibox_bordercolor_tl] (0,0) rectangle(2*\l__hanzibox_character_int,2);
-            }{}
-
-          \node[] at (1*\l__hanzibox_character_int,1)
-            {\huge{\xpinyin*[vsep=0.90 cm]{\tl_use:N \l__hanzibox_character_tl}}};
-
-          \int_compare:nNnTF { \l__hanzibox_translation_int } = {0}
-            { }
-            {
-              \node[align=center] at (1*\l__hanzibox_character_int,-1.0)
-                {\strut\small\textit{\tl_use:N \l__hanzibox_translation_tl}};
+              \bool_if:NTF \l__hanzibox_hanzi_bool
+                {
+                  \node[\l__hanzibox_fgcolor_tl] at (1*\l__hanzibox_character_int,1)
+                    {\huge{\xpinyin*[format={\small\color{\l__hanzibox_fgcolor_tl}},
+                     vsep=0.90 cm]{\l__hanzibox_character_tl}}};
+                }{
+                  \node[\l__hanzibox_bgcolor_tl] at (1*\l__hanzibox_character_int,1)
+                    {\huge{\xpinyin*[format={\small\color{\l__hanzibox_fgcolor_tl}},
+                     vsep=0.90 cm]{\l__hanzibox_character_tl}}};
+                }
+            }{
+              \bool_if:NTF \l__hanzibox_hanzi_bool
+                {
+                  \node[\l__hanzibox_fgcolor_tl] at (1*\l__hanzibox_character_int,1)
+                    {\huge{\xpinyin*[format={\small\color{\l__hanzibox_bgcolor_tl}},
+                     vsep=0.90 cm]{\l__hanzibox_character_tl}}};
+                }{
+                  \node[\l__hanzibox_fgcolor_tl] at (1*\l__hanzibox_character_int,1)
+                    {\huge{\xpinyin*[format={\small\color{\l__hanzibox_bgcolor_tl}},
+                     vsep=0.90 cm]{\l__hanzibox_character_tl}}};
+                }
             }
+            \__hanzibox_tran_draw:nn {\l__hanzibox_character_int}{-1.0}
         }
+      \bool_if:NF \l__hanzibox_hanzi_bool
+        {
+          \__hanzibox_frame_background:n {-0.5cm}
+        }
     }%
     }%
   }
+\cs_new_protected:Npn \__hanzibox_frame_background:n #1
+  {
+    \int_compare:nNnT { \l__hanzibox_character_int } < {2}
+      {
+        \int_case:nn {\l__hanzibox_inner_int}
+          {
+            {1}{
+            }
+            {2}{
+              \__hanzibox_star_background:n {#1}
+            }
+            {3}{
+              \__hanzibox_cross_background:n {#1}
+            }
+          }
+      }
+  }
+\cs_new_protected:Npn \__hanzibox_star_background:n #1
+  {
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l__hanzibox_bordercolor_tl!50](0,0)--(2,2);%
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l__hanzibox_bordercolor_tl!50](0,2)--(2,0);%
+
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
+  }
+\cs_new_protected:Npn \__hanzibox_cross_background:n #1
+  {
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l__hanzibox_bordercolor_tl!50](0,1)--(2,1);%
+    \draw[stretch~dash=on~2pt~off~2pt,thin, yshift=#1,
+          \l__hanzibox_bordercolor_tl!50](1,0)--(1,2);%
+  }
+\cs_new_protected:Npn \__hanzibox_border_draw:n #1
+  {
+      \int_compare:nNnTF { \l__hanzibox_character_int } = {0}
+        {
+          \draw[fill=\l__hanzibox_bgcolor_tl,line~width=\l__hanzibox_borderwidth_dim,
+            yshift=#1, draw=\l__hanzibox_bordercolor_tl] (0,0) rectangle(2,2);
+        }
+        {
+          \bool_if:NTF \l__hanzibox_border_bool
+            {
+              \draw[fill=\l__hanzibox_bgcolor_tl,line~width=\l__hanzibox_borderwidth_dim,
+                    yshift=#1, draw=\l__hanzibox_bordercolor_tl] (0,0)
+                rectangle(2*\l__hanzibox_character_int,2);
+            }{}
+        }
+  }
+\cs_new_protected:Npn \__hanzibox_tran_draw:nn #1#2
+  {
+    \bool_if:NTF \l__hanzibox_tran_bool
+      {
+        \node[align=center,\l__hanzibox_fgcolor_tl] at (1*#1,#2)
+          {\strut\small\textit{\l__hanzibox_translation_tl}};
+      }{
+        \node[align=center,\l__hanzibox_bgcolor_tl] at (1*#1,#2)
+          {\strut\small\textit{\l__hanzibox_translation_tl}};
+      }
+  }
 %% 
 %%     This package consists of the file  hanzibox.dtx,
 %%                  and the derived files hanzibox.sty,



More information about the tex-live-commits mailing list.