summaryrefslogtreecommitdiff
path: root/Master/dviout/GRAPHIC/LATEX2E/dviout.dtx
blob: 7b9e80b1bc287b776c019c4edc044dc9ad2624e7 (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
% \iffalse
%<*ignore>
% Copyright (C) 1995, Written by Kazunori ASAYAMA (TPM03937@pcvan.or.jp)
%               1997-2000, modified by SHIMA (oshima@ms.u-tokyo.ac.jp)
%               2000, modified by Matsuda & Otobe
%
% This file is a part of the package of `dviout'.
%
% It should be distributed *unchanged* and together with the package.
% A modified version of this file may be distributed, but it should
% be distributed with a *different* name.
%
%</ignore>
%<dviout>\ProvidesFile{dviout.def}
%<*driver>
\NeedsTeXFormat{LaTeX2e}\ProvidesFile{dviout.dtx}
%</driver>
                [2000/5/11 Driver file of `dviout' for LaTeX2e]
%<*driver>
\documentclass{ltxdoc}
\GetFileInfo{dviout.dtx}
\begin{document}
  \title{Driver file of \emph{dviout} for \LaTeXe}
  \author{Kazunori ASAYAMA\thanks{%
	\texttt{TPM03937@pcvan.or.jp} / %
	\texttt{GHF01532@niftyserve.or.jp}} \ and 
	SHIMA\thanks{%
	\texttt{dviout-admin@akagi.ms.u-tokyo.ac.jp}}}
  \date{\filedate}
  \maketitle
  \DocInput{dviout.dtx}
\end{document}
%</driver>
%\fi
%
% \CheckSum{344}
%
% \changes{v0.7}{2000/5/11}{Seventh version.}
%
% \StopEventually{}
%
% \section{Usage}
%
% See
% `|drivers.dtx|',
% `|graphics.dtx|',
% `|graphicx.dtx|' and
% `|grfguide.tex|'.
%
% \section{Implementation}
% \subsection{Color}
% Color specifications are mostly from `drivers.dtx' with
% |color1| option.
%
%    \begin{macrocode}
\def\c@lor@arg#1{%
  \dimen@#1\p@
  \ifdim\dimen@<\z@\dimen@\maxdimen\fi
  \ifdim\dimen@>\p@
    \PackageError{color}{Argument `#1' not in range [0,1]}\@ehd
  \fi}
\def\color@gray#1#2{%
  \c@lor@arg{#2}%
  \def#1{gray #2}%
  }
