Debian Codegraph @

texmf-dist/tex/plain/js-misc/xfig.tex

raw
1 % $Id: xfig.tex,v 1.4 1995/05/07 16:52:05 schrod Exp $
2 %------------------------------------------------------------
3 % Hacked together by Joachim Schrod <[email protected]>
4 % Put into public domain.
5
6 %
7 % Support for xfig pictures in plain TeX
8 % orginally written for transfig 2.1.7
9 % support last checked for transfig 3.1.3
10 %
11
12
13 % USAGE:
14 %
15 % To include xfig figures in plain TeX documents, just input these
16 % macros and then input the (La)TeX file you got by exporting your
17 % figure as `LaTeX picture' or by calling fig2dev with option `-L
18 % latex'. No other ``language'' is supported by these macros; in
19 % particular, `Combined PS/LaTeX' is not supported.
20
21 % You can select the used types for text by redefining some macros:
22 % \FigFontType<type> (with <type> equal `rm', `bf', `it', `sf', or
23 % `tt') must expand to the external font name that's used for the
24 % respective xfig font selection.
25 % \FigFontDefault specifies the font that's used for the `Default'
26 % font selection. That macro is only accessed if you use the new xfig,
27 % or if you repaired the no-NFSS code of fig2dev (in texfonts.h, see
28 % comments at \xfig@bindSetFigFont implementation below).
29 %
30 % At the start of each figure \pictureHook is evaluated, you might
31 % want to bind that to some code that does document-specific setup.
32 % Each figure is set in a group, so you can rebind other control
33 % sequences in that hook.
34
35
36 % ------------------------------------------------------------
37
38 % IMPLEMENTATION NOTES:
39 %
40 % The macros might not work in all circumstances, it's updated and improved
41 % by need...
42 %
43 % In particular:
44 % -- The font selection in \SetFigFont could be improved.
45 % -- The environment code (\begin/\end) is very rough and should
46 % check for erroneous input.
47
48
49 % Code structure:
50 %
51 % After general setup, code from DEK that implements most parts of
52 % LaTeX's picture environment is used. Then we add definitions for the
53 % missing and xfig-specific tags.
54 %
55 % In Emacs, each section starts on a new page.
56
57
58 % ============================================================
59
60 % standard setup:
61
62 \ifx \CatEscape\undefined
63 \chardef\CatEscape=0
64 \chardef\CatOpen=1
65 \chardef\CatClose=2
66 \chardef\CatIgnore=9
67 \chardef\CatLetter=11
68 \chardef\CatOther=12
69 \chardef\CatActive=13 % \active of plain.tex
70 \chardef\CatInvalid=15
71
72 \chardef\CatAtCode=\catcode`\@
73 \chardef\CatUsCode=\catcode`\_
74 \fi
75
76 \catcode`\@=\CatLetter % top level macro file
77
78 \begingroup
79 \catcode`\$=\CatIgnore
80 \catcode`\:=\CatIgnore
81 \message{xfig pictures, $Revision: 1.4 $}
82 \endgroup
83
84
85 % This macro file allocates registers and might be read in multiple
86 % times, in groups. (Actually, this occured for the first time when we
87 % wanted to use xfig pictures in Texinfo documents. There they are
88 % typeset in a `tex' environment, and xfig is read in anew for each
89 % figure.) As all register allocations are globally, we define some
90 % macros that help us to define them only once.
91
92 \def\xfig@newskip#1{%
93 \ifx #1\undefined \csname newskip\endcsname #1\fi
94 }
95 \def\xfig@newdimen#1{%
96 \ifx #1\undefined \csname newdimen\endcsname #1\fi
97 }
98 \def\xfig@newcount#1{%
99 \ifx #1\undefined \csname newcount\endcsname #1\fi
100 }
101 \def\xfig@newbox#1{%
102 \ifx #1\undefined \csname newbox\endcsname #1\fi
103 }
104
105
106 % ============================================================
107
108 %% First comes an implementation of the picture environment's features,
109 %% by the Grand Wizard of TeX Arcana himself. This is from picture.tex,
110 %% I deleted the \cpic macro and the squines. \makebox did not support
111 %% position specifiers, I substituted the definition by the one from
112 %% LaTeX2e. In addition, all register allocations are made with the
113 %% macros defined above.
114
115 % --------------------------------------------------
116
117 % Pictures (a subset of \LaTeX's conventions, plus squines)
118
119 %% [start of change to DEK's code]
120 %%
121 %% At's catcode is changed above already.
122 %% Allocation info for registers should go to log file.
123
124 % \chardef\CatcodeAt=\catcode`\@
125 % \catcode`\@=11 % enable private control sequences
126 % \def\wlog#1{} % don't put allocation info into the log
127
128 %% [end of change]
129
130 \xfig@newskip\hsssglue \hsssglue=0pt plus 1fill minus 1fill
131 \def\hsss{\hskip\hsssglue}
132
133 \xfig@newdimen\unitlength \xfig@newdimen\linethickness
134 \xfig@newdimen\@picheight \xfig@newdimen\@xdim \xfig@newdimen\@ydim \xfig@newdimen\@len
135 \xfig@newdimen\@save
136 \xfig@newcount\@multicount \xfig@newcount\@xarg \xfig@newcount\@yarg
137 \xfig@newbox\@picbox \xfig@newbox\@mpbox
138
139 \font\tenln=line10 \font\tenlnw=linew10
140 \font\tencirc=lcircle10 \font\tencircw=lcirclew10
141
142 \xfig@newdimen\@halfwidth
143
144 \def\thinlines{\let\linefont=\tenln \let\circlefont=\tencirc
145 \linethickness=\fontdimen8\linefont \@halfwidth .5\linethickness}
146 \def\thicklines{\let\linefont=\tenlnw \let\circlefont=\tencircw
147 \linethickness=\fontdimen8\linefont \@halfwidth .5\linethickness}
148 \thinlines
149
150 \def\beginpicture(#1,#2)(#3,#4){\@picheight=#2\unitlength
151 \setbox\@picbox=\hbox to#1\unitlength\bgroup \let\line=\@line
152 \kern-#3\unitlength \lower#4\unitlength\hbox\bgroup\ignorespaces}
153 \def\endpicture{\egroup\hss\egroup
154 \ht\@picbox=\@picheight \dp\@picbox=\z@
155 \leavevmode\box\@picbox}
156
157 \def\put(#1,#2)#3{\raise#2\unitlength\rlap{\kern#1\unitlength #3}\ignorespaces}
158
159 \def\multiput(#1,#2)(#3,#4)#5#6{\@multicount=#5\relax
160 \@xdim=#1\unitlength \@ydim=#2\unitlength \setbox\@mpbox=\hbox{#6}%
161 \loop\ifnum\@multicount>0
162 \raise\@ydim\rlap{\kern\@xdim \unhcopy\@mpbox}%
163 \advance\@xdim#3\unitlength \advance\@ydim#4\unitlength
164 \advance\@multicount\m@ne \repeat\ignorespaces}
165
166 \def\@ifnextchar#1#2#3{\let\@tempe=#1\def\@tempa{#2}\def\@tempb{#3}\futurelet
167 \@tempc\@ifnch}
168 \def\@ifnch{\ifx \@tempc \@sptoken \let\@tempd\@xifnch
169 \else \ifx \@tempc \@tempe\let\@tempd\@tempa\else\let\@tempd\@tempb\fi
170 \fi \@tempd}
171
172 %% [start of change to DEK's code]
173 %%
174 %% \makebox is called with an optional argument, the position
175 %% specifier. The code below is copied from the LaTeX2e beta-test
176 %% release.
177
178 \def\makebox(#1,#2){%
179 \@ifnextchar[{\@makebox(#1,#2)}{\@makebox(#1,#2)[]}}
180
181 \def\@nnil{\@nil}
182 \def\@fornoop#1\@@#2#3{}
183 \def\@tfor#1:=#2\do#3{\def\@fortmp{#2}\ifx\@fortmp\empty \else
184 \@tforloop#2\@nil\@nil\@@#1{#3}\fi}
185 \def\@tforloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
186 \let\@nextwhile\@fornoop \else
187 #4\relax\let\@nextwhile\@tforloop\fi\@nextwhile#2\@@#3{#4}}
188
189 \long\def\@makebox(#1,#2)[#3]#4{%
190 \vbox to#2\unitlength
191 {\let\mb@b\vss \let\mb@l\hss\let\mb@r\hss
192 \let\mb@t\vss
193 \@tfor\@tempa :=#3\do{%
194 \if s\@tempa
195 \let\mb@l\relax\let\mb@r\relax
196 \else
197 \expandafter\let\csname mb@\@tempa\endcsname\relax
198 \fi}%
199 \mb@t
200 \hbox to #1\unitlength{\mb@l #4\mb@r}%
201 \mb@b
202 \kern\z@}}
203
204 %% [end of change]
205
206 \newif\ifneg
207 \def\@line(#1,#2)#3{\@xarg=#1 \@yarg=#2 \@len=#3\unitlength \leavevmode
208 \ifnum\@xarg<0 \reverseline \else \negfalse \@ydim=\z@\fi
209 \ifnum\@xarg=0 \@vline
210 \else\ifnum\@yarg=0 \@hline \else\@sline\fi\fi
211 \ifneg\kern-\@len\else\@save=\@ydim\fi}
212 \def\reverseline{\negtrue \kern-\@len \@xarg=-\@xarg
213 \@ydim=\@len \multiply\@ydim\@yarg \divide\@ydim\@xarg \@yarg=-\@yarg}
214
215 \def\@hline{\vrule height.5\linethickness depth.5\linethickness width\@len}
216 \def\@vline{\kern-.5\linethickness\vrule width\linethickness
217 \ifnum\@yarg<0 height\z@ depth\else depth\z@ height\fi\@len
218 \kern-.5\linethickness}
219
220 \def\@sline{\setbox\@picbox=\hbox{\linefont \count@=\@xarg \multiply\count@ 8
221 \ifnum\@yarg>0 \advance\count@\@yarg \advance\count@-9
222 \else \advance\count@-\@yarg \advance\count@ 55 \fi \char\count@}%
223 \ifnum\@yarg<0 \@picheight=-\ht\@picbox \advance\@ydim\@picheight
224 \else \@picheight=\ht\@picbox \fi
225 \@xdim=\wd\@picbox \@save=\@ydim
226 \loop\ifdim\@xdim<\@len \raise\@ydim\copy\@picbox
227 \advance\@xdim\wd\@picbox \advance\@ydim\@picheight \repeat
228 \advance\@xdim-\@len \kern-\@xdim
229 \multiply\@xdim\@yarg \divide\@xdim\@xarg \advance\@ydim-\@xdim
230 \raise\@ydim\box\@picbox}
231
232 \def\vector(#1,#2)#3{\@line(#1,#2){#3}%
233 \ifnum\@xarg=0 \@vvector \else\ifnum\@yarg=0 \@hvector \else\@svector\fi\fi}
234 \def\@hvector{\ifneg\rlap{\linefont\char27}\else
235 \smash{\llap{\linefont\char45}}\fi} % we have to smash because of font bug
236 \def\@vvector{\ifnum\@yarg<0 \raise-\@len\rlap{\linefont\char63}%
237 \else\setbox\@picbox=\rlap{\linefont\char54}\advance\@len-\ht\@picbox
238 \raise\@len\box\@picbox\fi}
239
240 \def\@svector{\setbox\@picbox=\hbox to\z@{\linefont
241 \ifnum\@yarg<0 \count@=55 \@yarg=-\@yarg \else\count@=-9 \fi
242 \ifneg\multiply\@xarg16 \multiply\@yarg2
243 \else\hss % \llap
244 \ifnum\@xarg>2 \multiply\@xarg9 \multiply\@yarg2 \advance\count@29
245 \else\ifnum\@yarg>2 \multiply\@xarg16 \multiply\@yarg9 \advance\count@-20
246 \else\multiply\@xarg24 \multiply\@yarg3 \fi\fi\fi
247 \advance\count@\@xarg \advance\count@\@yarg \char\count@
248 \ifneg\hss\fi}% \rlap
249 \raise\@save\box\@picbox}
250
251 \def\disk#1{\@len=#1\unitlength \count@='160 \@diskcirc}
252 \def\circle#1{\@len=#1\unitlength \count@='140 \@diskcirc}
253 \def\@diskcirc{\setbox\@picbox=\hbox{\circlefont\char\count@}\@xdim=\wd\@picbox
254 \leavevmode \ifdim\@len>15.499\@xdim \@bigdc \else \@smalldc\fi}
255 \def\@bigdc{\ifnum\count@<'160 \@bigcirc
256 \else \@len=15\@xdim \@diskcirc\fi}
257 \def\@smalldc{{\advance\@len-.5\@xdim
258 \loop\ifdim\@xdim<\@len \advance\count@\@ne \advance\@xdim\wd\@picbox\repeat
259 \hbox{\circlefont\char\count@}}}
260 \def\@bigcirc{{\circlefont\count@=15
261 \setbox\@picbox=\hbox{\char\count@}\@xdim=\wd\@picbox
262 \ifdim\@len>2.5\@xdim \@len=2.5\@xdim\fi
263 \advance\@len-.125\wd\@picbox
264 \loop\ifdim\@xdim<\@len \advance\count@ 4 \advance\@xdim.25\wd\@picbox\repeat
265 \@ydim=.5\@xdim \advance\@ydim.5\linethickness
266 \setbox\@picbox=\vbox{\hbox{\char\count@\advance\count@-3\char\count@}%
267 \nointerlineskip
268 \hbox{\advance\count@\m@ne\char\count@\advance\count@\m@ne\char\count@}}%
269 \kern-\@ydim\lower\@ydim\box\@picbox}}
270
271 \newif\ifovaltl \newif\ifovaltr \newif\ifovalbl \newif\ifovalbr
272 \ovaltltrue \ovaltrtrue \ovalbltrue \ovalbrtrue
273 \def\oval(#1,#2){\@xdim=#1\unitlength \@ydim=#2\unitlength
274 {\circlefont \setbox\@picbox=\hbox{\char0}
275 \ifdim\@xdim<\wd\@picbox \@xdim=\wd\@picbox\fi
276 \ifdim\@ydim<\wd\@picbox \@ydim=\wd\@picbox\fi
277 \@save=\@xdim \ifdim\@ydim<\@save \@save=\@ydim \fi
278 \count@=39
279 \loop \setbox\@picbox=\hbox{\char\count@}\ifdim\@save<\wd\@picbox
280 \advance\count@-4 \repeat
281 \setbox\strutbox=\hbox{\vrule height\ht\@picbox depth\dp\@picbox width\z@
282 \kern\wd\@picbox}%
283 \@save=.5\wd\@picbox \advance\@save-.5\linethickness
284 \setbox0=\hbox to\@xdim{\ifovaltl\char\count@\else\strut\fi
285 \kern-\@save\leaders\hrule height\ifovaltl\linethickness\else\z@\fi\hfil
286 \leaders\hrule height\ifovaltr\linethickness\else\z@\fi\hfil\kern\@save
287 \ifovaltr\advance\count@-3\char\count@\else\strut\fi\kern-\wd\@picbox}%
288 \advance\count@\m@ne
289 \setbox2=\hbox to\@xdim{\ifovalbl\char\count@\else\strut\fi
290 \kern-\@save\leaders\hrule height\ifovalbl\linethickness\else\z@\fi\hfil
291 \leaders\hrule height\ifovalbr\linethickness\else\z@\fi\hfil\kern\@save
292 \ifovalbr\advance\count@\m@ne\char\count@\else\strut\fi\kern-\wd\@picbox}%
293 \@save=\@ydim \advance\@save-\wd\@picbox \divide\@save 2
294 \setbox\@picbox=\vbox{\box0\nointerlineskip
295 \hbox to\@xdim{\vrule height\@save width\ifovaltl\linethickness\else\z@\fi
296 \hfil\ifovaltr\vrule width\linethickness\kern-\linethickness\fi}%
297 \nointerlineskip
298 \hbox to\@xdim{\vrule height\@save width\ifovalbl\linethickness\else\z@\fi
299 \hfil\ifovalbr\vrule width\linethickness\kern-\linethickness\fi}%
300 \nointerlineskip\box2}%
301 \@save=.5\@ydim \advance\@save.5\linethickness \leavevmode
302 \kern-.5\@xdim \kern-.5\linethickness \lower\@save\box\@picbox}}
303
304 % ============================================================
305
306 %% More picture environment tags, output by fig2dev
307
308
309 %% The framebox tag was missing in DEK's code. Below is a copy from
310 %% the 1994/06/01 version of ltboxes.dtx. Actually, we need only the
311 %% \@framepicbox tag.
312
313 % \DescribeMacro\framebox
314 % |\framebox| ... : like |\makebox|, except it puts a `frame' around
315 % the box. The frame is made of lines of thickness
316 % |\fboxrule|, separated by space |\fboxsep| from the
317 % text -- except for |\framebox(X,Y)| ... , where the
318 % thickness of the lines is as for the picture environment,
319 % and there is no separation added.
320
321 \def\framebox(#1,#2){%
322 \@ifnextchar[{\@framebox(#1,#2)}{\@framebox(#1,#2)[]}% ] (Emacs)
323 }
324 \long\def\@framebox(#1,#2)[#3]#4{%
325 \frame{\makebox(#1,#2)[#3]{#4}}}
326
327 \long\def\frame#1{%
328 \leavevmode
329 \hbox{%
330 \hskip-\linethickness
331 \vbox{%
332 \vskip-\linethickness
333 \hrule height\linethickness
334 \hbox{%
335 \vrule width\linethickness
336 #1%
337 \vrule width\linethickness}%
338 \hrule height\linethickness
339 \vskip -\linethickness}%
340 \hskip -\linethickness}}
341
342
343 %% The dashbox tag was also missing. We copy it from ltpictur.dtx,
344 %% 1994/05/22 v1.0e LaTeX Kernel (Picture Mode). The (missing)
345 %% indentation is from there, not introduced by me. Sorry, but this
346 %% must be emphasized.
347
348 % \@wholewidth -> \linethickness
349 % \@makepicbox -> \makebox
350
351 \xfig@newdimen\@dashdim
352 \xfig@newbox\@dashbox
353 \xfig@newcount\@dashcnt
354
355 \def\@whilenoop#1{}
356 \def\@whilenum#1\do #2{\ifnum #1\relax #2\relax\@iwhilenum{#1\relax
357 #2\relax}\fi}
358 \def\@iwhilenum#1{\ifnum #1\let\@nextwhile\@iwhilenum
359 \else\let\@nextwhile\@whilenoop\fi\@nextwhile{#1}}
360
361 \def\dashbox#1(#2,#3){\leavevmode\hbox to\z@{\baselineskip \z@skip
362 \lineskip \z@skip
363 \@dashdim #2\unitlength
364 \@dashcnt \@dashdim \advance\@dashcnt 200
365 \@dashdim #1\unitlength\divide\@dashcnt \@dashdim
366 \ifodd\@dashcnt\@dashdim \z@
367 \advance\@dashcnt \@ne \divide\@dashcnt \tw@
368 \else \divide\@dashdim \tw@ \divide\@dashcnt \tw@
369 \advance\@dashcnt \m@ne
370 \setbox\@dashbox \hbox{\vrule height \@halfwidth depth \@halfwidth
371 width \@dashdim}\put(0,0){\copy\@dashbox}%
372 \put(0,#3){\copy\@dashbox}%
373 \put(#2,0){\hskip-\@dashdim\copy\@dashbox}%
374 \put(#2,#3){\hskip-\@dashdim\box\@dashbox}%
375 \multiply\@dashdim \thr@@
376 \fi
377 \setbox\@dashbox \hbox{\vrule height \@halfwidth depth \@halfwidth
378 width #1\unitlength\hskip #1\unitlength}\count@\z@
379 \put(0,0){\hskip\@dashdim \@whilenum \count@ <\@dashcnt
380 \do{\copy\@dashbox\advance\count@ \@ne }}\count@\z@
381 \put(0,#3){\hskip\@dashdim \@whilenum \count@ <\@dashcnt
382 \do{\copy\@dashbox\advance\count@ \@ne }}%
383 \@dashdim #3\unitlength
384 \@dashcnt \@dashdim \advance\@dashcnt 200
385 \@dashdim #1\unitlength\divide\@dashcnt \@dashdim
386 \ifodd\@dashcnt \@dashdim \z@
387 \advance\@dashcnt \@ne \divide\@dashcnt \tw@
388 \else
389 \divide\@dashdim \tw@ \divide\@dashcnt \tw@
390 \advance\@dashcnt \m@ne
391 \setbox\@dashbox\hbox{\hskip -\@halfwidth
392 \vrule width \linethickness
393 height \@dashdim}\put(0,0){\copy\@dashbox}%
394 \put(#2,0){\copy\@dashbox}%
395 \put(0,#3){\lower\@dashdim\copy\@dashbox}%
396 \put(#2,#3){\lower\@dashdim\copy\@dashbox}%
397 \multiply\@dashdim \thr@@
398 \fi
399 \setbox\@dashbox\hbox{\vrule width \linethickness
400 height #1\unitlength}\count@\z@
401 \put(0,0){\hskip -\@halfwidth \vbox{\@whilenum \count@ <\@dashcnt
402 \do{\vskip #1\unitlength\copy\@dashbox\advance\count@ \@ne }%
403 \vskip\@dashdim}}\count@\z@
404 \put(#2,0){\hskip -\@halfwidth \vbox{\@whilenum \count@<\@dashcnt
405 \do{\vskip #1\unitlength\copy\@dashbox\advance\count@ \@ne }%
406 \vskip\@dashdim}}}\makebox(#2,#3)}
407
408
409 % ============================================================
410
411 %% Then we must supply the LaTeX tags that are inserted by fig2dev.
412
413 % \setlength is the LaTeX PC way of setting a register.
414 \def\setlength#1#2{#1=#2\relax}
415
416 % --------------------------------------------------
417
418 % \makeatletter is called to access private macros in the \SetFigFont
419 % definition. Since we never expand that definition, we could ignore
420 % the catcode change. But we should not define a macro with a nonsense
421 % name...
422 \ifx \makeatletter\undefined
423 \def\makeatletter{\catcode`\@=11 } % <-- Space
424 \fi
425
426 % --------------------------------------------------
427
428 % The real hassle in that macro file is the font switch code. Once
429 % there was an interface, in transfig 2.1.7 & 2.1.8: A macro named
430 % \SetFigFont was used to select the type for texts. The macro
431 % definition itself is written by fig2dev, it is part of the figure
432 % code.
433 %
434 % Then transfig 3 was released and the interface disappeared. There's
435 % still the macro \SetFigFont and the macro definition is still
436 % written by fig2dev, but it may be defined with 3 arguments or with 5
437 % arguments, one cannot determine what's used. The second form is used
438 % when NFSS is added to the defines of fig2dev and should be the
439 % default. (After all, LaTeX2e subsumed NFSS.) The first form must be
440 % used for LaTeX 2.09 w/OFSS.
441 %
442 % \SetFigFont is not defined if it is defined already when the figure
443 % code is read. OK, one might think, let's define a plain TeX version.
444 % (Actually, xfig.tex up to revision 1.3 did so.) But which interface
445 % shall we use for our definition? In a typical installation one has
446 % old documents with xfig pictures that were created with an old
447 % fig2dev, we must therefore support the three-arg-variant. Newly
448 % created figures will use the five-arg-variant, though. There is no
449 % obvious way to determine which variant will be used in the
450 % respective figure.
451
452 % Please note that the information above -- and the one below about
453 % the actual possible interfaces of \SetFigFont -- was determined by
454 % looking at the output of example files and the code in setfigfont.c
455 % and texfonts.h, as not even the comments in these files got updated
456 % when the new \SetFigFont interface was introduced. (Sigh.)
457 %
458 % The changes were not even marked in the list of changes, I learned
459 % about them when folks from the Net sent me complaints about revision
460 % 1.1 of xfig.tex. (I hadn't installed xfig 3 at this time.)
461 %
462 % Do I really have to tell you what I think about these kinds of
463 % changes, in terms of software quality? (Don't ask me when I'm in a
464 % bad mood if you want polite answers.)
465
466 % Well, here's the solution: As told above, I've analyzed the possible
467 % expansions of \SetFigFont. I'll define macros for every cseq that's
468 % in the expansion, one of these macros will bind \SetFigFont to
469 % \SetFigFontOFSS or \SetFigFontNFSS, respectively. Let's have a look:
470 %
471 % OFSS: evaluates \@setsize. This macro has supposed to have 4
472 % arguments (type, baselineskip, font-setup, font-setup). Then the
473 % type specifier is evaluated by a \csname. Passing nothing there will
474 % effectively be a nop.
475 %
476 % NFSS: The \SetFigfont expansion uses more cseqs, but is more
477 % regular, too. We may supply empty expansions for everything that
478 % shall setup the font parameters: \reset@font, \fontsize (2 args),
479 % \fontfamily & \fontseries & \fontshape (each 1 arg). Then
480 % \selectfont is evaluated, here we bind the appropriate expansion of
481 % \SetFigFont.
482
483 % Now we may setup the macro definitions, evaluate one pseudo
484 % \SetFigFont and \SetFigFont will be bound to the correct expansion.
485 %
486 % The first argument must be a number, as the OFSS \SetFigFont version
487 % assigns it to a count register.
488 \def\xfig@bindSetFigFont{%
489 % OFSS
490 \def\@setsize##1##2##3##4{\let\SetFigFont\SetFigFontOFSS}%
491 % NFSS
492 \let\reset@font\relax
493 \def\fontsize##1##2{}%
494 \def\fontfamily##1{}%
495 \def\fontseries##1{}%
496 \def\fontshape##1{}%
497 \def\selectfont{\let\SetFigFont\SetFigFontNFSS}%
498 % Now bind correct \SetFigFont by evaluating \SetFigFont.
499 \SetFigFont{0}{}{}{}{}%
500 }
501
502 % --------------------------------------------------
503
504 % The interface of \SetFigFontOFSS:
505 % #1 is the size (w/o pt),
506 % #2 the baselineskip (w/o pt),
507 % #3 a plain TeX type specifier.
508 % If #3 is empty we assume that a default font should be taken.
509 % This default font can be named by \FigFontDefault. Note, that
510 % this parameter is not empty if you choose the font `Default' in
511 % xfig. You have to chang texfonts.h accordingly. I did it
512 % already for 2.1.7 and sent the diffs to the maintainer, but
513 % obviously he dumped them since they did not appear in 3.x.
514 %
515 % It's a pity, that we can't use the plain TeX type specifier. We
516 % demand an appropriate font scaled to the correct size. This is not
517 % the best solution, but nowadays most DVI drivers generate the fonts on
518 % the fly anyhow.
519
520 \def\FigFontDefault{cmr10}
521 \def\FigFontType{\FigFontDefault\space}
522 \def\FigFontTyperm{cmr10}
523 \def\FigFontTypebf{cmbx10}
524 \def\FigFontTypeit{cmti10}
525 \def\FigFontTypesf{cmss10}
526 \def\FigFontTypett{cmtt10}
527 \def\SetFigFontOFSS#1#2#3{%
528 \font\FigFont \csname FigFontType#3\endcsname\space at #1pt
529 \FigFont
530 \baselineskip #2pt\relax
531 }
532
533 % The interface of \SetFigFontNFSS:
534 % #1 is the size (w/o pt),
535 % #2 the baselineskip (w/o pt),
536 % #3 the NFSS font family (as a cseq),
537 % #4 the NFSS font series (as a cseq), and
538 % #5 the NFSS font shape (as a cseq).
539 %
540 % The current font state is reset before the arguments take effect.
541 % The call to \SetFigFont doesn't use the full possibilities of NFSS;
542 % only fixed combinations of arguments are supplied, as xfig itself
543 % knows only about a fixed set of fonts (default, roman, bold, italic,
544 % sans serif, and typewriter).
545
546 % We map that interface back to the one of \SetFigFontOFSS. To do that
547 % we redefine the NFSS font specifiers locally to create plain TeX
548 % font specifiers. That's mostly easy, medium density (`md') series
549 % and upright (`up') shape are ignored in plain anyhow. The default is
550 % explicitely specified by \familydefault, we don't need to infer it.
551 % But there is one exception: bold is specified as `roman bold', ie,
552 % as `rmbf'. For that exception we just define a new FigFontType macro.
553
554 \def\FigFontTypermbf{\FigFontTypebf}
555 \def\SetFigFontNFSS#1#2#3#4#5{%
556 \begingroup
557 \let\familydefault\empty
558 \def\rmdefault{rm}%
559 \def\sfdefault{sf}%
560 \def\ttdefault{tt}%
561 \let\mddefault\empty
562 \def\bfdefault{bf}%
563 \let\updefault\empty
564 \def\itdefault{it}%
565 \xdef\FigFontSpec{#3#4#5}%
566 \endgroup
567 \SetFigFontOFSS{#1}{#2}{\FigFontSpec}%
568 }
569
570 % --------------------------------------------------
571
572 % Environments are enclosed in \begin{foo} ... \end{foo}.
573 % I don't check if the call is ok -- this file is specific for
574 % machine-generated code, that shall be correct by definition.
575 %
576 % We need to setup the correct \SetFigFont binding, as explained above.
577 % And let's evaluate a hook to enable document specific adaptions.
578
579 \def\begin#1{%
580 \begingroup
581 \def\end##1{%
582 \csname end##1\endcsname
583 \endgroup
584 }%
585 \xfig@bindSetFigFont
586 \csname #1Hook\endcsname
587 \csname begin#1\endcsname
588 }
589
590
591 % ============================================================
592
593 \catcode`\@=\CatAtCode
594
595 \endinput
596
597
598 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599 %
600 % $Log: xfig.tex,v $
601 % Revision 1.4 1995/05/07 16:52:05 schrod
602 % Determine \SetFigFont variant automatically. \OldXfig is not
603 % looked at any more, \SetFigFontOld and \SetFigFontNew are renamed to
604 % \SetFigFontOFSS and \SetFigFontNFSS.
605 %
606 % Revision 1.3 1995/04/17 00:01:08 schrod
607 % Don't allocate registers anew if xfig.tex is read in the second
608 % time.
609 %
610 % Revision 1.2 1995/03/16 01:15:51 schrod
611 % Support output of transfig 3.1.1.
612 %
613 % Revision 1.1 1995/03/13 23:18:15 schrod
614 % Started to manage this package with CVS. Made minor code cleanup.
615 %
616
617 % 94-06-10 js Initial revision.
618
619
620 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
621 Local Variables:
622 mode: plain-tex
623 TeX-master: t
624 TeX-brace-indent-level: 4
625 page-delimiter: "^% ==*$"
626 End: