summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-10-11 20:25:38 +0000
committerKarl Berry <karl@freefriends.org>2021-10-11 20:25:38 +0000
commit5743624ea509ba5a2e1a933dc8e0327cc268ed8c (patch)
treed312c3f25c31e220c2c92d6b952b1a86873621ca /Master/texmf-dist/tex/xelatex
parent2077deb33c2d217375849387f233e7a7421e3fbd (diff)
hanzibox (11oct21)
git-svn-id: svn://tug.org/texlive/trunk@60737 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex')
-rw-r--r--Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty633
1 files changed, 378 insertions, 255 deletions
diff --git a/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty
index 3d9641749d9..2cc012a0b5c 100644
--- a/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty
+++ b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty
@@ -27,7 +27,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{expl3}
-\GetIdInfo$Id: hanzibox.dtx 2.1.1 2021-10-07 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $
+\GetIdInfo$Id: hanzibox.dtx 2.2.0 2021-10-11 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $
{Boxed Chinese characters with Pinyin above and translation below.}
\ProvidesExplPackage{\ExplFileName}
{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -79,6 +79,7 @@
\bool_new:N \l__hanzibox_withvowel_bool
\bool_new:N \l__hanzibox_withtone_bool
\bool_new:N \l__hanzibox_withpinyin_bool
+\bool_new:N \l__hanzibox_withpinyinlines_bool
\bool_new:N \l__hanzibox_withhanzi_bool
\bool_new:N \l__hanzibox_withtran_bool
@@ -90,9 +91,14 @@
\dim_new:N \l__hanzibox_frame_size_dim
\dim_new:N \l__hanzibox_char_width_dim
\dim_new:N \l__hanzibox_char_height_dim
+\dim_new:N \l__hanzibox_pinyin_height_i_dim
+\dim_new:N \l__hanzibox_pinyin_height_ii_dim
+\dim_new:N \l__hanzibox_pinyin_height_iii_dim
\dim_new:N \l__hanzibox_box_width_dim
\dim_new:N \l__hanzibox_box_height_dim
-\dim_new:N \l__hanzibox_linewidth_dim
+\dim_new:N \l__hanzibox_frame_linewidth_dim
+\dim_new:N \l__hanzibox_pinyin_linewidth_dim
+\dim_new:N \l__hanzibox_cross_linewidth_dim
\clist_new:N \l__hanzibox_tone_pinyin_clist
@@ -100,6 +106,7 @@
\coffin_new:N \l__hanzibox_box_coffin
\coffin_new:N \l__hanzibox_pinyin_box_coffin
\coffin_new:N \l__hanzibox_tran_box_coffin
+\coffin_new:N \l__hanzibox_pinyin_hanzi_coffin
\coffin_new:N \l__hanzibox_tmpa_coffin
\coffin_new:N \l__hanzibox_tmpb_coffin
@@ -116,6 +123,7 @@
\int_new:N \l__hanzibox_pinyin_int
\int_new:N \l__hanzibox_character_int
\int_new:N \l__hanzibox_translation_int
+\int_new:N \l__hanzibox_charstroke_type_int
\int_new:N \l__hanzibox_tone_int
\str_new:N \l__hanzibox_pinyin_str
@@ -124,6 +132,26 @@
\cs_new_nopar:Nn \__hanzibox_aux_color_fill:
{ }
+\cs_new:Npn \__hanzibox_calc_pinyin_h:
+ {
+ \hbox_set:Nn \l_tmpa_box
+ {
+ \tl_use:N \l__hanzibox_pinyin_format_tl
+ a
+ }
+ \dim_set:Nn \l__hanzibox_pinyin_height_i_dim
+ {
+ \box_ht:N \l_tmpa_box
+ }
+ \dim_set:Nn \l__hanzibox_pinyin_height_ii_dim
+ {
+ \l__hanzibox_pinyin_height_i_dim + \l__hanzibox_pinyin_height_i_dim
+ }
+ \dim_set:Nn \l__hanzibox_pinyin_height_iii_dim
+ {
+ \l__hanzibox_pinyin_height_i_dim + \l__hanzibox_pinyin_height_i_dim + \l__hanzibox_pinyin_height_i_dim
+ }
+ }
\cs_new:Npn \__hanzibox_calc_basechar_w_h:
{
\dim_set:Nn \l__hanzibox_char_width_dim
@@ -164,7 +192,7 @@
\dim_gset_eq:NN \l__hanzibox_frame_size_dim \l_tmpb_dim
}
- \dim_gadd:Nn \l__hanzibox_frame_size_dim { 2pt }
+ \dim_gadd:Nn \l__hanzibox_frame_size_dim { 1pt }
\dim_gset_eq:NN \hanziboxwidth \l__hanzibox_frame_size_dim
\dim_gset_eq:NN \hanziboxheight \l__hanzibox_frame_size_dim
@@ -187,65 +215,116 @@
\cs_new:cn { \__hanzibox_frame_type:n {#1} }
}
\__hanzibox_new_frame_construct:nn { none } { }
-\__hanzibox_new_frame_construct:nn { 口 }
+\__hanzibox_new_frame_construct:nn { pinyinlines }
{
- \color_stroke:n { hanziboxframecolor }
- \draw_path_rectangle_corners:nn { #1, #2} { #3, #4}
-
- \cs_if_eq:NNTF \__hanzibox_aux_color_fill: \c_empty_tl
+ \bool_if:NTF \l__hanzibox_withpinyinlines_bool
{
- \draw_path_use_clear:n { stroke }
+ \draw_scope_begin:
+ \draw_path_moveto:n { #1, 0 }
+ \draw_path_lineto:n { #3, 0 }
+ \draw_path_moveto:n { #1, \l__hanzibox_pinyin_height_i_dim }
+ \draw_path_lineto:n { #3, \l__hanzibox_pinyin_height_i_dim }
+ \draw_path_moveto:n { #1, \l__hanzibox_pinyin_height_ii_dim }
+ \draw_path_lineto:n { #3, \l__hanzibox_pinyin_height_ii_dim }
+ \draw_path_moveto:n { #1, \l__hanzibox_pinyin_height_iii_dim }
+ \draw_path_lineto:n { #3, \l__hanzibox_pinyin_height_iii_dim }
+ \draw_path_use_clear:n { stroke }
+ \draw_scope_end:
}
{
- \draw_path_use_clear:n { stroke , fill }
+ \draw_scope_begin:
+ \hcoffin_set:Nn \l_tmpa_coffin
+ {
+ \tl_use:N \l__hanzibox_pinyin_format_tl
+ \phantom{a}
+ }
+
+ \coffin_resize:Nnn \l_tmpa_coffin
+ { #3 } { \l__hanzibox_pinyin_height_iii_dim }
+
+ \draw_coffin_use:Nnn \l_tmpa_coffin { l } { b }
+ \draw_scope_end:
}
}
-\__hanzibox_new_frame_construct:nn { 十 }
+\__hanzibox_new_frame_construct:nn { filledbox }
{
- \tl_if_empty:NF \l__hanzibox_dash_pattern_tl
+ \cs_if_eq:NNF \__hanzibox_aux_color_fill: \c_empty_tl
{
- \exp_args:No \draw_dash_pattern:nn { \l__hanzibox_dash_pattern_tl } { 0pt }
+ \color_stroke:n { hanziboxframecolor }
+ \draw_path_rectangle_corners:nn { #1, #2} { #3, #4}
+
+ \draw_path_use_clear:n { stroke, fill }
}
- \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 }
- \draw_path_lineto:n { #3, (#4)/2 }
- \draw_path_use_clear:n { stroke }
+ }
+\__hanzibox_new_frame_construct:nn { framebox }
+ {
+ \draw_scope_begin:
+ \color_stroke:n { hanziboxframecolor }
+ \draw_path_rectangle_corners:nn { #1, #2} { #3, #4}
+ \draw_path_use_clear:n { stroke }
+ \draw_scope_end:
+ }
+\__hanzibox_new_frame_construct:nn { 十 }
+ {
+ \draw_scope_begin:
+ \tl_if_empty:NF \l__hanzibox_dash_pattern_tl
+ {
+ \exp_args:No \draw_dash_pattern:nn { \l__hanzibox_dash_pattern_tl } { 0pt }
+ }
+ \draw_linewidth:n{ \l__hanzibox_cross_linewidth_dim }
+ \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 }
+ \draw_path_lineto:n { #3, (#4)/2 }
+ \draw_path_use_clear:n { stroke }
+ \draw_scope_end:
}
\__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 { hanziboxcrosscolor }
- \draw_path_moveto:n { #1, #2 }
- \draw_path_lineto:n { #3, #4 }
- \draw_path_moveto:n { #1, #4 }
- \draw_path_lineto:n { #3, #2 }
- \draw_path_use_clear:n { stroke }
+ \draw_scope_begin:
+ \tl_if_empty:NF \l__hanzibox_dash_pattern_tl
+ {
+ \exp_args:No \draw_dash_pattern:nn { \l__hanzibox_dash_pattern_tl } { 0pt }
+ }
+ \draw_linewidth:n{ \l__hanzibox_cross_linewidth_dim }
+ \color_stroke:n { hanziboxcrosscolor }
+ \draw_path_moveto:n { #1, #2 }
+ \draw_path_lineto:n { #3, #4 }
+ \draw_path_moveto:n { #1, #4 }
+ \draw_path_lineto:n { #3, #2 }
+ \draw_path_use_clear:n { stroke }
+ \draw_scope_end:
}
-\__hanzibox_new_frame_construct:nn { 田 }
+\__hanzibox_new_frame_construct:nn { 米 }
{
- \__hanzibox_frame_type_c:n { 口 } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__hanzibox_frame_type_c:n { × } {#1} {#2} {#3} {#4} {#5} {#6}
\__hanzibox_frame_type_c:n { 十 } {#1} {#2} {#3} {#4} {#5} {#6}
}
-\__hanzibox_new_frame_construct:nn { 米 }
+\__hanzibox_new_frame_construct:nn { 口 }
{
- \__hanzibox_frame_type_c:n { × } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__hanzibox_frame_type_c:n { filledbox } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__hanzibox_frame_type_c:n { framebox } {#1} {#2} {#3} {#4} {#5} {#6}
+ }
+
+\__hanzibox_new_frame_construct:nn { 田 }
+ {
+ \__hanzibox_frame_type_c:n { filledbox } {#1} {#2} {#3} {#4} {#5} {#6}
\__hanzibox_frame_type_c:n { 十 } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__hanzibox_frame_type_c:n { framebox } {#1} {#2} {#3} {#4} {#5} {#6}
}
\__hanzibox_new_frame_construct:nn { 咪 }
{
- \__hanzibox_frame_type_c:n { 口 } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__hanzibox_frame_type_c:n { filledbox } {#1} {#2} {#3} {#4} {#5} {#6}
\__hanzibox_frame_type_c:n { × } {#1} {#2} {#3} {#4} {#5} {#6}
\__hanzibox_frame_type_c:n { 十 } {#1} {#2} {#3} {#4} {#5} {#6}
+ \__hanzibox_frame_type_c:n { framebox } {#1} {#2} {#3} {#4} {#5} {#6}
}
+\msg_new:nnn { hanzibox } { frame-exists } { The~ frame~ type~ `#1~ not~ exists. }
\cs_new_nopar:Npn \__hanzibox_resize:n #1
{
__hanzibox_processor_resize_ #1 :w
@@ -371,7 +450,29 @@
\msg_new:nnn { hanzibox } { frame-type } { using~ `#1'~ frame. }
\cs_new_nopar:Npn \__hanzibox_zihao:n #1 { \zihao {#1} }
-\msg_new:nnn { hanzibox } { frame-exists } { The~ frame~ type~ `#1~ not~ exists. }
+\cs_new:Npn \__hanzibox_chars_stroke:nn #1#2
+ {
+ \special { pdf:code ~ q ~ #1 } #2 \special { pdf:code ~ Q }
+ }
+\cs_new_protected:Npn \__hanzibox_chars_stroke_construct:n #1
+ {
+ \int_case:nn {\l__hanzibox_charstroke_type_int}
+ {
+ {1}{ #1 }
+ {2}{
+ \__hanzibox_chars_stroke:nn { 1 ~ Tr ~ 0.10 ~ w ~ [] ~ 0 ~ d ~ 1 ~ J } {#1}
+ }
+ {3}{
+ \__hanzibox_chars_stroke:nn { 1 ~ Tr ~ 0.10 ~ w ~ [1~1] ~ 0 ~ d ~ 1 ~ J } {#1}
+ }
+ {4}{
+ \__hanzibox_chars_stroke:nn { 3 ~ Tr } {#1}
+ }
+
+ }
+ }
+\cs_generate_variant:Nn \__hanzibox_chars_stroke_construct:n { V }
+\cs_generate_variant:Nn \__hanzibox_chars_stroke_construct:n { x }
\cs_set_nopar:Npn \__hanzibox_color_select:nn #1#2
{
\color_set:nn {#1} {#2}
@@ -398,7 +499,9 @@
}
\__hanzibox_calc_basechar_w_h:
},
- pinyinf .tl_set:N = \l__hanzibox_pinyin_format_tl ,
+ pinyinf .code:n = { \tl_set:Nn \l__hanzibox_pinyin_format_tl { #1 }
+ \__hanzibox_calc_pinyin_h:
+ },
pinyinf .initial:n = \tiny ,
charf .code:n = { \tl_gset:Nn \l__hanzibox_character_format_tl {#1}
\__hanzibox_calc_frame_size:
@@ -420,8 +523,14 @@
scale .meta:n = { xscale = #1 , yscale = #1 } ,
width .dim_set:N = \l__hanzibox_box_width_dim ,
height .dim_set:N = \l__hanzibox_box_height_dim ,
- linewidth .dim_set:N = \l__hanzibox_linewidth_dim ,
+ linewidth .dim_set:N = \l__hanzibox_frame_linewidth_dim ,
linewidth .initial:n = 0.4pt ,
+ framelinewidth .dim_set:N = \l__hanzibox_frame_linewidth_dim ,
+ framelinewidth .initial:n = 0.4pt ,
+ pinyinlinewidth .dim_set:N = \l__hanzibox_pinyin_linewidth_dim ,
+ pinyinlinewidth .initial:n = 0.4pt ,
+ crosslinewidth .dim_set:N = \l__hanzibox_cross_linewidth_dim ,
+ crosslinewidth .initial:n = 0.3pt ,
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 }
@@ -433,9 +542,17 @@
\__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} } ,
- color .meta:n = { framecolor = #1, charcolor = #1 } ,
- color* .meta:n = { framecolor* = #1, charcolor* = #1 } ,
+ charcolor* .code:n = { \__hanzibox_color_select:nnn { hanziboxcharcolor } #1 } ,
+ pinyincolor .code:n = { \__hanzibox_color_select:nn { hanziboxpinyincolor } {#1} } ,
+ pinyincolor .initial:n = black ,
+ pinyincolor* .code:n = { \__hanzibox_color_select:nnn { hanziboxpinyincolor } #1 } ,
+ trancolor .code:n = { \__hanzibox_color_select:nn { hanziboxtrancolor } {#1} } ,
+ trancolor .initial:n = black ,
+ trancolor* .code:n = { \__hanzibox_color_select:nnn { hanziboxtrancolor } #1 } ,
+ color .meta:n = { framecolor = #1, crosscolor = #1, charcolor = #1,
+ pinyincolor = #1, trancolor = #1 } ,
+ color* .meta:n = { framecolor* = #1, crosscolor = #1, charcolor* = #1,
+ pinyincolor* = #1, trancolor* = #1 } ,
fillcolor .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1}
{ \__hanzibox_color_select:nn { hanziboxfillcolor } { white }
\cs_set_nopar:Npn \__hanzibox_aux_color_fill: { }
@@ -446,6 +563,12 @@
fillcolor* .code:n = { \__hanzibox_color_select:nnn { hanziboxfillcolor } #1
\cs_set_nopar:Npn \__hanzibox_aux_color_fill: { \color_fill:nn #1 }
} ,
+ charstroke .choice:,
+ charstroke .value_required:n = true,
+ charstroke .choices:nn =
+ { none, solid, dashed, invisible }
+ { \int_set_eq:NN \l__hanzibox_charstroke_type_int \l_keys_choice_int },
+ charstroke .initial:n = none,
dashpattern .tl_set:N = \l__hanzibox_dash_pattern_tl ,
dashpattern .initial:n = { } ,
framearc .code:n = { \tl_set:Nn \l__hanzibox_frame_arc_tl { {#1}{#1} } } ,
@@ -470,6 +593,10 @@
tone .default:n = true,
tone .initial:n = true,
+ pinyinline .bool_set:N = \l__hanzibox_withpinyinlines_bool,
+ pinyinline .default:n = true,
+ pinyinline .initial:n = false,
+
pinyin .bool_set:N = \l__hanzibox_withpinyin_bool,
pinyin .default:n = true,
pinyin .initial:n = true,
@@ -496,15 +623,10 @@
tranf = \tiny ,
frametype = none ,
resize = none ,
- crosscolorratio = 20,
- framecolor = black,
}
\NewDocumentCommand \hanziboxset { m }
{ \keys_set:nn { hanzibox } {#1} }
- % \xpinyinsetup{pysep={\hspace*{1em}}}
-\cs_set_eq:NN \__hanzibox_pinyinaux:n \pinyin
-\cs_generate_variant:Nn \__hanzibox_pinyinaux:n { x }
\cs_new:Npn \__hanzibox_dialog:nnnn #1#2#3#4
{
\group_begin:
@@ -514,61 +636,111 @@
\tl_set:Nx \l__hanzibox_pinyin_tl {#3}
\tl_set:Nx \l__hanzibox_translation_tl {#4}
- \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
- {
- \tl_use:N \l__hanzibox_pinyin_format_tl
- \tl_use:N \l__hanzibox_pinyin_tl
- }
\hcoffin_set:Nn \l__hanzibox_str_box_coffin
{
\tl_map_inline:Nn \l__hanzibox_character_tl
{
- \__hanzibox_single_handle:N ##1 \allowbreak
+ \__hanzibox_single_handle:N ##1
+ }
+ }
+ \hcoffin_set:Nn \l_tmpa_coffin
+ {
+ \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
+ {
+ \color_select:n { hanziboxpinyincolor }
+ \tl_use:N \l__hanzibox_pinyin_format_tl
+ \tl_use:N \l__hanzibox_pinyin_tl
}
+ \dim_set:Nn \l_tmpa_dim { \coffin_wd:N \l__hanzibox_pinyin_box_coffin }
+ \draw_begin:
+ \draw_linewidth:n { \l__hanzibox_frame_linewidth_dim }
+ \color_stroke:n { hanziboxframecolor!50 }
+
+ \draw_path_scope_begin:
+ \__hanzibox_frame_type_c:n { pinyinlines }
+ { 0 } { 0 } { \l_tmpa_dim } { \hanziboxheight } { 1.0 } { 1.0 }
+ \draw_transform_shift:n {\l_tmpa_dim / 2.0, \l__hanzibox_pinyin_height_i_dim }
+ \draw_coffin_use:Nnn \l__hanzibox_pinyin_box_coffin { hc } { H }
+ \draw_path_scope_end:
+ \draw_end:
}
\hcoffin_set:Nn \l__hanzibox_tran_box_coffin
{
\tl_use:N \l__hanzibox_translation_format_tl
\tl_use:N \l__hanzibox_translation_tl
}
- \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin
- { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
- \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin
+ \coffin_join:NnnNnnnn \l_tmpa_coffin { hc } { b }
+ \l__hanzibox_str_box_coffin { hc } { t } { 0pt } { \l__hanzibox_frame_linewidth_dim }
+ \coffin_join:NnnNnnnn \l_tmpa_coffin
{ hc } { b } \l__hanzibox_tran_box_coffin { hc } { t } { 0pt } { -2pt }
- \coffin_set_eq:NN \l__hanzibox_box_coffin \l__hanzibox_str_box_coffin
+ \coffin_set_eq:NN \l__hanzibox_box_coffin \l_tmpa_coffin
\__hanzibox_resize_c:n { \l__hanzibox_resize_method_tl }
\coffin_typeset:Nnnnn \l__hanzibox_box_coffin
{ l } { b } { 0pt } { 0pt }
+ \allowbreak
\group_end:
}
+\cs_new:Npn \__hanzibox_single_pinyin_hanzi_construct:NN #1#2
+ {
+ \tl_if_empty:NTF #1
+ {
+ \hcoffin_set:Nn \l_tmpa_coffin
+ {
+ \__hanzibox_single_handle:N \c__hanzibox_basechar_tl
+ }
+ }
+ {
+ \hcoffin_set:Nn \l_tmpa_coffin
+ {
+ \__hanzibox_single_handle:N #1
+ }
+ }
+
+ \tl_if_empty:NTF #2
+ {
+ \hcoffin_set:Nn \l__hanzibox_pinyin_hanzi_coffin
+ {
+ \__hanzibox_single_pinyin_lines:
+ }
+
+ \coffin_join:NnnNnnnn \l__hanzibox_pinyin_hanzi_coffin
+ { hc } { b } \l_tmpa_coffin { hc } { t } { 0pt } { \l__hanzibox_pinyin_linewidth_dim }
+ }
+ {
+ \bool_if:NTF \l__hanzibox_withpinyin_bool
+ {
+ \hcoffin_set:Nn \l__hanzibox_pinyin_hanzi_coffin
+ {
+ \__hanzibox_single_pinyin:V #2
+ }
+
+ \coffin_join:NnnNnnnn \l__hanzibox_pinyin_hanzi_coffin
+ { hc } { b } \l_tmpa_coffin { hc } { t } { 0pt } { \l__hanzibox_pinyin_linewidth_dim }
+ }
+ {
+ \coffin_set_eq:NN \l__hanzibox_pinyin_hanzi_coffin \l_tmpa_coffin
+ }
+ }
+ }
\cs_new:Npn \__hanzibox_multi_str_coffin_construct:
{
+ \hcoffin_set:Nn \l__hanzibox_str_box_coffin
+ {
+ }
\bool_if:NTF \l__hanzibox_autopinyin_bool
{
- \hcoffin_set:Nn \l__hanzibox_str_box_coffin
+ \tl_map_inline:Nn \l__hanzibox_character_tl
{
- \tl_map_inline:Nn \l__hanzibox_character_tl
- {
- \hcoffin_set:Nn \l_tmpa_coffin
- {
- \__hanzibox_single_handle:N ##1
- }
+ \__hanzibox_get_hanzi_pinyin:n { ##1 }
- \bool_if:NT \l__hanzibox_withpinyin_bool
- {
- \__hanzibox_get_hanzi_pinyin:n { ##1 }
- \__hanzibox_single_pinyin:V \l__hanzibox_hanzi_pinyin_tl
+ \__hanzibox_single_pinyin_hanzi_construct:NN ##1 \l__hanzibox_hanzi_pinyin_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
- }
+ \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin { r } { b }
+ \l__hanzibox_pinyin_hanzi_coffin { l } { b }
+ { -\l__hanzibox_frame_linewidth_dim } { 0pt }
}
}
{
@@ -576,214 +748,138 @@
\clist_clear:N \l__hanzibox_tone_pinyin_clist
\clist_set:NV \l__hanzibox_tone_pinyin_clist \l__hanzibox_tone_pinyin_tl
\int_set:Nn \l_tmpa_int {\clist_count:N \l__hanzibox_tone_pinyin_clist}
- \hcoffin_set:Nn \l__hanzibox_str_box_coffin
- {
- \int_compare:nNnTF { \l__hanzibox_character_int } = { \l_tmpa_int }
- {
- \tl_map_inline:Nn \l__hanzibox_character_tl
- {
- \hcoffin_set:Nn \l_tmpa_coffin
- {
- \__hanzibox_single_handle:N ##1
- }
-
- \bool_if:NT \l__hanzibox_withpinyin_bool
- {
- \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
- }
- }
- {
- \int_compare:nNnTF { \l__hanzibox_character_int } > { \l_tmpa_int }
- {
- \int_step_inline:nn { \l_tmpa_int }
- {
- \hcoffin_set:Nn \l_tmpa_coffin
- {
- \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l__hanzibox_character_tl { ##1 }}
- \__hanzibox_single_handle:N \l_tmpa_tl
- }
- \bool_if:NT \l__hanzibox_withpinyin_bool
- {
- \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
- }
- \int_step_inline:nnn { \l_tmpa_int + 1 } { \l__hanzibox_character_int }
- {
- \hcoffin_set:Nn \l_tmpa_coffin
- {
- \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l__hanzibox_character_tl { ##1 }}
- \__hanzibox_single_handle:N \l_tmpa_tl
- }
- \coffin_typeset:Nnnnn \l_tmpa_coffin
- { l } { b } { 0pt } { 0pt }
- \allowbreak
- }
- }
- {
- \int_step_inline:nn { \l__hanzibox_character_int }
- {
- \hcoffin_set:Nn \l_tmpa_coffin
- {
- \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l__hanzibox_character_tl { ##1 }}
- \__hanzibox_single_handle:N \l_tmpa_tl
- }
- \bool_if:NT \l__hanzibox_withpinyin_bool
- {
- \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_if:NTF \l__hanzibox_withhanzi_bool
- {
- \bool_set_false:N \l__hanzibox_withhanzi_bool
- \int_step_inline:nnn { \l__hanzibox_character_int + 1 } { \l_tmpa_int }
- {
- \hcoffin_set:Nn \l_tmpa_coffin
- {
- \__hanzibox_single_handle:N \c__hanzibox_basechar_tl
- }
- \bool_if:NT \l__hanzibox_withpinyin_bool
- {
- \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_true:N \l__hanzibox_withhanzi_bool
- }
- {
- \int_step_inline:nnn { \l__hanzibox_character_int + 1 } { \l_tmpa_int }
- {
- \hcoffin_set:Nn \l_tmpa_coffin
- {
- \__hanzibox_single_handle:N \c__hanzibox_basechar_tl
- }
- \bool_if:NT \l__hanzibox_withpinyin_bool
- {
- \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
- }
- }
- }
- }
- }
+ \int_compare:nNnTF { \l__hanzibox_character_int } = { \l_tmpa_int }
+ {
+ \tl_map_inline:Nn \l__hanzibox_character_tl
+ {
+ \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+ \__hanzibox_single_pinyin_hanzi_construct:NN ##1 \l_tmpb_tl
+
+ \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin { r } { b }
+ \l__hanzibox_pinyin_hanzi_coffin { l } { b }
+ { -\l__hanzibox_frame_linewidth_dim } { 0pt }
+ }
+ }
+ {
+ \int_compare:nNnTF { \l__hanzibox_character_int } > { \l_tmpa_int }
+ {
+ \int_step_inline:nn { \l_tmpa_int }
+ {
+ \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l__hanzibox_character_tl { ##1 }}
+ \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+
+ \__hanzibox_single_pinyin_hanzi_construct:NN \l_tmpa_tl \l_tmpb_tl
+ \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin { r } { b }
+ \l__hanzibox_pinyin_hanzi_coffin { l } { b }
+ { -\l__hanzibox_frame_linewidth_dim } { 0pt }
+ }
+ \int_step_inline:nnn { \l_tmpa_int + 1 } { \l__hanzibox_character_int }
+ {
+ \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l__hanzibox_character_tl { ##1 }}
+ \tl_clear:N \l_tmpb_tl
+
+ \__hanzibox_single_pinyin_hanzi_construct:NN \l_tmpa_tl \l_tmpb_tl
+ \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin { r } { b }
+ \l__hanzibox_pinyin_hanzi_coffin { l } { b }
+ { -\l__hanzibox_frame_linewidth_dim } { 0pt }
+ }
+ }
+ {
+ \int_step_inline:nn { \l__hanzibox_character_int }
+ {
+ \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \l__hanzibox_character_tl { ##1 }}
+ \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+
+ \__hanzibox_single_pinyin_hanzi_construct:NN \l_tmpa_tl \l_tmpb_tl
+ \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin { r } { b }
+ \l__hanzibox_pinyin_hanzi_coffin { l } { b }
+ { -\l__hanzibox_frame_linewidth_dim } { 0pt }
+ }
+
+ \bool_set_eq:NN \l_tmpa_bool \l__hanzibox_withhanzi_bool
+ \bool_set_false:N \l__hanzibox_withhanzi_bool
+ \int_step_inline:nnn { \l__hanzibox_character_int + 1 } { \l_tmpa_int }
+ {
+ \tl_clear:N \l_tmpa_tl
+ \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+
+ \__hanzibox_single_pinyin_hanzi_construct:NN \l_tmpa_tl \l_tmpb_tl
+ \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin { r } { b }
+ \l__hanzibox_pinyin_hanzi_coffin { l } { b }
+ { -\l__hanzibox_frame_linewidth_dim } { 0pt }
+ }
+ \bool_set_eq:NN \l__hanzibox_withhanzi_bool \l_tmpa_bool
+ }
+ }
}
}
\cs_new:Npn \__hanzibox_single_str_coffin_construct:
{
\bool_if:NTF \l__hanzibox_autopinyin_bool
{
- \__hanzibox_multi_str_coffin_construct:
+ \hcoffin_set:Nn \l__hanzibox_str_box_coffin
+ {
+ \__hanzibox_get_hanzi_pinyin:V \l__hanzibox_character_tl
+
+ \__hanzibox_single_pinyin_hanzi_construct:NN
+ \l__hanzibox_character_tl \l__hanzibox_hanzi_pinyin_tl
+ \coffin_typeset:Nnnnn \l__hanzibox_pinyin_hanzi_coffin
+ { l } { b } { 0pt } { 0pt }
+ }
}
{
\hcoffin_set:Nn \l__hanzibox_str_box_coffin
{
- \hcoffin_set:Nn \l_tmpa_coffin
- {
- \__hanzibox_single_handle:N \l__hanzibox_character_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
+ \tl_set:Nx \l_tmpb_tl { \clist_use:Nn \l__hanzibox_tone_pinyin_clist { } }
- \bool_if:NT \l__hanzibox_withpinyin_bool
- {
- \hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
- {
- \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 {}
- }
- \coffin_join:NnnNnnnn \l_tmpa_coffin
- { hc } { t } \l__hanzibox_pinyin_box_coffin { hc } { H } { 0pt } { 3pt }
- }
- \coffin_typeset:Nnnnn \l_tmpa_coffin
+ \__hanzibox_single_pinyin_hanzi_construct:NN \l__hanzibox_character_tl \l_tmpb_tl
+ \coffin_typeset:Nnnnn \l__hanzibox_pinyin_hanzi_coffin
{ l } { b } { 0pt } { 0pt }
- \allowbreak
}
}
}
\cs_new:Npn \__hanzibox_null_str_coffin_construct:
{
+ \bool_set_eq:NN \l_tmpa_bool \l__hanzibox_withhanzi_bool
+ \bool_set_false:N \l__hanzibox_withhanzi_bool
\bool_if:NTF \l__hanzibox_autopinyin_bool
{
\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
}
}
{
\hcoffin_set:Nn \l__hanzibox_str_box_coffin
{
- \bool_if:NTF \l__hanzibox_withpinyin_bool
- {
- \__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
- \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
+ }
+ \bool_if:NTF \l__hanzibox_withpinyin_bool
+ {
+ \__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
+ \int_set:Nn \l_tmpa_int {\clist_count:N \l__hanzibox_tone_pinyin_clist}
- \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
- }
- }
+ \int_step_inline:nn { \l_tmpa_int }
{
- \bool_set_false:N \l__hanzibox_withhanzi_bool
- \__hanzibox_single_handle:N \c__hanzibox_basechar_tl
- \allowbreak
+ \tl_clear:N \l_tmpa_tl
+ \clist_pop:NN \l__hanzibox_tone_pinyin_clist \l_tmpb_tl
+
+ \__hanzibox_single_pinyin_hanzi_construct:NN \l_tmpa_tl \l_tmpb_tl
+ \coffin_join:NnnNnnnn \l__hanzibox_str_box_coffin { r } { b }
+ \l__hanzibox_pinyin_hanzi_coffin { l } { b }
+ { -\l__hanzibox_frame_linewidth_dim } { 0pt }
}
}
+ {
+ \bool_set_false:N \l__hanzibox_withhanzi_bool
+ \__hanzibox_single_handle:N \c__hanzibox_basechar_tl
+ }
}
+ \bool_set_eq:NN \l__hanzibox_withhanzi_bool \l_tmpa_bool
}
\cs_new:Npn \__hanzibox_handle:nnnn #1#2#3#4
{
@@ -824,7 +920,7 @@
{
\hcoffin_set:Nn \l__hanzibox_tran_box_coffin
{
- \color_select:n { hanziboxcharcolor }
+ \color_select:n { hanziboxtrancolor }
\tl_use:N \l__hanzibox_translation_format_tl
\tl_use:N \l__hanzibox_translation_tl
}
@@ -838,6 +934,7 @@
\coffin_typeset:Nnnnn \l__hanzibox_box_coffin
{ l } { b } { 0pt } { 0pt }
+ \allowbreak
\group_end:
}
\cs_new:Npn \__hanzibox_single_pinyin:n #1
@@ -849,7 +946,7 @@
\__hanzibox_split_pinyin_withtone:n { #1 }
\hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
{
- \color_select:n { hanziboxcharcolor }
+ \color_select:n { hanziboxpinyincolor }
\tl_use:N \l__hanzibox_pinyin_format_tl
\bool_if:NTF \l__hanzibox_withinitial_bool
@@ -880,7 +977,7 @@
{
\hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
{
- \color_select:n { hanziboxcharcolor }
+ \color_select:n { hanziboxpinyincolor }
\tl_use:N \l__hanzibox_pinyin_format_tl
#1
}
@@ -890,12 +987,13 @@
\__hanzibox_split_pinyin_withouttone:n { #1 }
\hcoffin_set:Nn \l__hanzibox_pinyin_box_coffin
{
- \color_select:n { hanziboxcharcolor }
+ \color_select:n { hanziboxtrancolor }
\tl_use:N \l__hanzibox_pinyin_format_tl
\tl_use:N \l__hanzibox_pinyin_tl
}
}
+ \__hanzibox_single_pinyin_lines_construct:
}
\cs_generate_variant:Nn \__hanzibox_single_pinyin:n { V }
\cs_generate_variant:Nn \__hanzibox_single_pinyin:n { x }
@@ -928,7 +1026,7 @@
{
\color_select:n { hanziboxcharcolor }
\tl_use:N \l__hanzibox_character_format_tl
- #1
+ \__hanzibox_chars_stroke_construct:n { #1 }
}
}
{
@@ -949,7 +1047,7 @@
\cs_new:Npn \__hanzibox_single_frame_construct:
{
\draw_begin:
- \draw_linewidth:n { \l__hanzibox_linewidth_dim }
+ \draw_linewidth:n { \l__hanzibox_frame_linewidth_dim }
\__hanzibox_aux_color_fill:
\color_stroke:n { hanziboxframecolor }
@@ -963,6 +1061,30 @@
\draw_path_scope_end:
\draw_end:
}
+\cs_new:Npn \__hanzibox_single_pinyin_lines_construct:
+ {
+ \draw_begin:
+ \draw_linewidth:n { \l__hanzibox_pinyin_linewidth_dim }
+ \color_stroke:n { hanziboxframecolor!50 }
+
+ \draw_path_scope_begin:
+ \__hanzibox_frame_type_c:n { pinyinlines }
+ { 0 } { 0 } { \hanziboxwidth } { \hanziboxheight } { 1.0 } { 1.0 }
+ \draw_transform_shift:n {\hanziboxwidth / 2.0, \l__hanzibox_pinyin_height_i_dim }
+ \draw_coffin_use:Nnn \l__hanzibox_pinyin_box_coffin { hc } { H }
+ \draw_path_scope_end:
+ \draw_end:
+ }
+\cs_new:Npn \__hanzibox_single_pinyin_lines:
+ {
+ \draw_begin:
+ \draw_linewidth:n { \l__hanzibox_pinyin_linewidth_dim }
+ \color_stroke:n { hanziboxframecolor!50 }
+
+ \__hanzibox_frame_type_c:n { pinyinlines }
+ { 0 } { 0 } { \hanziboxwidth } { \hanziboxheight } { 1.0 } { 1.0 }
+ \draw_end:
+ }
\tl_new:N \l__hanzibox_save_tl
\tl_new:N \l__hanzibox_hanzi_pinyin_tl
\tl_new:N \l__hanzibox_tone_pinyin_tl
@@ -1026,6 +1148,7 @@
}
{ \tl_set_eq:NN \l__hanzibox_hanzi_pinyin_tl \l_tmpa_tl }
}
+\cs_generate_variant:Nn \__hanzibox_get_hanzi_pinyin:n { V }
\clist_set:Nn \l__hanzibox_initials_clist
{
{zh} , {ch} , {sh} , {b} , {p} , {m} , {f} ,