summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/cjkpunct/setpunct/setpunct-macros.tex
blob: 2036a0878a56e2da5bb92a0a92eeb8c75549df59 (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
\documentclass{article}
\usepackage{CJK}
\begin{document}
\begin{CJK*}{GBK}{song}


\makeatletter
\pagestyle{empty}

\def\puncts{¡®¡°¡¸¡º¡²£¨£Û£û¡´¡¶¡¼¡¾¡ª¡­¡¢¡££¬£®£º£»£¡£¿£¥¡³£©£Ý£ý¡µ¡·¡½¡¿¡¯¡±¡¹¡»}

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

\newwrite\fdrubisha
\newwrite\fdspa
\newread\fdin

\def\makefile@rubisha{
\immediate\openout\fdrubisha=rubisha.tex\relax
\immediate\write\fdrubisha{\string\documentclass{article}}
\immediate\write\fdrubisha{\string\usepackage{CJK}       }
\immediate\write\fdrubisha{\string\textwidth 200pt      }
\immediate\write\fdrubisha{\string\textheight 200pt     }
\immediate\write\fdrubisha{\string\begin{document}       }
\immediate\write\fdrubisha{\string\begin{CJK*}{GBK}{song}}
\immediate\write\fdrubisha{\string\makeatletter          }
\immediate\write\fdrubisha{\string\pagestyle{empty}      }
\immediate\write\fdrubisha{\string\def\string\punctlist\sharp1\sharp2\lbrace
      \sharp1\sharp2\string\rule{0.5pt}{40pt}\string\newpage}
\immediate\write\fdrubisha{\string\rule{0.5pt}{20pt}\sharp1\sharp2\string\newpage}
\immediate\write\fdrubisha{\string\@ifnextchar[{\string\xeCJK@gobble@a}{\string\punctlist}\rbrace}
\immediate\write\fdrubisha{}
\immediate\write\fdrubisha{\string\def\string\xeCJK@gobble@a[]{}                       }
\immediate\write\fdrubisha{}
\immediate\write\fdrubisha{\string\CJKfamily{\CJKpunct@family}}
\immediate\write\fdrubisha{\string\fontsize{100pt}{120pt}\string\selectfont}
{
\let\protect\@unexpandable@protect
\immediate\write\fdrubisha{\string\punctlist\space\puncts []}
}
\immediate\write\fdrubisha{\string\newpage               }
\immediate\write\fdrubisha{\string\end{CJK*}             }
\immediate\write\fdrubisha{\string\end{document}}
\immediate\closeout\fdrubisha\relax}



\newcount\cnta
\newcount\cntb

\newcommand{\CJKpunctsetfamily}[1]{
  \edef\CJKpunct@family{#1}
  \makefile@rubisha
  \immediate\write18{pdflatex rubisha}
  \immediate\write18{\ghostscript}
  \epstobbox
  }

\catcode`\%=11\relax

\def\epstobbox{
  \cntb=0
  \def\CJKpunctspaces{}
  \immediate\openin\fdin=rubishb.tex\relax
  \ifeof\fdin
    \@latex@error{setpunct: file rubishb.tex not found}{}\relax
  \fi
  \loop
    \getxyspace
    \edef\CJKpunctspaces{\CJKpunctspaces\temp@xspace,}
    \getxyspace
    \edef\CJKpunctspaces{\CJKpunctspaces\temp@xspace,}
    \advance\cntb 1
  \ifnum\cntb<35\repeat
  \immediate\closein\fdin
  \immediate\write\fdspa{\string\def\string\CJKpunct@\CJKpunct@family
    @spaces{\CJKpunctspaces,,}\string\relax}}

\def\getxyspace{
  \read\fdin to\tempa
  \edef\:{\tempa}
  \expandafter\getleftupdimen\: {} %%BoundingBox: 1 1 0 0 \relax
  \ifnum\temp@xwidth<0\relax
    \read\fdin to\tempa
    \edef\:{\tempa}
    \expandafter\getleftupdimen\: {} %%BoundingBox: 1 1 0 0 \relax
  \fi
  \ifnum\temp@xwidth<1
    \@latex@error{error in setting punct bbox \tempa}{}\relax
  \fi
  \cnta=-\temp@xwidth\relax
  \advance\cnta 100\relax
  \ifnum\cnta<0
    \cnta=0\relax
  \fi
  \edef\temp@xspace{\the\cnta}}

\long\def\getleftupdimen#1%%BoundingBox: #2 #3 #4 #5 {
  \cnta=#4\relax
  \advance\cnta -#2\relax
  \edef\temp@xwidth{\the\cnta}
  \cnta=#5\relax
  \advance\cnta -#3\relax
  \edef\temp@yheight{\the\cnta}
  \gobblerest}

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

\immediate\openout\fdspa=CJKpunct.spa\relax

\setpunctfamilies

\immediate\closeout\fdspa
\end{CJK*}
\end{document}