summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/xelatex/xecjk/make-tbl-file/eps2tbl.tex
blob: 36ed4dd7ce43935f405b053bf5b181b3251171ca (plain)
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
% -*- coding: utf-8 -*-

\def\tblversion{2008/06/06}

\catcode`\%=11

\long\def\getleftspace#1BoundingBox: #2 #3 #4 #5{
\cnta=#4\relax
\advance\cnta -#2\relax
\gobblerest}

\long\def\gobblerest#1\relax{}


\def\getboundingbox#1{
\edef\epsfilename{#1}
\immediate\openin0=\epsfilename\relax
\ifeof0
  \@latex@error{file \epsfilename\space not found}{}\relax
\fi
\loop
   \read0 to\tempa
   \expandafter\getleftspace\tempa {} BoundingBox: 0 0 0 0 \relax
   \ifnum\the\cnta=0\repeat
\closein0}


\def\prepunct#1{
  \advance\cntb 1
  \ifnum\the\cntb<10
    \edef\epsfilename{rubish-0\the\cntb.eps}
  \else
    \edef\epsfilename{rubish-\the\cntb.eps}
  \fi
  \getboundingbox{\epsfilename}
  \advance\cnta -1993\relax
  \cnta=-\cnta\relax
  \divide\cnta 2\relax
  \expandafter\edef\csname  lspace@#1\endcsname{\the\cnta}
  \advance\cntb 1
  \ifnum\the\cntb<10
    \edef\epsfilename{rubish-0\the\cntb.eps}
  \else
    \edef\epsfilename{rubish-\the\cntb.eps}
  \fi
  \getboundingbox{\epsfilename}
  \advance\cnta -1993\relax
  \cnta=-\cnta\relax
  \divide\cnta 2\relax
  \expandafter\edef\csname  rspace@#1\endcsname{\the\cnta}
  \@ifnextchar[{\xeCJK@gobble@a}{\prepunct}}

\let\postpunct\prepunct
\def\xeCJK@gobble@a[]{}


\cntb=0
\input{punct-\CJKlanguage.tex}


\catcode`\%=14


%
%  bbox to tbl
%
%

