| 1 |
% METATeX.TeX (RMCG19940730) |
| 2 |
|
| 3 |
% METATeX.TeX communicates TeX and METAFONT |
| 4 |
% Copyright (C) 2003, 2004 Ram\'on Casares |
| 5 |
% |
| 6 |
% This program is free software; you can redistribute it and/or modify |
| 7 |
% it under the terms of the GNU General Public License as published by |
| 8 |
% the Free Software Foundation; either version 2 of the License, or |
| 9 |
% (at your option) any later version. |
| 10 |
% |
| 11 |
% This program is distributed in the hope that it will be useful, |
| 12 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
% GNU General Public License for more details. |
| 15 |
% |
| 16 |
% You should have received a copy of the GNU General Public License |
| 17 |
% along with this program; if not, write to the |
| 18 |
% Free Software Foundation, Inc., |
| 19 |
% 59 Temple Place, Suite 330, |
| 20 |
% Boston, MA 02111-1307 USA |
| 21 |
|
| 22 |
%\message{V1.0 by RMCG 20031002} |
| 23 |
\message{V1.1 by RMCG 20040812} % mptopdf -> mtmp2pdf |
| 24 |
|
| 25 |
\chardef\MToldatcatcode=\catcode`\@\catcode`\@=11 |
| 26 |
|
| 27 |
\newif\ifMTf@le % true if auxiliar.mf is found (second pass) |
| 28 |
\newif\ifMTmf % true if second pass and MF (not MPost) has drawn the figures |
| 29 |
\newwrite\MToutf@le |
| 30 |
\newread\MTinf@le |
| 31 |
\newbox\MTbox |
| 32 |
\newbox\MTb@x |
| 33 |
\newcount\MTn@ |
| 34 |
\newdimen\MTxpos@ |
| 35 |
\newdimen\MTypos@ |
| 36 |
|
| 37 |
\openin\MTinf@le=auxiliar.mf % First see if the mf file exists |
| 38 |
\ifeof\MTinf@le \MTf@lefalse \else \MTf@letrue \fi |
| 39 |
\closein\MTinf@le |
| 40 |
|
| 41 |
\def\MTendmark{} |
| 42 |
{\obeylines\gdef\MTign@re#1 |
| 43 |
{\def\next{#1}\ifx\next\MTendmark \let\next\endgroup \else % |
| 44 |
\let\next\MTign@re\fi \next}} |
| 45 |
{\obeylines\gdef\MTc@py#1 |
| 46 |
{\def\next{#1}\ifx\next\MTendmark \let\next\endgroup \else % |
| 47 |
\immediate\write\MToutf@le{\next}\let\next\MTc@py\fi \next}} |
| 48 |
|
| 49 |
{\obeylines\gdef\MTign@reline#1 |
| 50 |
{\endgroup}} |
| 51 |
{\obeylines\gdef\MTc@pyline#1 |
| 52 |
{\immediate\write\MToutf@le{#1}\endgroup}} |
| 53 |
|
| 54 |
\def\MTsetupc@py{\def\do##1{\catcode`##1=12 }\dospecials |
| 55 |
\catcode`\\=0 \let\\=\MTbackslash \obeyspaces\obeylines} |
| 56 |
|
| 57 |
\def\MTmf@mp{\ifeof\MTinf@le |
| 58 |
\errhelp={It seems to me that file auxiliar.mf has not been processed, |
| 59 |
or that file auxiliar.log was deleted.}% |
| 60 |
\errmessage{File auxiliar.log not found}% |
| 61 |
\else |
| 62 |
\read\MTinf@le to \next % reads METAXXXX banner |
| 63 |
\def\MT@mf{METAFONT}% |
| 64 |
\def\MT@##1 ##2 ##3,##4\MT@@{##3}% #1 = This, #2 = is, #3 = METAFONT ? |
| 65 |
\edef\MTmeta{\expandafter\MT@\next\MT@@}% |
| 66 |
\message{(Drawings made by \MTmeta)}% |
| 67 |
\ifx\MTmeta\MT@mf \MTmftrue \else \MTmffalse \fi |
| 68 |
\fi} |
| 69 |
|
| 70 |
\def\MTl@gl@b{\MTloglabel } |
| 71 |
\def\MTgetl@g{\ifeof\MTinf@le \let\next\relax |
| 72 |
\errhelp={I was expecting to read a label location.}% |
| 73 |
\errmessage{Unexpected end of auxiliar.log}% |
| 74 |
\else \read\MTinf@le to \next |
| 75 |
\ifx\next\MTl@gl@b \let\next\relax |
| 76 |
{\catcode`\>=9 |
| 77 |
\global\read\MTinf@le to \MTxpos@text |
| 78 |
\global\read\MTinf@le to \MTypos@text }% |
| 79 |
\else \let\next\MTgetl@g \fi\fi \next} |
| 80 |
|
| 81 |
\escapechar=-1 \edef\MTbackslash{\string\\}\escapechar=`\\ |
| 82 |
\def\MTslashing{\begingroup \escapechar=-1 \edef\\{\string\\}% |
| 83 |
\edef\{{\string\{}\edef\}{\string\}}\edef\#{\string\#}% |
| 84 |
\edef\${\string\$}\edef\^{\string\^}\edef\_{\string\_}% |
| 85 |
\edef\&{\string\&}\edef\~{\string\~}\edef\%{\string\%}% |
| 86 |
\escapechar=`\\} |
| 87 |
\let\MTendslashing=\endgroup |
| 88 |
|
| 89 |
\def\MTf@rst#1#2#3/{#1}\def\MTsec@nd#1#2#3/{#2} |
| 90 |
|
| 91 |
\ifMTf@le \message{Second TeX pass} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 92 |
\openin\MTinf@le=auxiliar.log |
| 93 |
\MTmf@mp |
| 94 |
\ifMTmf % METAFONT has written auxiliar.log |
| 95 |
\font\MTfont=auxiliar \def\MTchar{\MTfont\char\MTn@}% |
| 96 |
\else % MetaPost has written auxiliar.log |
| 97 |
\ifx\pdfliteral\undefined |
| 98 |
\def\MTchar{\special{psfile=auxiliar.\number\MTn@}}% |
| 99 |
\else |
| 100 |
\input mtmp2pdf |
| 101 |
\def\MTchar{\MPtoPDF{auxiliar.\number\MTn@}}% |
| 102 |
%\input supp-pdf.tex % Context |
| 103 |
%\let\oldfinMPgrap=\finishMPgraphic % to avoid centering |
| 104 |
%\def\finishMPgraphic{\xdef\MPxoffset{0}\xdef\MPyoffset{0}\oldfinMPgrap}% |
| 105 |
%\def\MTchar{\convertMPtoPDF{auxiliar.\number\MTn@}{1}{1}}% |
| 106 |
\fi |
| 107 |
\fi |
| 108 |
\def\MTcode{\begingroup\MTsetupc@py\MTign@re{ }} |
| 109 |
\def\MT:{\begingroup\MTsetupc@py\MTign@reline} |
| 110 |
\def\MTline#1{} |
| 111 |
\def\MTbeginchar(#1,#2,#3);{\setbox\MTb@x=\hbox{\MTchar}% |
| 112 |
\wd\MTb@x=#1\ht\MTb@x=#2\dp\MTb@x=#3\setbox\MTbox=\vtop{\box\MTb@x}} |
| 113 |
\def\MTlabel#1(#2)#3"#4";{\setbox\MTb@x\hbox{#4}\MTgetl@g |
| 114 |
\MTxpos@=\MTxpos@text pt \MTypos@=\MTypos@text pt \dimen@=\dp\MTbox |
| 115 |
\setbox\MTbox=\vtop{\unvbox\MTbox\nointerlineskip |
| 116 |
\def\1{\MTf@rst#3cc/}\def\2{\MTsec@nd#3cc/}% |
| 117 |
\vbox to 0pt{\advance\dimen@\MTypos@ \kern-\dimen@ |
| 118 |
\if b\1\kern-\ht\MTb@x \else \if c\1\kern-0.5\ht\MTb@x \fi\fi |
| 119 |
\hbox to 0pt{\kern\MTxpos@ |
| 120 |
\if r\2\kern-\wd\MTb@x \else \if c\2\kern-0.5\wd\MTb@x \fi\fi |
| 121 |
\box\MTb@x\hss}\vss}}} |
| 122 |
\def\MTendchar;{\global\advance\MTn@1 } |
| 123 |
\else \message{First TeX pass} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 124 |
\let\MTfont=\nullfont |
| 125 |
\let\MTchar=\relax |
| 126 |
\tracinglostchars=0 |
| 127 |
\immediate\openout\MToutf@le=auxiliar.mf |
| 128 |
\def\MTcode{\begingroup\MTsetupc@py\MTc@py{ }} |
| 129 |
\def\MT:{\begingroup\MTsetupc@py\MTc@pyline} |
| 130 |
\def\MTline#1{\MTslashing\immediate\write\MToutf@le{#1}\MTendslashing} |
| 131 |
\def\MTbeginchar(#1,#2,#3);{% |
| 132 |
\MTline{beginchar(\number\MTn@,#1\#,#2\#,#3\#); \% line \the\inputlineno}% |
| 133 |
\global\setbox\MTbox=\vtop{}\wd\MTbox=#1\ht\MTbox=#2\dp\MTbox=#3} |
| 134 |
\def\MTlabel#1(#2)#3"#4";{{\setbox0=\hbox{#4}% |
| 135 |
\def\1{\MTf@rst#3cc/}\def\2{\MTsec@nd#3cc/}% |
| 136 |
\MTline{ MTlabel(#2)("\1","\2","#1",\the\wd0,\the\ht0,\the\dp0);}}} |
| 137 |
\def\MTendchar;{\MTline{endchar;}\MTline{}\global\advance\MTn@1 } |
| 138 |
\fi |
| 139 |
|
| 140 |
\MT:% Generated by METATeX |
| 141 |
\MT: |
| 142 |
\MT: mag:=\number\mag/1000; |
| 143 |
\MT: |
| 144 |
\MT: truept = pt/mag; truept# = pt#/mag; |
| 145 |
\MT: truepc = pc/mag; truepc# = pc#/mag; |
| 146 |
\MT: truein = in/mag; truein# = in#/mag; |
| 147 |
\MT: truebp = bp/mag; truebp# = bp#/mag; |
| 148 |
\MT: truecm = cm/mag; truecm# = cm#/mag; |
| 149 |
\MT: truemm = mm/mag; truemm# = mm#/mag; |
| 150 |
\MT: truedd = dd/mag; truedd# = dd#/mag; |
| 151 |
\MT: truecc = cc/mag; truecc# = cc#/mag; |
| 152 |
\MT: |
| 153 |
\MT:if known prologues: % if mpost: |
| 154 |
\MT: |
| 155 |
\MT: mm#=2.84528; pt#=1; dd#=1.07001; bp#=1.00375; |
| 156 |
\MT: cm#=28.45276; pc#=12; cc#=12.84010; in#=72.27; |
| 157 |
\MT: |
| 158 |
\MT: string extra_setup, extra_beginchar, extra_endchar; |
| 159 |
\MT: extra_setup = extra_beginchar = extra_endchar = ""; |
| 160 |
\MT: |
| 161 |
\MT: def mode_setup = |
| 162 |
\MT: proofing:=0; % no, we're not making proofs |
| 163 |
\MT: fontmaking:=0; % no, we're not making a font |
| 164 |
\MT: tracingtitles:=0; % no, don't show titles at all |
| 165 |
\MT: scantokens extra_setup; |
| 166 |
\MT: enddef; |
| 167 |
\MT: |
| 168 |
\MT: def beginchar(expr c,w_sharp,h_sharp,d_sharp) = |
| 169 |
\MT: begingroup |
| 170 |
\MT: charcode:=c; |
| 171 |
\MT: w:=w_sharp*pt; h:=h_sharp*pt; d:=d_sharp*pt; |
| 172 |
\MT: clearxy; clearit; clearpen; |
| 173 |
\MT: pickup defaultpen; |
| 174 |
\MT: drawoptions(); |
| 175 |
\MT: scantokens extra_beginchar; |
| 176 |
\MT: enddef; |
| 177 |
\MT: |
| 178 |
\MT: def endchar = |
| 179 |
\MT: scantokens extra_endchar; |
| 180 |
\MT: shipit; |
| 181 |
\MT: endgroup |
| 182 |
\MT: enddef; |
| 183 |
\MT: |
| 184 |
\MT:else: % mf |
| 185 |
\MT: mode:=localfont; |
| 186 |
\MT:fi |
| 187 |
\MT: |
| 188 |
\MT:mode_setup; |
| 189 |
\MT: |
| 190 |
\MT:def MTlabel(suffix i)(expr v,h,add,wd,ht,dp) = |
| 191 |
\MT: x.i.l = x.i if h="c": - wd/2 elseif h="r": - wd fi; |
| 192 |
\MT: y.i.t = y.i if v="c": + ht/2 elseif v="b": + ht fi; |
| 193 |
\MT: x.i.r = x.i.l + wd; y.i.b = y.i.t - ht - dp; |
| 194 |
\MT: if not (add=""): erase fill (x.i.l,y.i.t) -- |
| 195 |
\MT: (x.i.l,y.i.b) -- (x.i.r,y.i.b) -- (x.i.r,y.i.t) -- cycle; fi |
| 196 |
\MT: message"\\MTloglabel"; show x\\i/pt; show y\\i/pt; message""; |
| 197 |
\MT:enddef; |
| 198 |
\MT: |
| 199 |
|
| 200 |
\let\texbye=\bye |
| 201 |
\outer\def\bye{\ifMTf@le \closein\MTinf@le \else |
| 202 |
\MTline{end.}\immediate\closeout\MToutf@le \fi |
| 203 |
\par\vfill\supereject\end} |
| 204 |
|
| 205 |
\catcode`\@=\MToldatcatcode |