\def\color@cmyk#1#2{\c@lor@@cmyk#2\@@#1}
\def\c@lor@@cmyk#1,#2,#3,#4\@@#5{%
  \c@lor@arg{#1}%
  \c@lor@arg{#2}%
  \c@lor@arg{#3}%
  \c@lor@arg{#4}%
  \def#5{cmyk #1 #2 #3 #4}}
\def\color@rgb#1#2{\c@lor@@rgb#2\@@#1}
\def\c@lor@@rgb#1,#2,#3\@@#4{%
  \c@lor@arg{#1}%
  \c@lor@arg{#2}%
  \c@lor@arg{#3}%
  \def#4{rgb #1 #2 #3}}
\def\color@hsb#1#2{\c@lor@@hsb#2\@@#1}
\def\c@lor@@hsb#1,#2,#3\@@#4{%
  \c@lor@arg{#1}%
  \c@lor@arg{#2}%
  \c@lor@arg{#3}%
  \def#4{hsb #1 #2 #3}}
\def\color@named#1#2{\c@lor@@named#2,,\@@#1}
\def\c@lor@@named#1,#2,#3\@@#4{%
  \@ifundefined{col@#1}%
    {\PackageError{color}{Undefined color `#1'}\@ehd}%
  {\def#4{ #1}}%
  }
\def\current@color{ Black}
\def\define@color@named#1#2{%
  \expandafter\let\csname col@#1\endcsname\@nnil}%
%    \end{macrocode}
%
% If the driver supports the color, we output
% \begin{quote}
% |\special{color push |\meta{color-spec}|}|
% |\special{color pop}|
% \end{quote}
% in the \emph{DVI} files, which is compatible with \emph{dvips.def}.
%
%    \begin{macrocode}
%<*color>
\def\set@color{%
  \special{color push \current@color}\aftergroup\reset@color}
\def\reset@color{\special{color pop}}
\def\set@page@color{\special{background \current@color}}
%</color>
%
%    \end{macrocode}
%
% While if the driver does not support the color,
% ignore color specials (accept but not output).
%
%    \begin{macrocode}
%<*!color>
\def\set@color{}
\def\reset@color{}
\def\set@page@color{}
%</!color>
%    \end{macrocode}
%
% \subsection{Graphic file inclusion}
% \begin{macro}{\Ginclude@eps}
%
% Define the method of including EPS file.
% This macro generates special:
% \begin{quote}
% |PSfile=|"\meta{filename}" \meta{keywords}
% \end{quote}
% which is compatible to \emph{dvips.def}.
%
%    \begin{macrocode}
%<*dviout>
\def\Ginclude@eps#1{%
 \message{<#1>}%
  \bgroup
  \def\@tempa{!}%
  \dimen@=10\Gin@req@width
  \dimen@ii1bp%
  \divide\dimen@\dimen@ii
  \@tempdima=10\Gin@req@height
  \divide\@tempdima\dimen@ii
    \special{PSfile="#1"\space
      llx=\Gin@llx\space
      lly=\Gin@lly\space
      urx=\Gin@urx\space
      ury=\Gin@ury\space
      \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi
      \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi
      \ifGin@clip clip\fi}%
  \egroup}
%    \end{macrocode}
% \end{macro} ^^A \Ginclude@eps
%
% \begin{macro}{\Ginclude@image@common}
%
% Define the common macro used by |\Ginclude@|\meta{type}
% macros.
%
% This macro receive two arguments, the filename of image as |#1|,
% and the type of image as |#2|, and generates a special instruction
% `\meta{type}|file=|\meta{filename} \meta{keywords}' in the \emph{DVI} file.
%
%    \begin{macrocode}
\def\Ginclude@image@common#1#2{%
  \bgroup
  \def\@tempa{!}%
  \ifx\Gin@scaley\@tempa
    \let\Gin@scaley\Gin@scalex
  \else
    \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi
  \fi
  \raise\Gin@req@height\hbox{%
  \divide\Gin@req@width by 65781% convert sp to bp
  \divide\Gin@req@height by 65781% convert sp to bp
  \message{<#1 \number\Gin@req@width bp\space x%
		\space\number\Gin@req@height bp>}%
  \special{#2file=#1\space%
        hsize=\number\Gin@req@width\space%
        vsize=\number\Gin@req@height}}%
  \egroup}
%    \end{macrocode}
% \end{macro} ^^A \Ginclude@image@common
%
% \begin{macro}{\Ginclude@pbm}
% Generate special:
% \begin{quote}
% |pbmfile=|\meta{filename} \meta{keywords}
% \end{quote}
% with using `|\Ginclude@image@common|' macro.
% This special is supported by \emph{dviprt} and \emph{dviout}.
%    \begin{macrocode}
\def\Gread@pbm#1{%
  \begingroup
  \Gin@bboxfalse
  \catcode`\#=14
  \openin\@inputcheck=#1\relax
  \ifeof\@inputcheck\errmessage{#1: could not open.}\fi
  \read\@inputcheck to \pbm@line
  %% Here, checking magic number. Not implemented yet.
  \newif\ifpbm@not@bb
  \loop\ifeof\@inputcheck\errmessage{#1: unexpected EOF.}\fi
  \read\@inputcheck to \pbm@line
  \ifx\pbm@line\@empty\pbm@not@bbtrue\else\pbm@not@bbfalse\fi
  \ifpbm@not@bb\repeat
  \closein\@inputcheck
  \expandafter\pbm@decode@bb\pbm@line]
  \endgroup}
\def\pbm@decode@bb#1 #2]{%
  \Gin@bboxtrue%
  \gdef\Gin@llx{0}\gdef\Gin@lly{0}\gdef\Gin@urx{#1}\gdef\Gin@ury{#2}}
\def\get@pbm@magic P#1{#1}
\def\Ginclude@pbm#1{\Ginclude@image@common{#1}{pbm}}
%    \end{macrocode}
% \end{macro} ^^A \Ginclude@pbm
%
% \begin{macro}{\Ginclude@bmp}
% Generate special:
% \begin{quote}
% |bmpfile=|\meta{filename} \meta{keywords}
% \end{quote}
% with using `|\Ginclude@image@common|' macro.
% This special is supported by \emph{dviout for Windows}.
%
% `filename' may be any graphic file if it is supported by Susie's plug-in.
% The file with the name replaced the extension of `filename' by '.bb' 
% is searched to read the BoundingBox.
%
%    \begin{macrocode}
\def\Gread@bmp#1{%
  \begingroup
\@tempcnta\z@
\loop\ifnum\@tempcnta<\@xxxii
   \catcode\@tempcnta14 %
   \advance\@tempcnta\@ne
\repeat
\catcode127=14 %
  \let\do\@makeother\dospecials\catcode`\ 10 %
  \catcode\endlinechar5 %
  \immediate\openin\@inputcheck#1 %
  \ifeof\@inputcheck
    \@warning{File `#1' not found (which will be created by %
    `bmc' with -b option)}
  \else
     \Gread@true
     \let\@tempb\Gread@false
     \loop
       \read\@inputcheck to\@tempa
       \ifeof\@inputcheck
         \Gread@false
       \else
         \expandafter\Gread@find@bb\@tempa:.\\%
       \fi
     \ifGread@
     \repeat
    \immediate\closein\@inputcheck
  \fi
  \ifGin@bbox\else
    \@warning
      {Assume Bounding Box: 0 0 72 72}%
    \gdef\@gtempa{0 0 72 72 }%
  \fi
  \endgroup
  \expandafter\Gread@parse@bb\@gtempa\\}
\def\Ginclude@bmp#1{\Ginclude@image@common{#1}{bmp}}
%    \end{macrocode}
% \end{macro} ^^A \Ginclude@bmp
%
%    \begin{macrocode}
\def\Gin@extensions{.eps,.ps,.pbm,.gif,.bmp,.bmc,.ps.gz,.eps.gz}
%    \end{macrocode}
%
% Define the associations between the extentions and the image formats.
% If the format of image is PostScript, then read the file and
% determine its bounding box from DSC comments.
%
%    \begin{macrocode}
\@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
\@namedef{Gin@rule@.ps.gz}#1{{eps}{.bb}{#1}}
\@namedef{Gin@rule@.eps.gz}#1{{eps}{.bb}{#1}}
\@namedef{Gin@rule@.pbm}#1{{pbm}{.pbm}{#1}}
\@namedef{Gin@rule@*}#1{{bmp}{.bb}{#1}}
%    \end{macrocode}
%
% \subsection{Rotation}
% \begin{macro}{\Grot@start}
% This generates the same code in \emph{DVI} file as \emph{dvips.def}.
% Colored graphic images can only be rotated an integer multiple of
% 90 degree and they should be given by EPS files.
%    \begin{macrocode}
\def\Grot@start{%
 \special{ps: gsave currentpoint
 currentpoint translate \Grot@angle\space neg
 rotate neg exch neg exch translate}}
\def\Grot@end{\special{ps: currentpoint grestore moveto}}
%    \end{macrocode}
% \end{macro} ^^A \Grot@start
%
% \subsection{Scaling}
% \begin{macro}{\Gscale@start}
% This generates the same code in \emph{DVI} file as \emph{dvips.def}.
%    \begin{macrocode}
\def\Gscale@start{\special{ps: currentpoint currentpoint translate
  \Gscale@x\space \Gscale@y\space scale neg exch neg exch translate}}
\def\Gscale@end{\special{ps: currentpoint currentpoint translate
  1 \Gscale@x\space div 1 \Gscale@y\space div scale
  neg exch neg exch translate}}
%    \end{macrocode}
% \end{macro} ^^A \Gscale@start
%
% \subsection{PostScript code}
% PostScript code is supported only if it is completed to draw a graphic.
% \begin{macro}{\Gin@PS@raw}
% |#1| PostScript code; 
%    \begin{macrocode}
\def\Gin@PS@raw#1{\special{ps: #1}}
%    \end{macrocode}
% \end{macro} ^^A \Gin@PS@raw
% \begin{macro}{\Gin@PS@restore}
% |#1| PostScript code
%    \begin{macrocode}
\def\Gin@PS@restored#1{\special{" #1}}
%    \end{macrocode}
% \end{macro} ^^A \Gin@PS@restore
%
%    \begin{macrocode}
%</dviout>
%    \end{macrocode}
%
% \Finale