From 2f7bce4f0ebd3375474c5e453d44287731e041fe Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 17 Apr 2022 20:02:53 +0000 Subject: hanzibox (17apr22) git-svn-id: svn://tug.org/texlive/trunk@63062 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/xelatex/hanzibox/hanzibox.sty | 87 +++++++++++++++++++++- 1 file changed, 84 insertions(+), 3 deletions(-) (limited to 'Master/texmf-dist/tex/xelatex') diff --git a/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty index 2cc012a0b5c..23078e54cbc 100644 --- a/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty +++ b/Master/texmf-dist/tex/xelatex/hanzibox/hanzibox.sty @@ -6,7 +6,7 @@ %% %% hanzibox.dtx (with options: `package') %% -%% Copyright (C) 2020-2021 by Nan Geng +%% Copyright (C) 2020-2022 by Nan Geng %% -------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -27,7 +27,7 @@ %% \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{expl3} -\GetIdInfo$Id: hanzibox.dtx 2.2.0 2021-10-11 08:00:00 +0800 Nan Geng $ +\GetIdInfo$Id: hanzibox.dtx 2.3.0 2022-04-17 08:00:00 +0800 Nan Geng $ {Boxed Chinese characters with Pinyin above and translation below.} \ProvidesExplPackage{\ExplFileName} {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -73,7 +73,12 @@ \__hanzibox_dialog:nnnn { #1 } { #2 } { #3 } { #4 } \group_end: } - +\NewDocumentCommand{\writegrid}{ O{} m } + { + \group_begin: + \__hanzibox_writegrid:nn { #1 } { #2 } + \group_end: + } \bool_new:N \l__hanzibox_autopinyin_bool \bool_new:N \l__hanzibox_withinitial_bool \bool_new:N \l__hanzibox_withvowel_bool @@ -109,6 +114,9 @@ \coffin_new:N \l__hanzibox_pinyin_hanzi_coffin \coffin_new:N \l__hanzibox_tmpa_coffin \coffin_new:N \l__hanzibox_tmpb_coffin +\coffin_new:N \l__hanzibox_grid_coffin +\coffin_new:N \l__hanzibox_grid_tmpa_coffin +\coffin_new:N \l__hanzibox_grid_tmpb_coffin \dim_new:N \hanziboxwidth \dim_new:N \hanziboxheight @@ -124,11 +132,13 @@ \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_grid_cols_int \int_new:N \l__hanzibox_tone_int \str_new:N \l__hanzibox_pinyin_str \tl_new:N \l__hanzibox_initial_tl \tl_new:N \l__hanzibox_vowel_tl +\tl_new:N \l__hanzibox_grid_sep_v_tl \cs_new_nopar:Nn \__hanzibox_aux_color_fill: { } @@ -609,6 +619,10 @@ tran .default:n = true, tran .initial:n = true, + gridsepv .tl_set:N = \l__hanzibox_grid_sep_v_tl , + gridsepv .initial:n = 4.0 , + gridcols .int_set:N = \l__hanzibox_grid_cols_int , + gridcols .initial:n = 20 , unknown .code:n = { \__hanzibox_error:n { unknown-option } } } \msg_new:nnn { hanzibox } { unknown-option } @@ -937,6 +951,73 @@ \allowbreak \group_end: } +\cs_new:Npn \__hanzibox_writegrid:nn #1#2 + { + \group_begin: + \keys_set:nn { hanzibox } { #1 } + + \tl_if_eq:NnT \l__hanzibox_frame_type_tl { none } + { \tl_set:Nn \l__hanzibox_frame_type_tl { 口 } } + + \hcoffin_set:Nn \l__hanzibox_grid_tmpa_coffin + { + \draw_begin: + \draw_linewidth:n { \l__hanzibox_frame_linewidth_dim } + \__hanzibox_aux_color_fill: + \color_stroke:n { hanziboxframecolor } + + \draw_path_scope_begin: + \__hanzibox_frame_type_c:n { \l__hanzibox_frame_type_tl } + { 0 } { 0 } { \hanziboxwidth } { \hanziboxheight } { 1.0 } { 1.0 } + \int_decr:N \l__hanzibox_grid_cols_int + \int_step_inline:nn { \l__hanzibox_grid_cols_int } + { + \draw_transform_shift:n {\hanziboxwidth, 0.0 } + \__hanzibox_frame_type_c:n { \l__hanzibox_frame_type_tl } + { 0 } { 0 } { \hanziboxwidth } { \hanziboxheight } { 1.0 } { 1.0 } + } + \draw_path_scope_end: + \draw_end: + } + + \hcoffin_set:Nn \l__hanzibox_grid_tmpb_coffin + { + \coffin_typeset:Nnnnn \l__hanzibox_grid_tmpa_coffin + { l } { b } { 0pt } { 0pt } + } + + \int_step_inline:nn { #2 - 1 } + { + \coffin_join:NnnNnnnn \l__hanzibox_grid_tmpb_coffin { hc } { b } + \l__hanzibox_grid_tmpa_coffin { hc } { t } { 0pt } + { -\hanziboxheight * \dim_ratio:nn { 1 pt }{ \l__hanzibox_grid_sep_v_tl pt } } + } + + \dim_set:Nn \l_tmpa_dim + { + \coffin_wd:N \l__hanzibox_grid_tmpb_coffin + } + \dim_set:Nn \l_tmpb_dim + { + \tex_dimexpr:D \coffin_ht:N \l__hanzibox_grid_tmpb_coffin + + \coffin_dp:N \l__hanzibox_grid_tmpb_coffin \scan_stop: + } + + \draw_begin: + \draw_linewidth:n { \l__hanzibox_frame_linewidth_dim * 4 } + \__hanzibox_aux_color_fill: + \color_stroke:n { hanziboxframecolor } + + \draw_path_scope_begin: + \draw_path_rectangle_corners:nn { 0cm , 0cm } { \l_tmpa_dim, \l_tmpb_dim } + \draw_path_use_clear:n { draw } + \draw_transform_shift:n {\l_tmpa_dim / 2.0, \l_tmpb_dim / 2.0 } + \draw_coffin_use:Nnn \l__hanzibox_grid_tmpb_coffin { hc } { vc } + \draw_path_scope_end: + \draw_end: + + \group_end: + } \cs_new:Npn \__hanzibox_single_pinyin:n #1 { \bool_if:NTF \l__hanzibox_withtone_bool -- cgit v1.2.3