1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
|
%% license LPPL 1.3c, https://www.latex-project.org/lppl/lppl-1-3c/
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{ xparse , l3keys2e }
\RequirePackage{ l3draw }
\ProvidesExplPackage {zitie} {2021/10/01} {v1.4.0} {CJK character calligraphy sheet}
\@ifpackageloaded { xcolor }
{
\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_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_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_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_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 \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
\dim_new:N \zitieboxht
\dim_new:N \zitieboxdp
\tl_new:N \zitiefontname
\tl_new:N \zitiexscaleratio
\tl_new:N \zitieyscaleratio
\int_new:N \l__zitie_begin_int
\int_new:N \l__zitie_end_int
\clist_new:N \l__zitie_tmpa_clist
\tl_new:N \l__zitie_tmpa_tl
\seq_new:N \l__zitie_tmpa_seq
\coffin_new:N \l__zitie_tmpa_coffin
\coffin_new:N \l__zitie_tmpb_coffin
\tl_new:N \l__zitie_file_chars_tl
\tl_const:Nn \c_zitie_font_name_prefix_tl { 字帖@ }
\sys_if_engine_xetex:TF { \tex_input:D zitie.xetex.def \prg_do_nothing: }
{
\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_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 }
\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
{ \exp_after:wN \zitie_token_if_punctuation:NT }
\cs_set:Npn \zitie_token_if_punctuation_o:NF
{ \exp_after:wN \zitie_token_if_punctuation:NF }
\cs_set:Npn \zitie_token_if_punctuation_f:NTF
{ \exp_args:Nf \zitie_token_if_punctuation:NTF }
\cs_set:Npn \zitie_token_if_punctuation_f:NT
{ \exp_args:Nf \zitie_token_if_punctuation:NT }
\cs_set:Npn \zitie_token_if_punctuation_f:NF
{ \exp_args:Nf \zitie_token_if_punctuation:NF }
%%%
\prg_new_conditional:Npnn \zitie_if_preamble: { p, T, F, TF }
{
\if_meaning:w \@onlypreamble \@notprerr
\prg_return_false:
\else:
\prg_return_true:
\fi:
}
\cs_new:Npn \__zitie_calc_basechar_w_h:
{
\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 }
\cs_new_nopar:Npn \__zitie_resize_c:n #1 { \use:c { __zitie_processor_resize_ #1 :n } }
\cs_new_nopar:Npn \zitie_processor:n #1 { __zitie_processor_ #1 :n }
\cs_new_nopar:Npn \zitie_processor_c:n #1 { \use:c { __zitie_processor_ #1 :n } }
\cs_new_nopar:Npn \zitie_processor:nnn #1#2#3
{
__zitie_processor_ #1 @ #2 :
\if_case:w 0#3 \prg_do_nothing:
\or: n \or: nn \or: nnn \or: nnnn \or: nnnnn \or: nnnnnn
\or: nnnnnnn \or: nnnnnnnn \else: nnnnnnnnn \fi:
}
\cs_new_nopar:Npn \zitie_processor_c:nnn #1#2#3 { \use:c { \zitie_processor:nnn {#1} {#2} {#3} } }
\cs_new_nopar:Npn \__zitie_coffin_ht_plus_dp:N #1 { \coffin_ht:N #1 + \coffin_dp:N #1 }
\cs_new:Npn \zitie_debug:n { \bool_if:NTF \l__zitie_debug_bool { \use:n } { \use_none:n } }
\cs_new_nopar:Npn \zitie_cjk_glyph_use:nN #1#2
{
\group_begin:
\bool_if:NTF \l__zitie_font_fallback_bool
{
\__zitie_font_select:nN {#1} \prg_do_nothing:
\__zitie_cjk_glyph_use_aux:N #2
}
{ \__zitie_font_select:nN {#1} #2 }
\group_end:
}
\cs_new_nopar:Npn \__zitie_cjk_glyph_use_aux:N #1
{
\exp_args:Nf \zitie_glyph_if_exist:NTF #1 {#1}
{
\clist_pop:NNTF \l__zitie_fallback_font_clist \l__zitie_tmpa_tl
{
\zitie_family_if_exist:nTF { \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
}
{
\zitierawCJKfamily+ { \l__zitie_tmpa_tl }
\__zitie_cjk_glyph_use_aux:N #1
}
}
{#1}
}
}
\msg_new:nnn { zitie } { frame-exists } { The~ frame~ type~ `#1~ not~ exists. }
\msg_new:nnn { zitie } { font-args } { The~ font~ arguments~ number~ must~ be~ 2~ or~ 3, while~ you~ get~ `#1' }
\keys_define:nn { zitie }
{
enable-background .bool_set:N = \g__zitie_enable_background_bool ,
enable-background .initial:n = false ,
enable-background .default:n = true ,
enable-zhlipsum .bool_set:N = \g__zitie_enable_zhlipsum_bool ,
enable-zhlipsum .initial:n = false ,
enable-zhlipsum .default:n = true ,
}
\keys_define:nn { zitie }
{
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 } ,
punctuation / unknown .code:n = { \cs_set_eq:cc { \zitie_processor:n { punctuation } } {#1} } ,
punctuation .initial:n = ignore ,
punctuation* .cs_set:cp = { \zitie_processor:n { punctuation } } #1 ,
frametype .code:n =
{
\exp_args:NNx \clist_if_in:NnTF \g__zitie_frame_list_clist {#1}
{ \tl_set:Nx \l_zitie_frame_type_tl {#1} }
{ \msg_error:nnx { zitie } { frame-exists } {#1} }
} ,
resize .code:n =
{
\exp_args:NNx \clist_if_in:NnTF \g__zitie_resize_method_clist {#1}
{ \tl_set:Nx \l_zitie_resize_method_tl {#1} }
{ \msg_error:nnx { zitie } { resize-method } {#1} }
} ,
font .tl_set:N = \l__zitie_font_tl ,
font .initial:n = 宋体 ,
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 ,
yscale .initial:n = 1 ,
scale .meta:n = { xscale = #1 , yscale = #1 } ,
width .dim_set:N = \l__zitie_box_width_dim ,
height .dim_set:N = \l__zitie_box_height_dim ,
linewidth .dim_set:N = \l__zitie_linewidth_dim ,
linewidth .initial:n = 0.4pt ,
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_set:nnn { zitieframecolor } #1 } ,
charcolor .code:n = { \zitie_color_set:nn { zitiecharcolor } {#1} } ,
charcolor .initial:n = black ,
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_set:nn { zitiefillcolor } { white } \cs_set_nopar:Npn \__zitie_aux_color_fill: { } }
{
\zitie_color_set:nn { zitiefillcolor } {#1}
\cs_set_nopar:Npn \__zitie_aux_color_fill: { \color_fill:n {#1} }
}
} ,
fillcolor* .code:n =
{
\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 ,
dashpattern .initial:n = { } ,
framearc .code:n = { \tl_set:Nn \l__zitie_frame_arc_tl { {#1}{#1} } } ,
framearc* .tl_set:N = \l__zitie_frame_arc_tl ,
framearc* .initial:n = { { 0cm }{ 0cm } } ,
filepath .code:n =
{
\seq_clear:N \l_file_search_path_seq
\keys_set:nn { zitie } { filepath+ = {#1} }
} ,
filepath+ .code:n = { \tl_map_inline:nn {#1} { \seq_put_right:Nn \l_file_search_path_seq {##1} } } ,
charstroke .multichoice: ,
charstroke / none .code:n = { \cs_set_eq:cN { \zitie_processor:n { charstroke } } \use:n } ,
charstroke / unknown .code:n = { \cs_set_eq:cc { \zitie_processor:n { charstroke } } {#1} } ,
charstrokespecial .code:n =
{
\cs_set:cn { \zitie_processor:n { charstroke } }
{ \zitie_stroke_chars:nn {#1} {##1} }
} ,
charstroke .initial:n = { none } ,
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 = \l__zitie_fallback_font_clist ,
fallbackfont .initial:n = { 宋体 } ,
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 {#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 } } }
}
\cs_new:Npn \zitie_new_process_rule:nnnn #1#2#3#4 % processor, id, arg num, code
{
\cs_set:cn { \zitie_processor:nnn {#1} {#2} {#3} }
{ \hook_use:n { zitie/processor/before } #4 \hook_use:n { zitie/processor/after } }
\keys_define:nn { zitie }
{ #1/#2 .code:n = { \cs_set_eq:cc { \zitie_processor:n {#1} } { \zitie_processor:nnn {#1} {#2} {#3} } } }
}
\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 }
{
\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
}
\zitie_new_process_rule:nnn { charstroke } { solid }
{ \zitie_stroke_chars:nn { 1 ~ Tr ~ 0.25 ~ w ~ [] ~ 0 ~ d ~ 1 ~ J } {#1} }
\zitie_new_process_rule:nnn { charstroke } { dashed }
{ \zitie_stroke_chars:nn { 1 ~ Tr ~ 0.25 ~ w ~ [.8] ~ 0 ~ d ~ 1 ~ J } {#1} }
\zitie_new_process_rule:nnn { charstroke } { whitesolid }
{ \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} { } }
\cs_new:Npn \__zitie_new_font_family_validate:nn #1#2 { \__zitie_new_font_family_validate:nnn {#1} {#2} { } }
\cs_new:Npn \zitie_new_font:n #1
{
\clist_map_inline:nn {#1}
{
\int_case:nnF { \tl_count:n {##1} }
{
{ 2 } { \__zitie_new_font_family_validate:nn ##1 }
{ 3 } { \__zitie_new_font_family_validate:nnn ##1 }
}
{ \msg_error:nnn { zitie } { font-args } {##1} }
}
}
\cs_new:Npn \zitie_new_font:nnn #1#2#3 % fontfamily, fontname, font feature
{
\seq_set_from_clist:Nn \l__zitie_tmpa_seq {#1}
\clist_set:Nn \l__zitie_tmpa_clist {#2}
\seq_map_indexed_inline:Nn \l__zitie_tmpa_seq
{
\__zitie_new_font_family_validate:nnn
{ ##2 } { \clist_item:Nn \l__zitie_tmpa_clist {##1} } {#3}
}
}
\cs_new:Npn \zitiesetup #1
{
\keys_set:nn { zitie } {#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 }
}
\cs_new:Npn \zitie_new_resize_method:nn #1
{
\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
{
\clist_put_right:Nn \g__zitie_frame_list_clist {#1}
\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 }
{
frametype = none ,
resize = none ,
}
\ProcessKeysPackageOptions { zitie }
\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}
\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}
\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
{
\zitie_token_if_punctuation_f:NTF #1
{ \zitie_processor_c:n { punctuation } {#1} }
{
\hcoffin_set:Nn \l__zitie_tmpb_coffin
{
\bool_if:NT \l__zitie_holdbasechar_height_bool { \vphantom \zitiebasechar }
\color_select:n { zitiecharcolor }
\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_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_tmpb_coffin }
\dim_gset_eq:NN \zitieboxwd \zitiewidth
\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 } }
\__zitie_single_frame_construct:
}
}
\cs_set:Npn \__zitie_single_construct_o:N
{ \exp_after:wN \__zitie_single_construct:N }
\cs_set:Npn \__zitie_single_construct_f:N
{ \exp_args:Nf \__zitie_single_construct:N }
\cs_new:Npn \zitie_dim_gezero_dispatch:NNnnn #1#2 #3#4#5
{
\dim_compare:nNnTF #1 > \c_zero_dim
{ #3 }
{
\dim_compare:nNnTF #2 > \c_zero_dim
{ #4 } { #5 }
}
}
\cs_new:Npn \zitie_dim_gezero_dispatch:NNnnnn #1#2 #3#4#5#6
{
\dim_compare:nNnTF #1 > \c_zero_dim
{
\dim_compare:nNnTF #2 > \c_zero_dim
{ #3 } { #4 }
}
{
\dim_compare:nNnTF #2 > \c_zero_dim
{ #5 } { #6 }
}
}
\cs_new:Npn \__zitie_force_size_dispatch:nnn % height, width, none
{ \zitie_dim_gezero_dispatch:NNnnn \l__zitie_box_height_dim \l__zitie_box_width_dim }
\cs_new:Npn \__zitie_force_size_dispatch:nnnn % both, height, width, none
{ \zitie_dim_gezero_dispatch:NNnnnn \l__zitie_box_height_dim \l__zitie_box_width_dim }
\zitie_new_resize_method:nn { real }
{
\__zitie_force_size_dispatch:nnnn
{ \coffin_resize:Nnn \l__zitie_tmpb_coffin \l__zitie_box_width_dim \l__zitie_box_height_dim }
{
\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_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_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_tmpb_coffin \l__zitie_box_width_dim \l__zitie_box_height_dim }
{
\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_tmpb_coffin
{ \l__zitie_box_width_dim }
{ \zitiebasecharheight * \dim_ratio:nn { \l__zitie_box_width_dim } { \coffin_wd:N \l__zitie_tmpb_coffin } }
}
{
\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 { \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_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:
{
\if_dim:w \zitieheight > \zitiewidth
\coffin_resize:Nnn \l__zitie_tmpa_coffin
{ ( \zitieheight - \zitiewidth ) / 2 }
{ \zitieheight }
\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_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:
}
\msg_new:nnn { zitie } { frame-type } { using~ `#1'~ frame. }
\cs_new:Npn \__zitie_single_frame_construct:
{
\draw_begin:
\draw_linewidth:n { \l__zitie_linewidth_dim }
\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_tmpb_coffin { l } { b }
\draw_end:
}
\zitie_new_frame_construct:nn { 口 }
{
\draw_path_rectangle_corners:nn { #1 , #2 } { #3 , #4 }
\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_moveto:n { #1 , (#4)/2 }
\draw_path_lineto:n { #3 , (#4)/2 }
\draw_path_use_clear:n { stroke }
}
\zitie_new_frame_construct:nn { 田 }
{
\zitie_frame_type_c:n { 口 } {#1} {#2} {#3} {#4} {#5} {#6}
\zitie_frame_type_c:n { 十 } {#1} {#2} {#3} {#4} {#5} {#6}
}
\zitie_new_frame_construct:nn { × }
{
\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 }
}
\zitie_new_frame_construct:nn { 咪 }
{
\zitie_frame_type_c:n { 口 } {#1} {#2} {#3} {#4} {#5} {#6}
\zitie_frame_type_c:n { × } {#1} {#2} {#3} {#4} {#5} {#6}
\zitie_frame_type_c:n { 十 } {#1} {#2} {#3} {#4} {#5} {#6}
}
\zitie_new_frame_construct:nn { 米 }
{
\zitie_frame_type_c:n { × } {#1} {#2} {#3} {#4} {#5} {#6}
\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}
{
\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:
}
\hook_new_pair:nn { zitie/framerange/before } { zitie/framerange/after }
\hook_new:n { zitie/framerange/range }
\NewDocumentCommand \framerange { 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/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 }
\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_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/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 \__zitie_break: \__zitie_construct_loop:N } }
}
\hook_new_pair:nn { zitie/zitieframe/before } { zitie/zitieframe/after }
\hook_new:n { zitie/zitieframe/par }
\NewDocumentEnvironment { zitieframe } { G{} O{} +b }
{
\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_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 }
\NewDocumentCommand \framezifile { 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/framezifile/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}
{
\file_get:nnN {#3} { } \l__zitie_file_chars_tl
\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}
\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
%%% module background
\dim_new:N \g__zitie_background_lmargin_dim
\dim_new:N \g__zitie_background_tmargin_dim
\dim_new:N \g__zitie_background_rmargin_dim
\dim_new:N \g__zitie_background_bmargin_dim
\dim_new:N \g__zitie_background_boxwidth_dim
\dim_new:N \g__zitie_background_boxheight_dim
\skip_new:N \g__zitie_background_boxcol_skip
\skip_new:N \g__zitie_background_boxrow_skip
\dim_new:N \g__zitie_background_framewidth_dim
\dim_new:N \g__zitie_background_frameheight_dim
\dim_new:N \g__zitie_background_x_left_dim
\dim_new:N \g__zitie_background_x_right_dim
\dim_new:N \g__zitie_background_y_top_dim
\dim_new:N \g__zitie_background_y_bottom_dim
\bool_new:N \g__zitie_background_colnum_bool
\bool_new:N \g__zitie_background_rownum_bool
\int_new:N \g__zitie_background_colboxes_int
\int_new:N \g__zitie_background_rowboxes_int
\dim_new:N \g__zitie_background_linewidth_dim
\cs_new_nopar:Npn \__zitie_background_aux_color_fill: { }
\keys_define:nn { zitie } { background .meta:nn = { zitie/background } {#1} }
\NewDocumentCommand \zitiebackground { O{} }
{
\keys_set:nn { zitie/background } {#1}
\__zitie_background_typeset:
}
\keys_define:nn { zitie/background }
{
typeset .choice: ,
typeset / true .code:n = { \cs_gset:Npn \__zitie_background_typeset: { \zitie_set_background_frame: } } ,
typeset / false .code:n = { \cs_gset:Npn \__zitie_background_typeset: { \zitie_unset_background_frame: } } ,
typeset / next .code:n =
{
\cs_gset:Npn \__zitie_background_typeset:
{ \zitie_unset_background_frame: \zitie_set_next_background_frame: }
} ,
typeset / none .code:n = { \cs_gset:Npn \__zitie_background_typeset: { } } ,
true .meta:n = { typeset = true } ,
on .meta:n = { typeset = true } ,
false .meta:n = { typeset = false } ,
off .meta:n = { typeset = false } ,
next .meta:n = { typeset = next } ,
none .meta:n = { typeset = none } ,
lmargin .dim_gset:N = \g__zitie_background_lmargin_dim ,
tmargin .dim_gset:N = \g__zitie_background_tmargin_dim ,
rmargin .dim_gset:N = \g__zitie_background_rmargin_dim ,
bmargin .dim_gset:N = \g__zitie_background_bmargin_dim ,
margin .code:n =
{
\if_case:w \clist_count:n {#1} \exp_stop_f:
\dim_gset:Nn \g__zitie_background_lmargin_dim { 0pt }
\dim_gset:Nn \g__zitie_background_tmargin_dim { 0pt }
\dim_gset:Nn \g__zitie_background_rmargin_dim { 0pt }
\dim_gset:Nn \g__zitie_background_bmargin_dim { 0pt }
\or:
\dim_gset:Nn \g__zitie_background_lmargin_dim {#1}
\dim_gset:Nn \g__zitie_background_tmargin_dim {#1}
\dim_gset:Nn \g__zitie_background_rmargin_dim {#1}
\dim_gset:Nn \g__zitie_background_bmargin_dim {#1}
\or:
\dim_gset:Nn \g__zitie_background_lmargin_dim { \clist_item:nn {#1} { 1 } }
\dim_gset:Nn \g__zitie_background_tmargin_dim { \clist_item:nn {#1} { 2 } }
\dim_gset:Nn \g__zitie_background_rmargin_dim { \clist_item:nn {#1} { 1 } }
\dim_gset:Nn \g__zitie_background_bmargin_dim { \clist_item:nn {#1} { 2 } }
\or:
\dim_gset:Nn \g__zitie_background_lmargin_dim { \clist_item:nn {#1} { 1 } }
\dim_gset:Nn \g__zitie_background_tmargin_dim { \clist_item:nn {#1} { 2 } }
\dim_gset:Nn \g__zitie_background_rmargin_dim { \clist_item:nn {#1} { 1 } }
\dim_gset:Nn \g__zitie_background_bmargin_dim { \clist_item:nn {#1} { 2 } }
\else:
\dim_gset:Nn \g__zitie_background_lmargin_dim { \clist_item:nn {#1} { 1 } }
\dim_gset:Nn \g__zitie_background_tmargin_dim { \clist_item:nn {#1} { 2 } }
\dim_gset:Nn \g__zitie_background_rmargin_dim { \clist_item:nn {#1} { 3 } }
\dim_gset:Nn \g__zitie_background_bmargin_dim { \clist_item:nn {#1} { 4 } }
\fi:
} ,
colnum .bool_gset:N = \g__zitie_background_colnum_bool ,
rownum .bool_gset:N = \g__zitie_background_rownum_bool ,
colboxes .int_gset:N = \g__zitie_background_colboxes_int ,
rowboxes .int_gset:N = \g__zitie_background_rowboxes_int ,
framewidth .dim_gset:N = \g__zitie_background_framewidth_dim ,
frameheight .dim_gset:N = \g__zitie_background_frameheight_dim ,
boxwidth .dim_gset:N = \g__zitie_background_boxwidth_dim ,
boxheight .dim_gset:N = \g__zitie_background_boxheight_dim ,
onpaper .meta:n = { frameheight = \paperheight , framewidth = \paperwidth } ,
onpaper .value_forbidden:n = true ,
ontext .meta:n = { frameheight = \textheight , framewidth = \textwidth } ,
ontext .value_forbidden:n = true ,
xrange .code:n =
{
\dim_gset:Nn \g__zitie_background_x_left_dim { \clist_item:nn {#1} {1} }
\dim_gset:Nn \g__zitie_background_x_right_dim { \clist_item:nn {#1} {2} }
} ,
yrange .code:n =
{
\dim_gset:Nn \g__zitie_background_y_top_dim { \clist_item:nn {#1} {1} }
\dim_gset:Nn \g__zitie_background_y_bottom_dim { \clist_item:nn {#1} {2} }
} ,
frametype .tl_gset:N = \g__zitie_background_frametype_tl ,
linewidth .dim_gset:N = \g__zitie_background_linewidth_dim ,
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_set:nn { zitiebackgroundfillcolor } { white }
\cs_gset_nopar:Npn \__zitie_background_aux_color_fill: { }
}
{
\zitie_color_set:nn { zitiebackgroundfillcolor } {#1}
\cs_gset_nopar:Npn \__zitie_background_aux_color_fill: { \color_fill:n {#1} }
}
} ,
fillcolor* .code:n =
{
\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 ,
}
\keys_set:nn { zitie/background }
{
typeset = none,
margin = { 0pt, 0pt, 0pt, 0pt },
colnum = false,
rownum = false,
colboxes = 1,
rowboxes = 1,
onpaper,
xrange = { 0cm, \paperwidth } ,
yrange = { 0cm, \paperheight } ,
frametype = none,
linewidth = 0.4pt,
framecolor = black,
dashpattern = { },
}
\cs_new:Npn \zitie_set_background_frame:
{
\__zitie_background_calc:
\__zitie_background_construct:nnn { background }
{ \g__zitie_background_x_left_dim-.5\g__zitie_background_linewidth_dim }
{ -\g__zitie_background_y_bottom_dim-.5\g__zitie_background_linewidth_dim }
}
\cs_new:Npn \zitie_set_next_background_frame:
{
\__zitie_background_calc:
\__zitie_background_next_construct:nnn { background }
{ \g__zitie_background_x_left_dim-.5\g__zitie_background_linewidth_dim }
{ -\g__zitie_background_y_bottom_dim-.5\g__zitie_background_linewidth_dim }
}
\cs_new:Npn \zitie_unset_background_frame:
{ \__zitie_unset_background_frame:n { background } }
\cs_new:Npn \__zitie_background_calc:
{
\zitie_dim_gezero_dispatch:NNnnnn
\g__zitie_background_boxheight_dim
\g__zitie_background_boxwidth_dim
{ \use_none:nn } { \use_ii:nn } { \use_i:nn } { \use:nn }
{
\dim_set:Nn \g__zitie_background_boxheight_dim
{ \g__zitie_background_frameheight_dim/\g__zitie_background_rowboxes_int }
}
{
\dim_set:Nn \g__zitie_background_boxwidth_dim
{ \g__zitie_background_framewidth_dim/\g__zitie_background_colboxes_int }
}
}
\cs_new_protected:Npn \__zitie_background_construct:nnn #1#2#3
{
\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:nnnnn #1#2#3#4#5
{
\hook_gput_code:nnn { shipout/#1 } { zitie/background/#2 }
{ \put ( \dim_eval:n {#3} , \dim_eval:n {#4} ) {#5} }
}
\cs_new_protected:Npn \__zitie_background_next_construct:nnn #1#2#3
{
\hook_gput_next_code:nn { shipout/#1 }
{ \put ( \dim_eval:n {#2} , \dim_eval:n {#3} ) { \__zitie_background_construct_draw: } }
}
\cs_new:Npn \__zitie_unset_background_frame:n #1
{ \hook_gremove_code:nn { shipout/#1 } { zitie/background } }
\cs_new:Npn \__zitie_unset_background_frame:nn #1#2
{ \hook_gremove_code:nn { shipout/#1 } { zitie/background/#2 } }
\cs_new:Npn \zitie_background_frame_type:n #1 { __zitie_background_frame_ #1 :nnnnnn }
\cs_new:Npn \zitie_background_frame_type_c:n #1 { \use:c { __zitie_background_frame_ #1 :nnnnnn } }
\cs_new:Npn \__zitie_background_construct_draw:
{
\draw_begin:
\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 }
\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 - .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
\fp_new:N \l__zitie_background_tmpb_fp
\zitie_background_new_frame_construct:nn { none } { }
\zitie_background_new_frame_construct:nn { 口 }
{
\draw_path_grid:nnnn { #5 } { #6 } { #1 , #2 } { #3 , #4 }
\draw_path_use_clear:n { stroke }
}
\zitie_background_new_frame_construct:nn { 十 }
{
\dim_step_inline:nnnn {#1+.5#5} {#5} {#3}
{
\draw_path_moveto:n { ##1 , #2 }
\draw_path_lineto:n { ##1 , #4 }
}
\dim_step_inline:nnnn {#2+.5#6} {#6} {#4}
{
\draw_path_moveto:n { #1 , ##1 }
\draw_path_lineto:n { #3 , ##1 }
}
\draw_path_use_clear:n { stroke }
}
\zitie_background_new_frame_construct:nn { 田 }
{
\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 { × }
{
\int_set:Nn \l__zitie_background_tmpa_int { \fp_to_int:n { ceil( \dim_ratio:nn {(#3)-(#1)} {#5} ) } }
\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+\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+\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 }
}
\cs_new:Npn \__zitie_background_frame_construct_aux_cross:nnnnnnnn #1#2#3#4#5#6#7#8
{
\int_step_inline:nn {#7}
{
\draw_path_moveto:n { #1 , #2 + ##1*(#6) }
\draw_path_lineto:n { #1 + ##1*(#5) , #2 }
}
\int_step_inline:nn {#7}
{
\draw_path_moveto:n { #1+#7*(#5) , #2+#7*(#6)-##1*(#6) }
\draw_path_lineto:n { #1+#7*(#5)-##1*(#5) , #2+#7*(#6) }
}
\int_step_inline:nn {#7}
{
\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_lineto:n { #1+##1*(#5) , #2+#7*(#6) }
}
}
\zitie_background_new_frame_construct:nn { 米 }
{
\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 { 咪 }
{
\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_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 }
{ `background'~ unenable.~ You~ must~ use~ `enable-background'~ when~ loading~ this~ package. }
\keys_define:nn { zitie } { background .code:n = \msg_error:nn { zitie } { background } }
\fi:
\if_bool:N \g__zitie_enable_zhlipsum_bool
\RequirePackage { zhlipsum }
%%% module zhlipsum
\cs_new:Npn \__zitie_zhlipsum_paras:nn #1#2 { c__zhlipsum_ #1 @ #2 _tl }
\hook_new_pair:nn { zitie/framezhlipsum/before } { zitie/framezhlipsum/after }
\hook_new:n { zitie/framezhlipsum/paragraph }
\NewDocumentCommand \framezhlipsum { O{} m >{ \TrimSpaces } O{simp} }
{
\group_begin:
\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 }
\zitie_repeat:Nnn \l__zitie_repeat_int
{
\__zhlipsum_parse_par:nn {#3} {#2}
\seq_if_empty:NF \l__zhlipsum_par_num_seq
{
\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: }
}
}
{ \hook_use:n { zitie/repeat } }
\hook_use:n { zitie/framezhlipsum/after }
}
{ \__zhlipsum_error:nn { invalid-name } {#3} }
\group_end:
}
%%%
\else:
\msg_new:nnn { zitie } { zhlipsum }
{ `zhlipsum'~ unenable.~ You~ must~ use~ `enable-zhlipsum'~ option~ when~ loading~ this~ package. }
\keys_define:nn { zitie }
{ zhlipsum .code:n = \msg_error:nn { zitie } { zhlipsum } }
\fi:
|