diff options
author | Karl Berry <karl@freefriends.org> | 2021-10-07 20:33:53 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-10-07 20:33:53 +0000 |
commit | 4d48af346935c8e1a7c68e737d9e8b064a2685d9 (patch) | |
tree | 85f2855fbfed1dfc5298d8d2ed76c3a09eca7833 /Master/texmf-dist/tex/xelatex/hanzibox | |
parent | e33d70fb04b016cc65621ba1907ecb4ddc8e650e (diff) |
hanzibox (7oct21)
git-svn-id: svn://tug.org/texlive/trunk@60710 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/hanzibox')
-rw-r--r-- | Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty | 77 |
1 files changed, 54 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty index e86b73715aa..3d9641749d9 100644 --- a/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty +++ b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty @@ -27,13 +27,18 @@ %% \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{expl3} -\GetIdInfo$Id: hanzibox.dtx 2.1.0 2021-09-30 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $ +\GetIdInfo$Id: hanzibox.dtx 2.1.1 2021-10-07 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $ {Boxed Chinese characters with Pinyin above and translation below.} \ProvidesExplPackage{\ExplFileName} {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage { xtemplate, l3keys2e, l3draw, xparse } +\cs_if_free:NT \box_ht_plus_dp:N + { + \cs_new_protected:Npn \box_ht_plus_dp:N #1 + { \tex_dimexpr:D \box_ht:N #1 + \box_dp:N #1 \scan_stop: } + } \sys_if_engine_xetex:F { \msg_fatal:nnx { hanzibox } { unsupported-engine } @@ -107,6 +112,7 @@ \tl_new:N \l__hanzibox_pinyin_format_tl \tl_new:N \l__hanzibox_character_format_tl \tl_new:N \l__hanzibox_translation_format_tl +\int_new:N \l__hanzibox_cross_color_ratio_int \int_new:N \l__hanzibox_pinyin_int \int_new:N \l__hanzibox_character_int \int_new:N \l__hanzibox_translation_int @@ -194,14 +200,13 @@ \draw_path_use_clear:n { stroke , fill } } } - \__hanzibox_new_frame_construct:nn { 十 } { \tl_if_empty:NF \l__hanzibox_dash_pattern_tl { \exp_args:No \draw_dash_pattern:nn { \l__hanzibox_dash_pattern_tl } { 0pt } } - \color_stroke:n { hanziboxframecolor!30 } + \color_stroke:n { hanziboxcrosscolor } \draw_path_moveto:n { (#3)/2, #2 } \draw_path_lineto:n { #3/2, #4 } \draw_path_moveto:n { #1, (#4)/2 } @@ -215,7 +220,7 @@ { \exp_args:No \draw_dash_pattern:nn { \l__hanzibox_dash_pattern_tl } { 0pt } } - \color_stroke:n { hanziboxframecolor!30 } + \color_stroke:n { hanziboxcrosscolor } \draw_path_moveto:n { #1, #2 } \draw_path_lineto:n { #3, #4 } \draw_path_moveto:n { #1, #4 } @@ -371,10 +376,12 @@ { \color_set:nn {#1} {#2} } +\cs_generate_variant:Nn \__hanzibox_color_select:nn {nx} \cs_set_nopar:Npn \__hanzibox_color_select:nnn #1#2#3 { \color_set:nnn {#1} {#2} {#3} } +\cs_generate_variant:Nn \__hanzibox_color_select:nnn {nnx} \cs_new:Npn \__hanzibox_debug:n { \bool_if:NTF \l__hanzibox_debug_bool @@ -415,9 +422,15 @@ height .dim_set:N = \l__hanzibox_box_height_dim , linewidth .dim_set:N = \l__hanzibox_linewidth_dim , linewidth .initial:n = 0.4pt , - framecolor .code:n = { \__hanzibox_color_select:nn { hanziboxframecolor } {#1} } , + crosscolorratio .int_set:N = \l__hanzibox_cross_color_ratio_int, + crosscolorratio .initial:n = 20, + framecolor .code:n = { \tl_set:Nx \l_tmpa_tl { #1 ! \int_use:N \l__hanzibox_cross_color_ratio_int } + \__hanzibox_color_select:nn { hanziboxframecolor } {#1} + \__hanzibox_color_select:nx{ hanziboxcrosscolor } { \l_tmpa_tl } } , framecolor .initial:n = black , - framecolor* .code:n = { \__hanzibox_color_select:nnn { hanziboxframecolor } #1 } , + framecolor* .code:n = { \tl_set:Nx \l_tmpa_tl { #1 ! \int_use:N \l__hanzibox_cross_color_ratio_int } + \__hanzibox_color_select:nnn { hanziboxframecolor } #1 + \__hanzibox_color_select:nnx { hanziboxcrosscolor } \l_tmpa_tl } , charcolor .code:n = { \__hanzibox_color_select:nn { hanziboxcharcolor } {#1} } , charcolor .initial:n = black , charcolor* .code:n = { \__hanzibox_color_select:nnn { hanziboxframecolor } {#1} } , @@ -483,6 +496,8 @@ tranf = \tiny , frametype = none , resize = none , + crosscolorratio = 20, + framecolor = black, } \NewDocumentCommand \hanziboxset { m } @@ -724,34 +739,50 @@ } \cs_new:Npn \__hanzibox_null_str_coffin_construct: { - \hcoffin_set:Nn \l__hanzibox_str_box_coffin + \bool_if:NTF \l__hanzibox_autopinyin_bool { - \bool_set_false:N \l__hanzibox_withhanzi_bool - - \hcoffin_set:Nn \l_tmpa_coffin + \hcoffin_set:Nn \l__hanzibox_str_box_coffin { + \bool_set_false:N \l__hanzibox_withhanzi_bool \__hanzibox_single_handle:N \c__hanzibox_basechar_tl + \allowbreak } - - \bool_if:NT \l__hanzibox_withpinyin_bool + } + { + \hcoffin_set:Nn \l__hanzibox_str_box_coffin { - \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin + \bool_if:NTF \l__hanzibox_withpinyin_bool { - \color_select:n { hanziboxcharcolor } - \tl_use:N \l__hanzibox_pinyin_format_tl \__hanzibox_get_tone_pinyin:V \l__hanzibox_pinyin_tl \clist_clear:N \l__hanzibox_tone_pinyin_clist \clist_set:NV \l__hanzibox_tone_pinyin_clist \l__hanzibox_tone_pinyin_tl - \clist_use:Nn \l__hanzibox_tone_pinyin_clist {} - % \__hanzibox_get_tone_pinyin:V \l__hanzibox_pinyin_tl - % \l__hanzibox_tone_pinyin_tl + \int_set:Nn \l_tmpa_int {\clist_count:N \l__hanzibox_tone_pinyin_clist} + + \int_step_inline:nn { \l_tmpa_int } + { + \bool_set_false:N \l__hanzibox_withhanzi_bool + + \hcoffin_set:Nn \l_tmpa_coffin + { + \__hanzibox_single_handle:N \c__hanzibox_basechar_tl + } + + \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl + \__hanzibox_single_pinyin:V \l_tmpb_tl + + \coffin_join:NnnNnnnn \l_tmpa_coffin + { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt } + \coffin_typeset:Nnnnn \l_tmpa_coffin + { l } { b } { 0pt } { 0pt } + \allowbreak + } + } + { + \bool_set_false:N \l__hanzibox_withhanzi_bool + \__hanzibox_single_handle:N \c__hanzibox_basechar_tl + \allowbreak } - \coffin_join:NnnNnnnn \l_tmpa_coffin - { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt } } - \coffin_typeset:Nnnnn \l_tmpa_coffin - { l } { b } { 0pt } { 0pt } - \allowbreak } } \cs_new:Npn \__hanzibox_handle:nnnn #1#2#3#4 |