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
|
%D \module
%D [ file=font-chi,
%D version=1999.10.10,
%D title=\CONTEXT\ Font Macros,
%D subtitle=Chinese,
%D author=Hans Hagen,
%D date=\currentdate,
%D suggestions=Wang Lei,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\ifx\handlechineseunicodeglyph\undefined \else \endinput \fi
% NOT YET ADAPTED TO THE NEW FONT MACROS
%D The first implementation (most of which is here) is based on
%D the specific font layout. This is because not all glyphs are
%D available in uniciode, which means that we cannot use
%D unicode codepoints (yet); if it were possible we could use
%D just one table per input encoding.
\writestatus{loading}{ConTeXt Font Macros / Chinese}
% much will to typo-chi.tex
%D Still to be implemented:
%D
%D \startitemize
%D \item columns left right touch
%D \item distance = (hsize-n*bodyfontsize)/(n-1)
%D \item char grids
%D \item char tables
%D \item all kind of rotated combinations
%D \item hanging puctuation
%D \item a few more encodings
%D \item rotation list
%D \stopitemize
%M \setupbodyfont[chi]
%M
%M \def\WangLei{\purechinese{\uchar{205}{245}\uchar{192}{218}}}
\useencoding[chi]
%D When \WangLei\ sent me a mail asking if \CONTEXT\ was able
%D to support Chinese, I wasn't sure if the answer could be
%D yes. I knew that those languages, rich of glyphs, were
%D typeset by \TEX, so in principle it should be possible. I
%D asked or some more input and was told that there were
%D \LATEX\ styles regarding those languages. When I unzipped
%D the accompanying files, it became clear that I had to
%D implement support for Chinese from scratch. There was a
%D multitude of font, with rather unfamiliar encodings, a
%D large collection of files with |<|at least for me|>|
%D unknown purposes, and worse, the documentation was mainly
%D in Chinese.
%D
%D So, \WangLei\ and I started exchanging some emails and it
%D soon became clear that supporting Chinese was not that
%D complicated at all. It mostly came to dealing with handling
%D \UNICODE\ fonts. It also became clear that everything
%D Chinese took place in the upper region of the eight bit
%D character set. I wrote some macros that could process the
%D small \type {Hello World} file \WangLei\ had send me, and
%D after some bug fixes real Chinese came out. I started to
%D like the look and fel of Chinese glyphs, so on we went.
%D
%D The first comments concerned spacing. The mix of English
%D and Chinese demands some rather deliberate handling of
%D spacing. Breaking lines was not so much a problem, and
%D could be solved by adding some glue between Chinese glyphs.
%D
%D In the meantime had asked \WangLei\ for some language bound
%D labels and texts, and implementing these was rather
%D straightforward. But, there were still some issues to deal
%D with: conversion of numbers, date handling and index
%D sorting.
%D
%D I consider(ed) writing Chinese support to be a nice puzzle,
%D since I have to act on chinese \CONTEXT\ code, where I only
%D understand the \CONTEXT\ part. The drawings \WangLei\ made
%D me (in drawing packages) were of great help. Since I write
%D these modules from scratch, although I fall back on some
%D basic encoding and font modules, I consider them to be
%D rather clean. This cannot be said of all \CONTEXT\ font
%D modules \type {-)}.
\unprotect
%D Because Chinese glyphs have more height than the average
%D Latin glyph, and at the same time don't have much depth,
%D we adapt the scale.
%D
%D Before and after the glyph we have to deal with Chinese
%D spacing. Special attention is given to punctuation.
%D
%D \starttyping
%D [some short nice chinese text with () and english]
%D \stoptyping
%D
%D We insert a bit of stretch and introduce a signal to
%D keep track of previous characters. We use a similar
%D method in the units module, which may be a nice
%D introduction to using signals.
%D \macros
%D {chineseunicodescale, chineseinterglyphskip,
%D chineseunicodeheight, chineseunicodedepth, chinesespace}
%D
%D There are a few variables, that can be (re|)|set
%D depending on the current font. They default to:
% hm, why don't we use the normal unicodestrut mechanism?
\def\chineseunicodescale {1.00} % not smaller than .85
\def\chineseunicodeheight {1.00}
\def\chineseunicodedepth {1.00}
\def\chineseinterglyphskip{0pt \!!plus .05em \!!minus .01em}
\def\chinesesurroundskip {.25em \!!plus .15em \!!minus .05em}
%D We define a few signals. As said, another example of
%D using signals can be found in the module \type {m-units}.
\newsignal\chineseLsignal % left boundary character
\newsignal\chineseRsignal % right boundary character
\newsignal\chineseSsignal % any other character (symbol)
\chardef\chineseBstatus=0 % 0=unknown 1=left 2=right 3=chinese 4=nospace
\chardef\chineseAstatus=0 % 0=unknown 1=left 2=right 3=space
\chardef\chineseSstatus=0 % 0=unknown 1=left 2=right
\sfcode`(=2000 % a temporary hack
\def\chinesenobreak
{\relax
\iftracechinese
\nobreak
\kern-.5pt\color[red]{\vrule\!!width1pt}\kern-.5pt
\nobreak
\else
\nobreak
\fi}
\newif\ifcorrectchineseboundarychars
\def\chineseunskip
{\unskip\unskip\unskip\unskip}
\def\insertchineseglyph
{\iftracechinese\tracedchineseglyph\else\insertunicodeglyph\fi}
\newif\ifverticalchinese
\def\handlechineseunicodeglyph
{\ifinpagebody
\horizontalchineseunicodeglyph
\else\ifverticalchinese
\verticalchineseunicodeglyph
\else
\horizontalchineseunicodeglyph
\fi\fi}
% chinese classes: left=1|right=2|center=3
\chardef\plusfour=4
\def\analyzechineseunicodeglyph % beware, no zerocount !
{\chardef\chineseSstatus0\getvalue{uc\number\unicodeposition}\relax}
\def\analyzechineseunicodeenviroment
{% left
\ifx (\nextutoken \chardef\chineseAstatus\plusone \else
\ifx [\nextutoken \chardef\chineseAstatus\plusone \else
% right
\ifx ,\nextutoken \chardef\chineseAstatus\plustwo \else
\ifx .\nextutoken \chardef\chineseAstatus\plustwo \else
\ifx ?\nextutoken \chardef\chineseAstatus\plustwo \else
\ifx ;\nextutoken \chardef\chineseAstatus\plustwo \else
\ifx :\nextutoken \chardef\chineseAstatus\plustwo \else
\ifx !\nextutoken \chardef\chineseAstatus\plustwo \else
\ifx )\nextutoken \chardef\chineseAstatus\plustwo \else
\ifx ]\nextutoken \chardef\chineseAstatus\plustwo \else
% space
\ifx\nextutoken\blankspace \chardef\chineseAstatus\plusthree \else
\ifx\nextutoken\space \chardef\chineseAstatus\plusthree \else
\chardef\chineseAstatus\zerocount
% unknown
\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi \fi\fi
% maybe save the last skip?
\chardef\chineseBstatus\ifdim\lastskip=\zeropoint\plusfour\else\zerocount\fi
\ifdim\lastskip=\chineseLsignal \chardef\chineseBstatus\plusone \else
\ifdim\lastskip=\chineseRsignal \chardef\chineseBstatus\plustwo \else
\ifdim\lastskip=\chineseSsignal \chardef\chineseBstatus\plusthree \else
\scratchskip=\lastskip \unskip
\ifdim\lastskip=\chineseLsignal \chardef\chineseBstatus\plusone \else
\ifdim\lastskip=\chineseRsignal \chardef\chineseBstatus\plustwo \else
\ifdim\lastskip=\chineseSsignal \chardef\chineseBstatus\plusthree \else
\space\scratchskip=\lastskip \unskip
\setbox\scratchbox=\hbox\bgroup
(\space
\ifdim\lastskip=\scratchskip
\egroup \chardef\chineseBstatus\plusone
\else
\egroup
\ifdim\scratchskip=\zeropoint \chardef\chineseBstatus\plusfour \fi
\fi
\fi\fi\fi
\fi\fi\fi}
\def\horizontalchineseunicodeglyph
{\relax
\ifhmode\else\dontleavehmode\fi % added
\setunicodescale\chineseunicodescale % redundant
\setunicodestrut\chineseunicodeheight\chineseunicodedepth % redundant
\ifprocessingverbatim
\iftracechinese
\ruledhbox{\insertunicodeglyph}%
\else
\insertunicodeglyph
\fi
\else\ifx\nextutoken\relax
\insertunicodeglyph
\else
\analyzechineseunicodeglyph
\analyzechineseunicodeenviroment
\ifcase\chineseSstatus\relax
\ifcase\chineseBstatus\relax
\chineseunskip
\hskip\chinesesurroundskip % unknown
\or
\chineseunskip
\chinesenobreak % left
\or
\ifcorrectchineseboundarychars\else\chineseunskip\fi
\hskip\chineseinterglyphskip % right
\or
\chineseunskip
\hskip\chineseinterglyphskip % chinese
\or
% whatever
\fi
\insertchineseglyph
\ifcase\chineseAstatus\relax
\hskip\chineseinterglyphskip % unknown
\hskip\chinesesurroundskip
\ifcase\chineseSstatus
\hskip\chineseSsignal
\or
\hskip\chineseLsignal
\else
\hskip\chineseRsignal
\fi
\or
\hskip\chineseinterglyphskip % left
\chinesenobreak
\hskip\chineseLsignal
\or
\chinesenobreak % right
\hskip\chineseinterglyphskip
\chinesenobreak
\hskip\chineseRsignal
\or
\hskip\chineseinterglyphskip % space
\hskip\chinesesurroundskip
\hskip\chineseSsignal
\fi
\or % left
\ifcorrectchineseboundarychars
\let\unicodecharcommand\chineseleftcharcommand
\fi
\chineseunskip
\insertchineseglyph
\chinesenobreak
\hskip\chineseLsignal
\or % right
\ifcorrectchineseboundarychars
\let\unicodecharcommand\chineserightcharcommand
\fi
\chineseunskip
\chinesenobreak
\insertchineseglyph
\hskip\chineseRsignal
\else % center
\chineseunskip
\chinesenobreak
\insertchineseglyph
\hskip\chineseinterglyphskip
\hskip\chineseRsignal
\fi\fi
\aftergroup\ignorespaces % watch this
\fi}
\def\verticalchineseunicodeglyph
{\relax
\ifprocessingverbatim % to do
\horizontalchineseunicodeglyph
\else
\setunicodescale\chineseunicodescale % redundant
\setunicodestrut\chineseunicodeheight\chineseunicodedepth % redundant
\ifx\nextutoken\relax
\insertchineseglyph
\ifvmode % catches \hbox{...}, actually \hbox should be \vbox -)
\nointerlineskip
\fi
\allowbreak
\else
\analyzechineseunicodeglyph
\setbox\scratchbox\hbox to \hsize
{\hss
\ifcase\chineseSstatus\relax
\insertchineseglyph
\else % left / right
\setbox\scratchbox\hbox{\insertchineseglyph}%
\rotate[\c!rotation=270]{\box\scratchbox}%
\fi
\hss}%
\ht\scratchbox\unicodeheight\strutht
\dp\scratchbox\unicodedepth \strutdp
\ifvmode % catches \hbox{...}, actually \hbox should be \vbox -)
\nointerlineskip
\fi
\ifcase\prevchineseSstatus\relax
\ifnum\chineseSstatus=\plustwo \par\nobreak\else\allowbreak\fi
\or % left
\par\nobreak
\or % right
\ifnum\chineseSstatus=\plustwo \par\nobreak\else\allowbreak\fi
\fi
\global\chardef\prevchineseSstatus\chineseSstatus % pagebody ...
\box\scratchbox\par
\fi
\aftergroup\ignorespaces % watch this
\fi}
%D \macros
%D {setupchinese,startvertical,nochinese}
%D
%D The previous macros implement horizontal as well as
%D vertical typesetting. Vertical typesetting is implemented
%D on top of the multi||column routines.
\def\setupchinese
{\dodoubleargument\getparameters[\??vt]}
\def\startvertical
{\dosingleempty\dostartvertical}
\def\dostartvertical[#1]%
{\bgroup
\def\maxnofcolumns{25}%
\verticalchinesetrue
\global\chardef\prevchineseSstatus\zerocount
\let\nochinese\nochineseinvertical
\doif\@@vtn\v!fit
{\dimen0=\textwidth \advance\dimen0 \@@vtdistance
\dimen2=\bodyfontsize \advance\dimen2 \@@vtdistance
\divide\dimen0 \number\dimen2
\edef\@@vtn{\number\dimen0}}%
\startcolumns
[\c!direction=\@@vtdirection,
\c!balance=\@@vtbalance,
\c!distance=\@@vtdistance,
\c!n=\@@vtn,
#1]}
\def\stopvertical
{\stopcolumns
\egroup}
\setupchinese
[\c!direction=\v!left,
\c!balance=\v!no,
\c!n=\v!fit,
\c!distance=1.5\bodyfontsize]
%D We can set up vertical typesetting with \type
%D {\setupchinese}.
%D \macros
%D {nochineseinvertical}
%D
%D English (non chinese) text is typeset rotated:
\def\nochineseinvertical#1%
{\par
\setbox\scratchbox\hbox{\strut#1}
\getnoflines{\wd\scratchbox}
\setbox\scratchbox\hbox to \noflines\openlineheight
{\hss\box\scratchbox\hss}
\hbox to \hsize
{\hss
\rotate
[\c!rotation=270]
{\vbox to \ht\scratchbox{\vss\box\scratchbox\vss}}%
\hss}
\par}
%D \macros
%D {correctchineseboundarychars}
%D
%D Careful reading of the previous macro learns that we
%D treat left and right glyphs differently. When we say
%D
%D \starttyping
%D \correctchineseboundarycharstrue
%D \stoptyping
%D
%D For the moment correction in on by default.
\correctchineseboundarycharstrue
\def\chineserightcharcommand#1%
{\iftracechinese\ruledhbox\else\hbox\fi \!!to .5em{#1\hss}%
\hskip.25em\!!plus .25em\relax}%
\def\chineseleftcharcommand#1%
{\ifnum\chineseBstatus<4 \hskip.25em \!!plus .25em\relax\fi
\iftracechinese\ruledhbox\else\hbox\fi \!!to .5em{\hss#1}}%
% \def\chineserightcharcommand#1%
% {\setbox\scratchbox=\hbox{#1}%
% \scratchdimen=.5em
% \ifdim\wd\scratchbox>\scratchdimen
% \iftracechinese\ruledhbox\else\hbox\fi \!!to \scratchdimen
% {\box\scratchbox\hss}%
% \hskip.5\scratchdimen\!!plus.5\scratchdimen\relax
% \else
% \box\scratchbox
% \fi}
% \def\chineseleftcharcommand#1%
% {\setbox\scratchbox=\hbox{#1}%
% \scratchdimen=.5em
% \ifdim\wd\scratchbox>\scratchdimen
% \ifnum\chineseBstatus<4
% \hskip.5\scratchdimen\!!plus.5\scratchdimen\relax
% \fi
% \iftracechinese\ruledhbox\else\hbox\fi \!!to \scratchdimen
% {\hss\box\scratchbox}%
% \else
% \box\scratchbox
% \fi}
%D The long list of numbers in the previous macro identify the
%D characters where special care is needed for breaking lines.
%D A linebreak is not permitted before:
%D
%D \def\DoIt #1 #2 %
%D {\hbox{\hbox to 2em{\uchar{#1}{#2}\hss}#1 #2}\par}
%D
%D \startcolumns[n=5]
%D \DoIt 161 162 \DoIt 161 163 \DoIt 161 164 \DoIt 161 167 \DoIt 161 173
%D \DoIt 161 175 \DoIt 161 177 \DoIt 161 179 \DoIt 161 181 \DoIt 161 183
%D \DoIt 161 185 \DoIt 161 187 \DoIt 161 189 \DoIt 161 191 \DoIt 161 227
%D \DoIt 161 228 \DoIt 161 229 \DoIt 163 161 \DoIt 163 162 \DoIt 163 167
%D \DoIt 163 169 \DoIt 163 172 \DoIt 163 174 \DoIt 163 186 \DoIt 163 187
%D \DoIt 163 190 \DoIt 163 191 \DoIt 163 221 \DoIt 163 253
%D \stopcolumns
%D
%D A linebreak is not permitted after the following glyphs:
%D
%D \startcolumns[n=5]
%D \DoIt 161 174 \DoIt 161 176 \DoIt 161 178 \DoIt 161 180 \DoIt 161 182
%D \DoIt 161 184 \DoIt 161 186 \DoIt 161 188 \DoIt 161 190 \DoIt 163 168
%D \DoIt 163 219 \DoIt 163 224 \DoIt 163 251
%D \stopcolumns
%D \macros
%D {tracechinesetrue, showchinesetracelegend}
%D
%D When we say \type {\tracechinesetrue}, we get some
%D insight in the way \CONTEXT\ handles the Chinese glyphs.
%D The symbols and color used represent:
%D
%D \showchinesetracelegend
\newif\iftracechinese
\def\showchinesetracelegend
{\definetabulate[\s!dummy][|c|l|l|l|]%
\startdummy
\HL
\NC \bf key \NC \bf meaning \NC \bf glyph \NC \bf keys \NC\NR
\HL
\NC u \NC unknown character type \NC \color[green]{current} \NC u l r \NC\NR
\NC l \NC left boundary character \NC \color[red]{previous} \NC u l r c n \NC\NR
\NC r \NC right boundary character \NC \color[blue]{next} \NC u l r s \NC\NR
\NC c \NC chinese character \NC \NC \NC\NR
\NC s \NC following space \NC \NC \NC\NR
\NC n \NC no preceding space \NC \NC \NC\NR
\HL
\stopdummy}
\def\tracedchineseglyph
{\dontleavehmode
\ruledhbox
{\setbox\scratchbox\hbox{\insertunicodeglyph}%
\hbox to \wd\scratchbox
{\localcolortrue
\copy\scratchbox
\infofont
\hskip-\wd\scratchbox
\hbox to \wd\scratchbox
{\hss
\color[green]{\ifcase\chineseSstatus\relax u\or l\or r\fi}%
\hss}%
\hskip-\wd\scratchbox
\lower\dp\scratchbox\hbox to \wd\scratchbox
{\hss
\color[red]{\ifcase\chineseBstatus\relax u\or l\or r\or c\or n\fi}%
\hss
\color[blue]{\ifcase\chineseAstatus\relax u\or l\or r\or s\fi}%
\hss}}}}
%D The following example shows how tracing works.
%D
%D \start \tracechinesetrue
%D ÔÚÕâÒ»´Î¸üÐÂÖÐÎÒÃǽ«½éÉܶÔÖÐÎĵÄÖ§³Ö¡£µ±±¾ÎĵÄÖÐÎÄÒëÕßÍõÀÚ
%D ѯÎÊÎÒ \nochinese{\CONTEXT} ÊÇ·ñÄÜ´¦ÀíººÓïʱ£¬ËûÒѾ³¢ÊÔ¹ý
%D ÔËÐÐÏÖÓеĺ꼯£¬µ«ÊÇûÓеõ½½á¹û¡£ÕâÒâζ×ŶÔÖÐÎĵÄÖ§³Ö»¹Ã»
%D ÓÐʵÏÖ¡£
%D
%D ÔÚÕâÒ»(´Î¸üÐÂ)ÖÐÎÒÃÇ (½«½é) ÉܶÔÖÐÎĵÄÖ§³Ö¡£µ±±¾ÎĵÄÖÐÎÄÒë,
%D ÕßÍõÀÚѯÎÊÎÒ\nochinese{\CONTEXT}ÊÇ·ñÄÜ´¦ÀíººÓïʱ£¬ËûÒѾ³¢
%D ÊÔ¹ýÔËÐÐÏÖÓеĺ꼯£¬µ«ÊÇûÓеõ½½á¹û¡£ÕâÒâζ×ŶÔÖÐÎĵÄÖ§³Ö
%D »¹Ã»ÓÐʵÏÖ¡£.
%D \stop
%D Because fonts are defined each time a \UNICODE\ is
%D encountered |<|which is less inefficient than one would
%D imagine, because \TEX\ is optimized quite well in this
%D repect|>| we can define macros like this to take care of
%D font switches. When available, one can add definitions
%D for italic, slanted, bold fonts and combinations of these.
%D \macros
%D {chinesenumber}
%D
%D The chinese numbering systems rather straightforward. First
%D there are the digits:
%D
%D \starttabulate[|c|c|c|c|c|c|c|c|c|c|]
%D \NC 0 \NC 1 \NC 2 \NC 3 \NC 4 \NC 5 \NC 6 \NC 7 \NC 8 \NC 9 \NC\NR
%D \NC \chinesenumber{0} \NC \chinesenumber{1} \NC \chinesenumber{2}
%D \NC \chinesenumber{3} \NC \chinesenumber{4} \NC \chinesenumber{5}
%D \NC \chinesenumber{6} \NC \chinesenumber{7} \NC \chinesenumber{8}
%D \NC \chinesenumber{9} \NC\NR
%D \stoptabulate
%D
%D Apart from these numbers, we have dedicated representations
%D of some powers of~$10$.
%D
%D \starttabulate[|c|c|c|c|c|]
%D \NC 10 \NC 100 \NC 1000 \NC 10000 \NC 100000000 \NC\NR
%D \NC \chinesenumber{10} \NC \chinesenumber{100}
%D \NC \chinesenumber{1000} \NC \chinesenumber{10000}
%D \NC \chinesenumber{100000000} \NC\NR
%D \stoptabulate
%D
%D The number~12 is a combination of $1\times10+2$, or:
%D \chinesenumber {12}, while~22 becomes \chinesenumber {22}.
%D The numbers below 20 are treated a bit different, just like
%D numbers with series of $0$'s. So $2\times10$ comes out as
%D two glyphs, but $1\times10$ as one, because in the latter
%D case the~$1$ is redundant. The same is true for the powers
%D of~10.
%D
%D \starttabulate[|r|r|r|r|r|r|]
%D \NC 1 \NC \chinesenumber {1} \NC
%D 9 \NC \chinesenumber {9} \NC
%D 4 \NC \chinesenumber {4} \NC\NR
%D \NC 11 \NC \chinesenumber {11} \NC
%D 99 \NC \chinesenumber {99} \NC
%D 16 \NC \chinesenumber {16} \NC\NR
%D \NC 111 \NC \chinesenumber {111} \NC
%D 999 \NC \chinesenumber {999} \NC
%D 256 \NC \chinesenumber {256} \NC\NR
%D \NC 1111 \NC \chinesenumber {1111} \NC
%D 9999 \NC \chinesenumber {9999} \NC
%D 65536 \NC \chinesenumber {65536} \NC\NR
%D \stoptabulate
%D
%D The implementation is rather simple. For internal purposes,
%D we let zero expand to~0. The digits $0-9$ and numbers $10$,
%D $100$, $1000$, $10000$ and $100000000$ are hard coded.
% This was the first implementation, before \WangLei\ asked
% me to look into Big Five encoding, so, like everthing in
% \TEX, things become a bit more complicated, but also more
% versatile.
%
% \starttypen
% \def\chinesedigit#1%
% {\ifnum #1=100000000 \uchar{210}{218}% 100000000
% \else\ifnum #1=10000 \uchar{205}{242}% 10000
% \else\ifnum #1=1000 \uchar{199}{167}% 1000
% \else\ifnum #1=100 \uchar{176}{217}% 100
% \else\ifnum #1=10 \uchar{202}{174}% 10
% \else\ifcase#1 \uchar{193}{227}% 0
% \or \uchar{210}{187}% 1
% \or \uchar{182}{254}% 2
% \or \uchar{200}{253}% 3
% \or \uchar{203}{196}% 4
% \or \uchar{206}{229}% 5
% \or \uchar{193}{249}% 6
% \or \uchar{198}{223}% 7
% \or \uchar{176}{203}% 8
% \or \uchar{190}{197}% 9
% \fi\fi\fi\fi\fi\fi}
% \stoptypen
%D We will implement four methods, the one described earlier,
%D a derived one with capitalized characters, an extended
%D version of the first method, and a rather Arabic method.
%D
%D \starttabulate[|l|l|]
%D \HL
%D \NC \bf command \NC \bf number 39 \NC\NR
%D \HL
%D \NC \type{\normalchinesenumber} \NC \normalchinesenumber {39} \NC\NR
%D \NC \type{\capitalizedchinesenumber} \NC \capitalizedchinesenumber{39} \NC\NR
%D \NC \type{\arabicchinesenumber} \NC \arabicchinesenumber {39} \NC\NR
%D \NC \type{\extendedchinesenumber} \NC \extendedchinesenumber {39} \NC\NR
%D \HL
%D \stoptabulate
%D
%D We use a dirty trick to enable Chinese Capital Digits. In
%D the encoding vectors, we define these by appending a suffix
%D \type {*} to the digit, which in the following macro is
%D appended or not (by passing \type {\empty}).
\def\chinesedigit#1#2% #2: suffix, here * or \empty
{\udigit{\chineseencoding}{\number#1#2}}
% Normal Chinese Number
\def\normalchinesenumber#1%
{\expandafter\dochinesenumber\number#1\relax\empty}
\def\dochinesenumber#1#2\relax#3%
{\ifnum#1#2<10 % 1-10
\chinesedigit{#1}#3%
\else\ifnum#1#2<20 % 11-99
\chinesedigit{10}#3%
\dodochinesenumberA#2\relax#3%
\else
\dodochinesenumber#1#2\relax#3%
\fi\fi}
\def\dodochinesenumber#1#2\relax#3%
{\ifnum#1=0
\chinesedigit{0}#3%
\dododochinesenumber0#2\relax#3%
\else\ifnum#1#2<10 % 1-10
\chinesedigit{#1#2}#3%
\dodochinesenumberA#2\relax#3%
\else\ifnum#1#2<100 % 11-99
\dodochinesenumber#1\relax#3%
\chinesedigit{10}#3%
\dodochinesenumberA#2\relax#3%
\else\ifnum#1#2<1000 % 100-999
\dodochinesenumber#1\relax#3%
\chinesedigit{100}#3%
\dodochinesenumberA#2\relax#3%
\else\ifnum#1#2<10000 % 1000-9999
\dodochinesenumber#1\relax#3%
\chinesedigit{1000}#3%
\dodochinesenumberA#2\relax#3%
\else\ifnum#1#2<100000 % 10000-99999
\dodochinesenumber#1\relax#3%
\chinesedigit{10000}#3%
\dodochinesenumberA#2\relax#3%
\else\ifnum#1#2<1000000 % 100000-999999
\dodochinesenumberB#1#2\relax#3%
\else\ifnum#1#2<10000000 % 1000000-9999999
\dodochinesenumberC#1#2\relax#3%
\else\ifnum#1#2<100000000 % 10000000-99999999
\dodochinesenumberD#1#2\relax#3%
\else\ifnum#1#2<1000000000 % 10000000-99999999
\dochinesenumber#1\relax#3%
\chinesedigit{100000000}#3%
\dododochinesenumber#2\relax#3%
\else
\dodochinesenumberE#1#2\relax#3%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
\def\dododochinesenumber#1#2\relax#3%
{\ifnum#1=0
\ifnum0#2>0 \dododochinesenumber#2\relax#3\fi
\else
\dodochinesenumber#1#2\relax#3%
\fi}
\def\dodochinesenumberA#1\relax#2%
{\ifcase0#1 \else\dodochinesenumber#1\relax#2\fi}
\def\dodochinesenumberB#1#2#3\relax#4%
{\dochinesenumber#1#2\relax#4%
\chinesedigit{10000}#4%
\dododochinesenumber#3\relax#4}
\def\dodochinesenumberC#1#2#3#4\relax#5%
{\dochinesenumber#1#2#3\relax#5%
\chinesedigit{10000}#5%
\dododochinesenumber#4\relax#5}
\def\dodochinesenumberD#1#2#3#4#5\relax#6%
{\dochinesenumber#1#2#3#4\relax#6%
\chinesedigit{10000}#6%
\dododochinesenumber#5\relax#6}
\def\dodochinesenumberE#1#2#3\relax#4%
{\dochinesenumber#1#2\relax#4%
\chinesedigit{100000000}#4%
\dododochinesenumber#3\relax#4}
% Capitalized Chinese Number
\def\capitalizedchinesenumber#1%
{\expandafter\dochinesenumber\number#1\relax*}
% Extended Chinese Number
\def\extendedchinesenumber#1%
{\expandafter\doextendedchinesenumber\number#1\relax}
\def\doextendedchinesenumber#1#2\relax%
{\ifnum #1#2<20 % 0-19
\dochinesenumber#1#2\relax\empty
\else\ifnum#1#2<30 % 20-29
\chinesedigit{20}\empty
\ifcase#2\else\chinesedigit{2#2}\fi
\else\ifnum#1#2<40 % 30-39
\chinesedigit{30}\empty
\ifcase#2\else\chinesedigit{3#2}\fi
\else
\dochinesenumber#1#2\relax\empty
\fi\fi\fi}
% Arabic Chinese Number
\def\arabicchinesenumber#1%
{\expandafter\doarabicchinesenumber\number#1@\relax}
\def\doarabicchinesenumber#1#2\relax
{\if#1@\else
\chinesedigit{#1}\empty
\doarabicchinesenumber#2\relax
\fi}
% The short call:
\def\chinesenumber{\normalchinesenumber}
% \dorecurse{40}
% {\hbox
% {\processingverbatimtrue
% \hbox to 1cm{\hss\recurselevel}\quad
% \hbox to 3cm{\hss\strut\normalchinesenumber {\recurselevel}}\quad
% \hbox to 3cm{\hss\strut\capitalizedchinesenumber{\recurselevel}}\quad
% \hbox to 3cm{\hss\strut\arabicchinesenumber {\recurselevel}}\quad
% \hbox to 3cm{\hss\strut\extendedchinesenumber {\recurselevel}}\crlf}}
%D The next table demonstates the correctness of the
%D conversion macro.
%D
%D \startbuffer
%D \starttable[|l|l|l|l|l|l|]
%D \HL
%D \NC number \NC converter \NC hard coded \NC
%D number \NC converter \NC hard coded\NC \SR
%D \HL
%D \NC 1 \NC \chinesenumber{1} \NC Ò» \NC
%D 0 \NC \chinesenumber{0} \NC Áã \NC\FR
%D \NC 11 \NC \chinesenumber{11} \NC ʮһ \NC
%D 10 \NC \chinesenumber{10} \NC Ê® \NC\MR
%D \NC 111 \NC \chinesenumber{111} \NC Ò»°Ùһʮһ \NC
%D 100 \NC \chinesenumber{100} \NC Ò»°Ù \NC\MR
%D \NC 101 \NC \chinesenumber{101} \NC Ò»°ÙÁãÒ» \NC
%D 120 \NC \chinesenumber{120} \NC Ò»°Ù¶þÊ® \NC\MR
%D \NC 1111 \NC \chinesenumber{1111} \NC һǧһ°Ùһʮһ \NC
%D 1000 \NC \chinesenumber{1000} \NC һǧ \NC\MR
%D \NC 1001 \NC \chinesenumber{1001} \NC һǧÁãÒ» \NC
%D 1020 \NC \chinesenumber{1020} \NC һǧÁã¶þÊ® \NC\MR
%D \NC 11111 \NC \chinesenumber{11111} \NC Ò»Íòһǧһ°Ùһʮһ \NC
%D 10000 \NC \chinesenumber{10000} \NC Ò»Íò \NC\MR
%D \NC 10001 \NC \chinesenumber{10001} \NC Ò»ÍòÁãÒ» \NC
%D 10200 \NC \chinesenumber{10200} \NC Ò»ÍòÁã¶þ°Ù \NC\LR
%D \HL
%D \NC 111111 \NC \chinesenumber{111111} \NC ʮһÍòһǧһ°Ùһʮһ \NC
%D 100000 \NC \chinesenumber{100000} \NC Ê®Íò \NC\FR
%D \NC 1111111 \NC \chinesenumber{1111111} \NC Ò»°ÙһʮһÍòһǧһ°Ùһʮһ \NC
%D 1000000 \NC \chinesenumber{1000000} \NC Ò»°ÙÍò \NC\MR
%D \NC 11111111 \NC \chinesenumber{11111111} \NC һǧһ°ÙһʮһÍòһǧһ°Ùһʮһ \NC
%D 10000000 \NC \chinesenumber{10000000} \NC һǧÍò \NC\MR
%D \NC 111111111 \NC \chinesenumber{111111111} \NC Ò»ÒÚһǧһ°ÙһʮһÍòһǧһ°Ùһʮһ \NC
%D 100000000 \NC \chinesenumber{100000000} \NC Ò»ÒÚ \NC\MR
%D \NC 1111111111 \NC \chinesenumber{1111111111} \NC ʮһÒÚһǧһ°ÙһʮһÍòһǧһ°Ùһʮһ \NC
%D 1000000000 \NC \chinesenumber{1000000000} \NC Ê®ÒÚ \NC\LR
%D \HL
%D \stoptable
%D \stopbuffer
%D
%D \placetable{Some Chinese number examples.}{\getbuffer}
%D Although the conversion can be hooked into most commands
%D that deal with numbers |<|those familiar with \TEX\ macro
%D programming will notice that the macro if fully
%D expandable|>| in many cases Chinese documents use western
%D digits. So, in practice, the change that the next example
%D shows up, is minimal.
%D
%D \starttabulate[|r|r|c|]
%D \NC 2546 \NC \chinesenumber {2546} \NC \NC\NR
%D \NC 9258 \NC \chinesenumber {9258} \NC $+$ \NC\NR
%D \HL
%D \NC 11804 \NC \chinesenumber {11804} \NC \NC\NR
%D \stoptabulate
%D
%D While in arabic arithmics addition leads to more digits, in
%D Chinese the number of glyphs can (temporary) decrease.
%D Given that the number of people dealing with Chinese is
%D considerably larger than the number of latin speaking
%D people, a successor of \TEX\ definitely must provide a
%D \type {\chinesenumeral} primitive.
\defineconversion [c] [\normalchinesenumber]
\defineconversion [chinese] [\normalchinesenumber]
\defineconversion [nc] [\normalchinesenumber]
\defineconversion [normalchinese] [\normalchinesenumber]
\defineconversion [cc] [\capitalizedchinesenumber]
\defineconversion [capitalizedchinese] [\capitalizedchinesenumber]
\defineconversion [ec] [\extendedchinesenumber]
\defineconversion [extendedchinese] [\extendedchinesenumber]
\defineconversion [ac] [\arabicchinesenumber]
\defineconversion [arabicchinese] [\arabicchinesenumber]
%D Date conversion:
\defineconversion [cn] [\v!day] [\chinesenumber]
\defineconversion [cn] [\v!month] [\chinesenumber]
\defineconversion [cn] [\v!year] [\chinesenumber]
%D \macros
%D {SimChi, TraChi}
%D
%D These components enable us to construct dedicated Chinese
%D font switches, like:
\setupunicodefont
[chinese]
[ \c!scale=\chineseunicodescale,
\c!height=\chineseunicodeheight,
\c!depth=\chineseunicodedepth,
\c!strut=\v!yes,
\c!interlinespace=\v!yes,
\c!conversion=\chinesenumber,
\c!commands=\setchineseencoding, % needed for digits
\c!command=\handlechineseunicodeglyph]
%D For the moment, this encoding is implemented rather ugly. The
%D trick is to move the encoding value from the current font
%D definition to the \type {\chineseencoding} macro.
\let\chineseencoding\empty
\def\setchineseencoding % normally SomeChineseRegular
{\getfontfileparameters\unicodestyle
\ifx\currentfontfileencoding\undefined \else
\let\chineseencoding\currentfontfileencoding
\fi}
%D We could have said:
%D
%D \starttyping
%D \defineunicodefont
%D [SimChi]
%D [SimplifiedChinese]
%D [\c!scale=\chineseunicodescale,
%D \c!height=\chineseunicodeheight,
%D \c!depth=\chineseunicodedepth,
%D \c!conversion=\chinesenumber,
%D \c!commands=\setchineseencoding, % needed for digits
%D \c!command=\handlechineseunicodeglyph]
%D \stoptyping
%D
%D However, the former definitions is more general. Next we
%D map a few fonts:
\definefontsynonym [SimplifiedChineseRegular] [gbsong] [encoding=gbk]
\definefontsynonym [SimplifiedChineseSlanted] [gbsongsl] [encoding=gbk]
\definefontsynonym [SimplifiedChineseItalic] [gbsongsl] [encoding=gbk]
\definefontsynonym [SimplifiedChineseBold] [gbhei] [encoding=gbk]
\definefontsynonym [SimplifiedChineseBoldSlanted] [gbheisl] [encoding=gbk]
\definefontsynonym [SimplifiedChineseBoldItalic] [gbheisl] [encoding=gbk]
\definefontsynonym [TraditionalChineseRegular] [b5song] [encoding=big5]
\definefontsynonym [TraditionalChineseSlanted] [b5songsl] [encoding=big5]
\definefontsynonym [TraditionalChineseItalic] [b5songsl] [encoding=big5]
\definefontsynonym [TraditionalChineseBold] [b5hei] [encoding=big5]
\definefontsynonym [TraditionalChineseBoldSlanted] [b5heisl] [encoding=big5]
\definefontsynonym [TraditionalChineseBoldItalic] [b5heisl] [encoding=big5]
% we need to move this to typescripts
\doifelse \currentregime {utf} {
\definefontsynonym [SimplifiedChineseRegular] [ChineseRegular]
\definefontsynonym [SimplifiedChineseSlanted] [ChineseSlanted]
\definefontsynonym [SimplifiedChineseItalic] [ChineseItalic]
\definefontsynonym [SimplifiedChineseBold] [ChineseBold]
\definefontsynonym [SimplifiedChineseBoldSlanted] [ChineseBoldSlanted]
\definefontsynonym [SimplifiedChineseBoldItalic] [ChineseBoldItalic]
\definefontsynonym [TraditionalChineseRegular] [ChineseRegular]
\definefontsynonym [TraditionalChineseSlanted] [ChineseSlanted]
\definefontsynonym [TraditionalChineseItalic] [ChineseItalic]
\definefontsynonym [TraditionalChineseBold] [ChineseBold]
\definefontsynonym [TraditionalChineseBoldSlanted][ChineseBoldSlanted]
\definefontsynonym [TraditionalChineseBoldItalic] [ChineseBoldItalic]
\definefontsynonym [ChineseRegular] [uni-htsong-][encoding=cjk-uni]
\definefontsynonym [ChineseSlanted] [uni-htsong-][encoding=cjk-uni]
\definefontsynonym [ChineseItalic] [uni-htsong-][encoding=cjk-uni]
\definefontsynonym [ChineseBold] [uni-hthei-] [encoding=cjk-uni]
\definefontsynonym [ChineseBoldSlanted][uni-hthei-] [encoding=cjk-uni]
\definefontsynonym [ChineseBoldItalic] [uni-hthei-] [encoding=cjk-uni]
\loadmapfile[uni-htsong.map]
\loadmapfile[uni-htfs.map]
\loadmapfile[uni-hthei.map]
\loadmapfile[uni-htkai.map]
} {
\loadmapfile[gbk]
}
\defineunicodefont [SimChi] [SimplifiedChinese] [chinese]
\defineunicodefont [TraChi] [TraditionalChinese] [chinese]
%D We default to these so called Simplified Chinese fonts.
\SimChi
%D In addition to these fonts, we (pre|)|define some commonly
%D used fonts:
\definefontsynonym [SimplifiedChineseSongTiRegular] [gbsong] [encoding=gbk]
\definefontsynonym [SimplifiedChineseSongTiSlanted] [gbsongsl] [encoding=gbk]
\definefontsynonym [SimplifiedChineseSongTiBold] [gbsong] [encoding=gbk]
\definefontsynonym [SimplifiedChineseSongTiBoldSlanted] [gbsongsl] [encoding=gbk]
\definefontsynonym [TraditionalChineseSongTiRegular] [b5song] [encoding=big5]
\definefontsynonym [TraditionalChineseSongTiSlanted] [b5songsl] [encoding=big5]
\definefontsynonym [TraditionalChineseSongTiBold] [b5song] [encoding=big5]
\definefontsynonym [TraditionalChineseSongTiBoldSlanted] [b5songsl] [encoding=big5]
\definefontsynonym [SimplifiedChineseHeiTiRegular] [gbhei] [encoding=gbk]
\definefontsynonym [SimplifiedChineseHeiTiSlanted] [gbheisl] [encoding=gbk]
\definefontsynonym [SimplifiedChineseHeiTiBold] [gbhei] [encoding=gbk]
\definefontsynonym [SimplifiedChineseHeiTiBoldSlanted] [gbheisl] [encoding=gbk]
\definefontsynonym [TraditionalChineseHeiTiRegular] [b5hei] [encoding=big5]
\definefontsynonym [TraditionalChineseHeiTiSlanted] [b5heisl] [encoding=big5]
\definefontsynonym [TraditionalChineseHeiTiBold] [b5hei] [encoding=big5]
\definefontsynonym [TraditionalChineseHeiTiBoldSlanted] [b5heisl] [encoding=big5]
\definefontsynonym [SimplifiedChineseKaiTiRegular] [gbkai] [encoding=gbk]
\definefontsynonym [SimplifiedChineseKaiTiSlanted] [gbkaisl] [encoding=gbk]
\definefontsynonym [SimplifiedChineseKaiTiBold] [gbkai] [encoding=gbk]
\definefontsynonym [SimplifiedChineseKaiTiBoldSlanted] [gbkaisl] [encoding=gbk]
\definefontsynonym [TraditionalChineseKaiTiRegular] [b5kai] [encoding=big5]
\definefontsynonym [TraditionalChineseKaiTiSlanted] [b5kaisl] [encoding=big5]
\definefontsynonym [TraditionalChineseKaiTiBold] [b5kai] [encoding=big5]
\definefontsynonym [TraditionalChineseKaiTiBoldSlanted] [b5kaisl] [encoding=big5]
\definefontsynonym [SimplifiedChineseFangSongRegular] [gbfs] [encoding=gbk]
\definefontsynonym [SimplifiedChineseFangSongSlanted] [gbfssl] [encoding=gbk]
\definefontsynonym [SimplifiedChineseFangSongBold] [gbfs] [encoding=gbk]
\definefontsynonym [SimplifiedChineseFangSongBoldSlanted] [gbfssl] [encoding=gbk]
\definefontsynonym [TraditionalChineseFangSongRegular] [b5fs] [encoding=big5]
\definefontsynonym [TraditionalChineseFangSongSlanted] [b5fssl] [encoding=big5]
\definefontsynonym [TraditionalChineseFangSongBold] [b5fs] [encoding=big5]
\definefontsynonym [TraditionalChineseFangSongBoldSlanted] [b5fssl] [encoding=big5]
\definefontsynonym [SimplifiedChineseLiShuRegular] [gbli] [encoding=gbk]
\definefontsynonym [SimplifiedChineseLiShuSlanted] [gblisl] [encoding=gbk]
\definefontsynonym [SimplifiedChineseLiShuBold] [gbli] [encoding=gbk]
\definefontsynonym [SimplifiedChineseLiShuBoldSlanted] [gblisl] [encoding=gbk]
\definefontsynonym [TraditionalChineseLiShuRegular] [b5li] [encoding=big5]
\definefontsynonym [TraditionalChineseLiShuSlanted] [b5lisl] [encoding=big5]
\definefontsynonym [TraditionalChineseLiShuBold] [b5li] [encoding=big5]
\definefontsynonym [TraditionalChineseLiShuBoldSlanted] [b5lisl] [encoding=big5]
%D The following definitions provide us the commands to switch
%D to these fonts.
\defineunicodefont [SimSongTi] [SimplifiedChineseSongTi] [chinese]
\defineunicodefont [TraSongTi] [TraditionalChineseSongTi] [chinese]
\defineunicodefont [SimHeiTi] [SimplifiedChineseHeiTi] [chinese]
\defineunicodefont [TraHeiTi] [TraditionalChineseHeiTi] [chinese]
\defineunicodefont [SimKaiTi] [SimplifiedChineseKaiTi] [chinese]
\defineunicodefont [TraKaiTi] [TraditionalChineseKaiTi] [chinese]
\defineunicodefont [SimFangSong] [SimplifiedChineseFangSong] [chinese]
\defineunicodefont [TraFangSong] [TraditionalChineseFangSong] [chinese]
\defineunicodefont [SimLiShu] [SimplifiedChineseLiShu] [chinese]
\defineunicodefont [TraLiShu] [TraditionalChineseLiShu] [chinese]
% \definealternativestyle [ChineseTitleFont] [\bfd\SimKaiTi] []
%D \macros
%D {purechinese}
%D
%D Use this macro to suppress spacing around Chinese text.
\def\purechinese#1% evt geen rek
{\hskip\chineseSsignal\relax
#1\unskip\unskip\unskip
\hskip\chineseSsignal\relax}
%D \macros
%D {stillchinese}
%D
%D Use the next macro when you want the next item to be put
%D tight to the previous chinese character.
\def\stillchinese
{\hskip\chineseSsignal\relax}
%D \macros
%D {nochinese}
%D
%D When we want to be sure of non||Chinese inline text,
%D we can package the for instance english text in \type
%D {\nochinese}.
\def\nochinese#1%
{\unskip\unskip\unskip
\hskip\chinesesurroundskip
\hskip\chineseinterglyphskip\relax
#1%
\hskip\chineseinterglyphskip\relax
\hskip\chinesesurroundskip
\ignorespaces}
%D \macros
%D {chisize}
%D
%D Chinese font sizes are specified in a different way,
%D using positive and negative numbers:
\def\chisize#1%
{\ifnum#11<0 % a trick to catch -0
\ifcase#1\space36\or24\or18\or15\or12\or9\or\else6.5\fi
\else
\ifcase#1\space42\or26\or22\or16\or14\or10.5\or7.5\or5.5\else5\fi
\fi pt}
%D So:
%D
%D \startbuffer
%D [\chisize{-1}] [\chisize{7}] [\chisize{+4}]
%D \stopbuffer
%D
%D \typebuffer
%D
%D gives:
%D
%D \getbuffer
%D
%D The full range of sizes is:
%D
%D \starttabulate[|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|]
%D \NC 8 \NC 7 \NC -6 \NC 6 \NC
%D -5 \NC 5 \NC -4 \NC 4 \NC
%D -3 \NC 3 \NC -2 \NC 2 \NC
%D -1 \NC 1 \NC -0 \NC 0 \NC\NR
%D \NC\chisize {8}\NC\chisize{7}\NC\chisize{-6}\NC\chisize{6}\NC
%D \chisize{-5}\NC\chisize{5}\NC\chisize{-4}\NC\chisize{4}\NC
%D \chisize{-3}\NC\chisize{3}\NC\chisize{-2}\NC\chisize{2}\NC
%D \chisize{-1}\NC\chisize{1}\NC\chisize{-0}\NC\chisize{0}\NC\NR
%D \stoptabulate
%D Now it's time for some real Chinese. This example
%D also shows that font switching is supported.
%D
%D \startnarrower
%D \midaligned{\tfd Ë®µ÷¸èÍ·}
%D \blank
%D \midaligned{\tfb ±û³½ÖÐÇ»¶Òû´ïµ©£¬´ó×í×÷´Ëƪ£¬¼æ»³×ÓÓÉ¡£}
%D \blank
%D \midaligned{\tfb ËÕéø}
%D \blank
%D Ã÷Ô¼¸Ê±ÓУ¿°Ñ¾ÆÎÊÇàÌì¡£²»ÖªÌìÉϹ¬ãÚ£¬½ñϦÊǺÎÄꣿÎÒÓû³Ë·ç¹éÈ¥
%D £¬ÓÖ¿ÖÇíÂ¥ÓñÓ¸ß´¦²»Ê¤º®¡£ÆðÎèŪÇåÓ°£¬ºÎËÆÔÚÈ˼䣿
%D \blank
%D תÖì¸ó£¬µÍ»§£¬ÕÕÎÞÃß¡£²»Ó¦Óкޣ¬ºÎÊÂÆ«Ïò±ðʱԲ£¿ÈËÓб¯»¶ÀëºÏ£¬
%D ÔÂÓÐÒõÇçԲȱ£¬´ËʹÅÄÑÈ«¡£µ«Ô¸È˳¤¾Ã£¬Ç§Àﹲ濾ꡣ
%D \stopnarrower
%D
%D The english translation is:
%D
%D \startnarrower
%D \midaligned{\tfd Tune: Prelude to the Melody of Water}
%D \blank
%D \midaligned{\tfb On the night of the Mid||Autumn Festival of
%D 1076, I drank happily till dawn and wrote this in my cups
%D while thinking of Zi||you.}
%D \blank
%D \midaligned{\tfb Su Shi}
%D \blank
%D How long will the bright moon appear? Wine||cup in hand, I
%D ask the sky. I do not know waht time of year it would be
%D tonight in the palace on high. Riding the wind, there I
%D would fly, yet I fear the crystal palace would be far too
%D high and cold for me. I rise and dance, with my shadow I
%D play. On high as on earth, would it be as gay?
%D \blank
%D The moon goes round the mansion red though gauze||draped
%D windows soft to shed her light upon the sleepless bed.
%D Against man she should have no spite. Why then when people
%D part is she oft full and bright? Men have sorrow and joy,
%D they part or meet again; The moon may be bright or dim, she
%D may wax or wane. There has been nothing perfect since the
%D olden days. So let us wish that man will live long as he
%D can! Though miles apart, we'll share the beauty she
%D displays.
%D \stopnarrower
%D This package is written in the city of Hasselt, a pretty
%D small town in the |<|compared to China real small|>|
%D Netherlands. Like most dutch cities, even this small one
%D has a chinese restaurant, run by chinese, speaking chinese,
%D and |<|indeed|>| writing chinese. Eating there will never
%D be the same, since now I can at least pretend to know the
%D glyphs all around the place. The numbers should pose me no
%D problems, but I fear I will never manage to recognize those
%D scribles they draw on their pads when thay take your order.
%D To make our lives more easy, we put it here (too):
\setuptyping[\c!tab=\v!no]
\protect \endinput
|