\def\getfontname"#1"\relax{
  \edef\temp{\zap@space #1 \@empty}
  \edef\temp{\lowercase{\def\noexpand\@ttfontname{\temp}}}
  \temp}

\expandafter\getfontname\ttfontname\relax



\def\temp{}
\def\xeCJK@stringtoascii#1{
  \ifnum\number`#1>127\relax
    \edef\temp{\temp\number`#1}
  \else
    \edef\temp{\temp\string#1}
  \fi
  \@ifnextchar[{\xeCJK@gobbletwo}{\xeCJK@stringtoascii}}

\def\xeCJK@gobbletwo[]{}

\expandafter\xeCJK@stringtoascii\@ttfontname[]

\edef\@ttfontname{\temp}

\ifx\ttfontname@def\@empty
\else
  \edef\@ttfontname{\ttfontname@def}
\fi

\typeout{........fontname=\@ttfontname=}






\def\prepunct#1{
\expandafter\def\csname punct\the\cnta\endcsname{#1}
\expandafter\def\csname prepunct\the\cnta\endcsname{1}
\expandafter\def\csname prepunct@#1\endcsname{1}
\advance\cnta 1
\@ifnextchar[{\xeCJK@gobble@a}{\prepunct}}

\def\postpunct#1{
\expandafter\def\csname punct\the\cnta\endcsname{#1}
\expandafter\def\csname prepunct\the\cnta\endcsname{0}
\expandafter\def\csname prepunct@#1\endcsname{0}
\advance\cnta 1
\@ifnextchar[{\xeCJK@gobble@a}{\postpunct}}

\def\xeCJK@gobble@a[]{}

\cnta=0
\input{punct-\CJKlanguage.tex}

\edef\totalpuncts{\the\cnta}
\typeout{...number of punctuation: \totalpuncts}






\bgroup
\catcode`\%=11
\catcode`\{=11
\catcode`\}=11
\catcode`\(=1
\catcode`\)=2
\global\def\percent(%)
\global\def\lbrace({)
\global\def\rbrace(})
\egroup

%
%
% tbl 文件头
\def\outputtblfileheader{
  \immediate\write\fdout{\percent\space -*- coding: utf-8 -*-}
  \immediate\write\fdout{\percent\space }
  \immediate\write\fdout{\percent\space This is the file \tblfilename\space version
  \tblversion}
  \bgroup
  \count@\time
  \divide\count@ 60
  \count2=-\count@
  \multiply\count2 60
  \advance\count2 \time
  \edef\today{%
    \the\year/\two@digits{\the\month}/\two@digits{\the\day}%
    \space\space at\space
      \two@digits{\the\count@}:\two@digits{\the\count2}}
  \immediate\write\fdout{\percent\space This is a generated file [\today].}
  \egroup
  \immediate\write\fdout{\percent\space Do not modify it!}
  \immediate\write\fdout{\percent\space }
  \immediate\write\fdout{\percent\space }
  \immediate\write\fdout{\percent\space Note:}
  \immediate\write\fdout{\percent\space\space\space    1) 'rule' is the width of the \string\vrule\space prepended/appended to the char.}
  \immediate\write\fdout{\percent\space\space\space     2) 'flag,sp,st,sh' means 'flag,space,stretch,shrink', the glue is}
  \immediate\write\fdout{\percent\space\space\space   defined by:  'space'em plus 'stretch'em minus 'shrink'em}
  \immediate\write\fdout{\percent\space\space\space  (it is ignored when flag is not 1).}
  \immediate\write\fdout{\percent\space\space\space    3) 'nbflag' means 'nobreak flag'.}
  \immediate\write\fdout{\percent\space\space\space    4) For more information on the tbl file, we refer to the CCT package.}
  \immediate\write\fdout{\percent\space\space\space   set rule to '0', pre glue to '0,0,0,0', post glue to '0,-0.2,0,0.2'.}
  \immediate\write\fdout{\percent\space\space\space}
  \immediate\write\fdout{\percent\space\space\space                 pre \space\space\space\space\space\space\space              post}
  \immediate\write\fdout{\percent\space\space\space      ------------------------------  ------------------------------}
  \immediate\write\fdout{\percent\space\space\space                    glue \space\space\space\space\space\space              glue}
  \immediate\write\fdout{\percent\space\space\space     char  nbflag  rule    (flag,sp,st,sh) nbflag  rule    (flag,sp,st,sh)}
  \immediate\write\fdout{\percent\space\space\space     ----  ------------------------------  ------------------------------}
}

\def\setnumbers#1#2{
  \def#1{0.}
  \ifnum #2<0
    \def#1{-.}
    \cntb=-#2\relax
  \else
    \cntb=#2\relax
  \fi
  \ifnum\the\cntb>99\relax
    \edef#1{#1\the\cntb}
  \else
    \ifnum\the\cntb>9\relax
      \edef#1{#10\the\cntb}
    \else
      \edef#1{#100\the\cntb}
    \fi
  \fi}



\def\setspecialpuncts{
\edef\temp{\csname lspace@—\endcsname}
\cnta=\temp\relax
\edef\temp{\csname rspace@—\endcsname}
\advance\cnta\temp\relax
\advance\cnta 8\relax
\cnta=-\cnta
\setnumbers{\tempa}{\cnta}
\immediate\write\fdout{\string\UTFpunct\space
    —  \space\space 1\space\space   -.00  \space  0,0,0,0   \space\space      0\space\space
        0.00 \space   1,0,0,0\relax}
\immediate\write\fdout{\string\UTFpunct\space
    …  \space\space 1\space\space   -.00  \space  0,0,0,0   \space\space      0\space\space
      0.00 \space   1,0,0,0\relax}
\immediate\write\fdout{\string\UTFpunctbreak\space —{}\relax}
\immediate\write\fdout{\string\UTFpunctbreak\space …{}\relax}
\immediate\write\fdout{\string\UTFkern\space  —— \tempa\relax}
\immediate\write\fdout{\string\UTFkern\space  …… 0\relax}}

%
%  CCT style kernings and glues
%

\def\outputtblitem{
  \edef\punctchar{\csname punct\the\cntc\endcsname}
  \expandafter\ifnum\csname prepunct\the\cntc\endcsname=0\relax
    \edef\temp{\csname lspace@\punctchar\endcsname}
    \cnta=125
    \advance\cnta -\temp\relax
    \setnumbers{\tempa}{\cnta}
    \cntd=\cnta\relax
%
    \edef\temp{\csname rspace@\punctchar\endcsname}
    \cnta=125
    \advance\cnta -\temp\relax
    \setnumbers{\tempb}{\cnta}
    \advance\cntd\cnta\relax
    \cntd=-\cntd\relax
    \ifnum\the\cntd>200
      \advance\cntd -200\relax
      \def\tempd{.200}
      \def\tempe{.200}
    \else
      \def\tempd{.000}
      \def\tempe{.100}
    \fi
    \ifnum\the\cntd>0
      \setnumbers{\tempc}{\cntd}
    \else
      \def\tempc{0.000}
    \fi
    \immediate\write\fdout{\string\UTFpunct\space\punctchar
      \space\space 1 \space\tempa\space\space 0,0,0,0  \space 0  \space
      \tempb\space\space 1,\tempc,\tempd,\tempe\relax}
  \else
    \edef\temp{\csname lspace@\punctchar\endcsname}
    \cnta=125
    \advance\cnta -\temp\relax
    \setnumbers{\tempa}{\cnta}
    \cntd=\cnta\relax
    \edef\temp{\csname rspace@\punctchar\endcsname}
    \cnta=125
    \advance\cnta -\temp\relax
    \setnumbers{\tempb}{\cnta}
    \advance\cntd\cnta\relax
    \cntd=-\cntd\relax
    \ifnum\the\cntd>200
      \advance\cntd -200\relax
      \def\tempd{.200}
      \def\tempe{.200}
    \else
      \def\tempd{.000}
      \def\tempe{.100}
    \fi
    \ifnum\the\cntd>0
      \setnumbers{\tempc}{\cntd}
    \else
      \def\tempc{0.000}
    \fi
    \immediate\write\fdout{\string\UTFpunct\space\punctchar
      \space\space 0 \space\tempa\space\space 1,\tempc,\tempd,\tempe  \space\space 1  \space\space
      \tempb\space\space 0,0,0,0\relax}
  \fi}

\edef\tblfilename{\CJKlanguage c\@ttfontname.tbl}
\immediate\openout\fdout=\tblfilename
\outputtblfileheader
\immediate\write\fdout{\percent}
\immediate\write\fdout{\percent\space \space  \string\punctstyle{CCT}}
\immediate\write\fdout{\percent}
\immediate\write\fdout{\string\expandafter\string\gdef\string\csname\space
           xeCJK@\CJKlanguage c\@ttfontname\string\endcsname\lbrace\percent}

\cntc=0
\loop
  \outputtblitem
  \advance\cntc 1\relax
  \ifnum\the\cntc<\totalpuncts\relax\repeat

\setspecialpuncts
\immediate\write\fdout{\string\xeCJK@defkern\rbrace\percent}
\immediate\write\fdout{\string\endinput}
\immediate\closeout\fdout


\def\outputtblitem{
  \edef\punctchar{\csname punct\the\cntc\endcsname}
  \expandafter\ifnum\csname prepunct\the\cntc\endcsname=0\relax
    \edef\temp{\csname lspace@\punctchar\endcsname}
    \cnta=\sidespace\relax
    \advance\cnta -\temp\relax
    \setnumbers{\tempa}{\cnta}
    \cntd=\cnta\relax
%
    \edef\temp{\csname rspace@\punctchar\endcsname}
    \cnta=\sidespace\relax
    \advance\cnta -\temp\relax
    \setnumbers{\tempb}{\cnta}
    \advance\cntd\cnta\relax
    \advance\cntd\xeCJK@minusspace\relax
    \cntd=-\cntd\relax
    \ifcsname  xeCJK@addspace\punctchar\endcsname
      \edef\temp{\csname xeCJK@addspace\punctchar\endcsname}
      \advance\cntd\temp\relax
    \fi
    \expandafter\edef\csname postglue\punctchar\endcsname{\the\cntd}
    \expandafter\edef\csname preglue\punctchar\endcsname{0}
    \edef\tempd{\stretchspace}
    \edef\tempe{\shrinkspace}
    \ifnum\the\cntd>0
      \setnumbers{\tempc}{\cntd}
    \else
      \def\tempc{0.000}
    \fi
    \immediate\write\fdout{\string\UTFpunct\space\punctchar
      \space\space 1 \space\tempa\space\space 0,0,0,0  \space 0  \space
      \tempb\space\space 1,\tempc,\tempd,\tempe\relax}
  \else
    \edef\temp{\csname lspace@\punctchar\endcsname}
    \cnta=\sidespace\relax
    \advance\cnta -\temp\relax
    \setnumbers{\tempa}{\cnta}
    \cntd=\cnta\relax
%
    \edef\temp{\csname rspace@\punctchar\endcsname}
    \cnta=\sidespace\relax
    \advance\cnta -\temp\relax
    \setnumbers{\tempb}{\cnta}
    \advance\cntd\cnta\relax
    \advance\cntd\xeCJK@minusspace\relax
    \cntd=-\cntd\relax
    \expandafter\edef\csname preglue\punctchar\endcsname{\the\cntd}
    \expandafter\edef\csname postglue\punctchar\endcsname{0}
    \edef\tempd{\stretchspace}
    \edef\tempe{\shrinkspace}
    \ifnum\the\cntd>0
      \setnumbers{\tempc}{\cntd}
    \else
      \def\tempc{0.000}
    \fi
    \immediate\write\fdout{\string\UTFpunct\space\punctchar
      \space\space 0 \space\tempa\space\space 1,\tempc,\tempd,\tempe  \space\space 1  \space\space
      \tempb\space\space 0,0,0,0\relax}
  \fi}

%
%  全角式(又称全身式) 在全篇文章中除了两个符号连在一起时,前一符号用半角外,所有符号都用全角。
%
\def\sidespace{125}
\cntc=0
\def\xeCJK@minusspace{0}
\def\stretchspace{.100}
\def\shrinkspace{.020}
\expandafter\def\csname xeCJK@addspace。\endcsname{0}
\expandafter\def\csname xeCJK@addspace?\endcsname{0}
\expandafter\def\csname xeCJK@addspace!\endcsname{0}



\edef\tblfilename{\CJKlanguage q\@ttfontname.tbl}
\immediate\openout\fdout=\tblfilename
\outputtblfileheader

\immediate\write\fdout{\percent}
\immediate\write\fdout{\percent\space \space
    \string\punctstyle{quanjiao}}
\immediate\write\fdout{\percent}

\immediate\write\fdout{\string\expandafter\string\gdef\string\csname\space
           xeCJK@\CJKlanguage q\@ttfontname\string\endcsname\lbrace\percent}

\loop
  \outputtblitem
  \advance\cntc 1\relax
  \ifnum\the\cntc<\totalpuncts\relax\repeat

\setspecialpuncts

\def\punctpair#1#2{
  \edef\temp{\csname postglue#1\endcsname}
  \cnta=\temp\relax
  \edef\temp{\csname preglue#2\endcsname}
  \advance\cnta \temp\relax
  \advance\cnta -500\relax
  \ifnum\the\cnta>0
    \setnumbers{\tempa}{\cnta}
    \immediate\write\fdout{\string\UTFkern\space #1#2\space \tempa\relax}
  \else
    \immediate\write\fdout{\string\UTFkern\space #1#2\space 0\relax}
  \fi}

\punctpairs
\immediate\write\fdout{\rbrace\percent}
\immediate\write\fdout{\string\endinput}
\immediate\closeout\fdout

%
%
% 全部半角式,全部标点符号(破折号、省略号除外)都用半角版。这种排版多用于工具书。
\def\stretchspace{.100}
\def\shrinkspace{.000}
\cntc=0
\def\xeCJK@minusspace{500}
\def\sidespace{100}
\expandafter\def\csname xeCJK@addspace。\endcsname{0}
\expandafter\def\csname xeCJK@addspace?\endcsname{0}
\expandafter\def\csname xeCJK@addspace!\endcsname{0}


\edef\tblfilename{\CJKlanguage b\@ttfontname.tbl}
\immediate\openout\fdout=\tblfilename
\outputtblfileheader


\immediate\write\fdout{\percent}
\immediate\write\fdout{\percent\space \space  \string\punctstyle{banjiao}}
\immediate\write\fdout{\percent}
\immediate\write\fdout{\string\expandafter\string\gdef\string\csname\space
           xeCJK@\CJKlanguage b\@ttfontname\string\endcsname\lbrace\percent}
\loop
  \outputtblitem
  \advance\cntc 1\relax
  \ifnum\the\cntc<\totalpuncts\relax\repeat

\setspecialpuncts

\def\punctpair#1#2{
 \edef\temp{\csname postglue#1\endcsname}
 \cnta=\temp\relax
 \edef\temp{\csname preglue#2\endcsname}
 \advance\cnta \temp\relax
 \ifnum\the\cnta>0
   \setnumbers{\tempa}{\cnta}
   \immediate\write\fdout{\string\UTFkern\space #1#2\space \tempa\relax}
 \else
   \immediate\write\fdout{\string\UTFkern\space #1#2\space 0\relax}
 \fi}

\punctpairs
\immediate\write\fdout{\rbrace\percent}
\immediate\write\fdout{\string\endinput}
\immediate\closeout\fdout



%
%
% 开明式,凡表示一句结束的符号(如句号、问号、叹号等)用全角外,
%         其它标点符号全部用半角。标点组合时的首标点一律用半角。目前大多出版物用此法。
%
%
\def\stretchspace{.100}
\def\shrinkspace{.000}
\expandafter\def\csname xeCJK@addspace。\endcsname{500}
\expandafter\def\csname xeCJK@addspace?\endcsname{500}
\expandafter\def\csname xeCJK@addspace!\endcsname{500}
\cntc=0
\def\xeCJK@minusspace{500}
\def\sidespace{100}

\edef\tblfilename{\CJKlanguage k\@ttfontname.tbl}
\immediate\openout\fdout=\tblfilename

\outputtblfileheader


\immediate\write\fdout{\percent}
\immediate\write\fdout{\percent\space \space   \string\punctstyle{kaiming}}
\immediate\write\fdout{\percent}
\immediate\write\fdout{\string\expandafter\string\gdef\string\csname\space
           xeCJK@\CJKlanguage k\@ttfontname\string\endcsname\lbrace\percent}
\loop
  \outputtblitem
  \advance\cntc 1\relax
  \ifnum\the\cntc<\totalpuncts\relax\repeat

\setspecialpuncts

\def\punctpair#1#2{
 \edef\temp{\csname postglue#1\endcsname}
 \cnta=\temp\relax
 \edef\temp{\csname preglue#2\endcsname}
 \advance\cnta \temp\relax
 \ifcsname xeCJK@addspace#1\endcsname
   \expandafter\ifnum\csname prepunct@#2\endcsname=0\relax
     \advance\cnta -500\relax
   \fi
 \fi
 \ifnum\the\cnta>0
   \setnumbers{\tempa}{\cnta}
   \immediate\write\fdout{\string\UTFkern\space #1#2\space \tempa\relax}
 \else
   \immediate\write\fdout{\string\UTFkern\space #1#2\space 0\relax}
 \fi}



\punctpairs
\immediate\write\fdout{\rbrace\percent}
\immediate\write\fdout{\string\endinput}
\immediate\closeout\fdout