| 1 |
% Copyright 2019 by Till Tantau |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
\pgfutil@format@is@plaintrue |
| 13 |
|
| 14 |
|
| 15 |
% The aux files, needed for reading back coordinates |
| 16 |
\def\pgfutil@aux@read@hook{ |
| 17 |
\pgfutil@IfFileExists{\jobname.pgf}{\input \jobname.pgf\relax}{} |
| 18 |
\csname newwrite\endcsname\pgfutil@auxout |
| 19 |
\immediate\csname openout\endcsname\pgfutil@auxout\jobname.pgf |
| 20 |
} |
| 21 |
\def\pgfutil@writetoaux#1{\write\pgfutil@auxout{#1}} |
| 22 |
|
| 23 |
% XColor-like support for plain TeX |
| 24 |
|
| 25 |
\def\pgfutil@definecolor#1#2#3{\csname pgfutil@emu@#2\endcsname{#1}#3\@nil} |
| 26 |
|
| 27 |
\def\pgfutil@emu@rgb#1#2,#3,#4\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#3,#4}}} |
| 28 |
\def\pgfutil@emu@gray#1#2\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#2,#2}}} |
| 29 |
\def\pgfutil@emu@RGB#1#2,#3,#4\@nil{% |
| 30 |
\begingroup |
| 31 |
\pgfmathdivide@{#2}{255}\let\pgfutil@emu@RGB@r\pgfmathresult |
| 32 |
\pgfmathdivide@{#3}{255}\let\pgfutil@emu@RGB@g\pgfmathresult |
| 33 |
\pgfmathdivide@{#4}{255}\let\pgfutil@emu@RGB@b\pgfmathresult |
| 34 |
\edef\pgf@marshal{\def\expandafter\noexpand\csname\string\color@#1\endcsname{% |
| 35 |
\noexpand\xcolor@{}{}{rgb}{\pgfutil@emu@RGB@r,\pgfutil@emu@RGB@g,\pgfutil@emu@RGB@b}}}% |
| 36 |
\expandafter\endgroup\pgf@marshal |
| 37 |
} |
| 38 |
|
| 39 |
\pgfutil@definecolor{white}{gray}{1} |
| 40 |
\pgfutil@definecolor{black}{gray}{0} |
| 41 |
\pgfutil@definecolor{gray}{gray}{0.5} |
| 42 |
\pgfutil@definecolor{red}{rgb}{1,0,0} |
| 43 |
\pgfutil@definecolor{green}{rgb}{0,1,0} |
| 44 |
\pgfutil@definecolor{blue}{rgb}{0,0,1} |
| 45 |
\pgfutil@definecolor{cyan}{rgb}{0,1,1} |
| 46 |
\pgfutil@definecolor{magenta}{rgb}{1,0,1} |
| 47 |
\pgfutil@definecolor{yellow}{rgb}{1,1,0} |
| 48 |
\pgfutil@definecolor{orange}{rgb}{1,0.5,0} |
| 49 |
\pgfutil@definecolor{violet}{rgb}{0.5,0,0.5} |
| 50 |
\pgfutil@definecolor{purple}{rgb}{0.75,0,0.25} |
| 51 |
\pgfutil@definecolor{brown}{rgb}{0.75,0.5,0.25} |
| 52 |
|
| 53 |
\def\pgfutil@color#1{% |
| 54 |
\pgfutil@colorlet{.}{#1}% |
| 55 |
\pgfsysprotocol@getcurrentprotocol\pgfutil@emu@temp% |
| 56 |
{% |
| 57 |
\pgfsysprotocol@setcurrentprotocol\pgfutil@empty% |
| 58 |
\pgfsysprotocol@bufferedtrue% |
| 59 |
\pgfsetcolor{.}% |
| 60 |
\expandafter\pgfsys@outerinvoke\expandafter{\pgfsysprotocol@currentprotocol}% |
| 61 |
}% |
| 62 |
\pgfsysprotocol@setcurrentprotocol\pgfutil@emu@temp% |
| 63 |
\aftergroup\pgfutil@reset@color% |
| 64 |
} |
| 65 |
|
| 66 |
\def\pgfutil@extractcolorspec#1#2{% |
| 67 |
\def#2{{#1}}% |
| 68 |
} |
| 69 |
|
| 70 |
\def\pgfutil@convertcolorspec#1#2#3{% |
| 71 |
\edef#3{\expandafter\expandafter\expandafter\pgfutil@emu@select\csname\string\color@#1\endcsname}% |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
\def\pgfutil@doifcolorelse#1#2#3{% |
| 76 |
\expandafter\ifx\csname\string\color@#1\endcsname\relax% |
| 77 |
\let\pgf@next=\pgfutil@secondoftwo% |
| 78 |
\else |
| 79 |
\let\pgf@next=\pgfutil@firstoftwo% |
| 80 |
\fi% |
| 81 |
\pgf@next{#2}{#3}% |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
\def\pgfutil@reset@color{% |
| 86 |
\pgfsysprotocol@getcurrentprotocol\pgfutil@emu@temp% |
| 87 |
{% |
| 88 |
\pgfsysprotocol@setcurrentprotocol\pgfutil@empty% |
| 89 |
\pgfsysprotocol@bufferedtrue% |
| 90 |
\pgfsetcolor{.}% |
| 91 |
\expandafter\pgfsys@outerinvoke\expandafter{\pgfsysprotocol@currentprotocol}% |
| 92 |
}% |
| 93 |
\pgfsysprotocol@setcurrentprotocol\pgfutil@emu@temp% |
| 94 |
} |
| 95 |
\expandafter\def\csname\string\color@.\endcsname{\xcolor@{}{}{rgb}{0,0,0}} |
| 96 |
|
| 97 |
\def\pgfutil@colorlet#1#2{% |
| 98 |
\edef\pgf@marshal{#2}% |
| 99 |
\expandafter\pgfutil@in@\expandafter!\expandafter{\pgf@marshal}% |
| 100 |
\ifpgfutil@in@% |
| 101 |
% compute mixture |
| 102 |
{% |
| 103 |
\expandafter\pgfutil@emu@mix\pgf@marshal!white!\@nil% |
| 104 |
\xdef\pgf@marshal{\noexpand\def\expandafter\noexpand\csname\string\color@#1\endcsname{% |
| 105 |
\noexpand\xcolor@{}{}{rgb}{\pgf@sys@tonumber\pgf@xa,\pgf@sys@tonumber\pgf@xb,\pgf@sys@tonumber\pgf@xc}}}% |
| 106 |
}% |
| 107 |
\pgf@marshal% |
| 108 |
\else% |
| 109 |
\edef\pgf@marshal{\noexpand\let\expandafter\noexpand\csname\string\color@#1\endcsname=% |
| 110 |
\expandafter\noexpand\csname\string\color@#2\endcsname}% |
| 111 |
\pgf@marshal% |
| 112 |
\fi% |
| 113 |
} |
| 114 |
\def\pgfutil@emu@mix#1!#2!#3!#4\@nil{% |
| 115 |
\expandafter\expandafter\expandafter\pgfutil@emu@unpack\csname\string\color@#1\endcsname% |
| 116 |
\pgf@ya=\pgf@xa% |
| 117 |
\pgf@yb=\pgf@xb% |
| 118 |
\pgf@yc=\pgf@xc% |
| 119 |
\expandafter\expandafter\expandafter\pgfutil@emu@unpack\csname\string\color@#3\endcsname% |
| 120 |
\c@pgf@counta=#2\relax% |
| 121 |
\c@pgf@countb=100\relax% |
| 122 |
\advance\c@pgf@countb by-\c@pgf@counta\relax% |
| 123 |
\pgf@xa=\c@pgf@countb\pgf@xa% |
| 124 |
\advance\pgf@xa by\c@pgf@counta\pgf@ya% |
| 125 |
\divide\pgf@xa by 100\relax% |
| 126 |
\pgf@xb=\c@pgf@countb\pgf@xb% |
| 127 |
\advance\pgf@xb by\c@pgf@counta\pgf@yb% |
| 128 |
\divide\pgf@xb by 100\relax% |
| 129 |
\pgf@xc=\c@pgf@countb\pgf@xc% |
| 130 |
\advance\pgf@xc by\c@pgf@counta\pgf@yc% |
| 131 |
\divide\pgf@xc by 100\relax% |
| 132 |
} |
| 133 |
\def\pgfutil@emu@unpack#1#2#3#4#5{% |
| 134 |
\pgfutil@emu@@unpack#5\@nil% |
| 135 |
} |
| 136 |
\def\pgfutil@emu@@unpack#1,#2,#3\@nil{% |
| 137 |
\pgf@xa=#1pt% |
| 138 |
\pgf@xb=#2pt% |
| 139 |
\pgf@xc=#3pt% |
| 140 |
} |
| 141 |
|
| 142 |
\def\pgfutil@emu@select#1#2#3#4#5{#5} |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
\let\definecolor=\pgfutil@definecolor |
| 147 |
\let\color=\pgfutil@color |
| 148 |
\let\colorlet=\pgfutil@colorlet |
| 149 |
\let\extractcolorspec=\pgfutil@extractcolorspec |
| 150 |
\let\convertcolorspec=\pgfutil@convertcolorspec |
| 151 |
|
| 152 |
\def\XC@tgt@mod#1{#1} |
| 153 |
\def\XC@sdef#1#2{\edef#1{#2}} |
| 154 |
\def\XC@mod@cmyk{cmyk} |
| 155 |
\def\XC@mod@rgb{rgb} |
| 156 |
|
| 157 |
|
| 158 |
% pgfutil@minipage |
| 159 |
|
| 160 |
\def\pgfutil@minipage[#1]#2{% |
| 161 |
\hbox to#2\bgroup% |
| 162 |
\hsize=#2\relax% |
| 163 |
\vbox\bgroup\noindent% |
| 164 |
} |
| 165 |
\def\pgfutil@endminipage{\egroup\egroup} |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
% Driver detector (not so good): |
| 170 |
|
| 171 |
\ifx\pdfoutput\@undefined\alloc@0\count\countdef\insc@unt\pdfoutput\fi |
| 172 |
\ifx\pdfoutput\relax\alloc@0\count\countdef\insc@unt\pdfoutput\fi |
| 173 |
|
| 174 |
\def\pgfutil@guessdriver{ |
| 175 |
\ifx\directlua\@undefined |
| 176 |
\ifx\HCode\@undefined% |
| 177 |
\ifcase\pdfoutput% |
| 178 |
\ifx\XeTeXversion\@undefined |
| 179 |
\def\pgfsysdriver{pgfsys-dvips.def}% hopefully |
| 180 |
\else |
| 181 |
\def\pgfsysdriver{pgfsys-xetex.def}% should be right |
| 182 |
\fi |
| 183 |
\else% |
| 184 |
\def\pgfsysdriver{pgfsys-pdftex.def}% should be right |
| 185 |
\fi% |
| 186 |
\else% |
| 187 |
\def\pgfsysdriver{pgfsys-tex4ht.def}% should be right |
| 188 |
\fi% |
| 189 |
\else |
| 190 |
\def\pgfsysdriver{pgfsys-luatex.def}% |
| 191 |
\fi |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
% Global colors |
| 197 |
|
| 198 |
\let\pgfutil@globalcolorsfalse=\relax |
| 199 |
\let\pgfutil@globalcolorstrue=\relax |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
% Font stuff |
| 204 |
|
| 205 |
\def\pgfutil@font@tiny{\fam\z@\fiverm} % How to do this correctly? |
| 206 |
\def\pgfutil@font@scriptsize{\fam\z@\sevenrm} |
| 207 |
\def\pgfutil@font@footnotesize{\rm} |
| 208 |
\def\pgfutil@font@small{\fam\z@\ninerm} |
| 209 |
\def\pgfutil@font@normalsize{\rm} |
| 210 |
\def\pgfutil@font@large{\rm} |
| 211 |
\def\pgfutil@font@Large{\rm} |
| 212 |
\def\pgfutil@font@huge{\rm} |
| 213 |
\def\pgfutil@font@Huge{\rm} |
| 214 |
|
| 215 |
\def\pgfutil@font@itshape{\it} |
| 216 |
\def\pgfutil@font@bfseries{\bf} |
| 217 |
|
| 218 |
\let\pgfutil@font@normalfont=\rm |
| 219 |
|
| 220 |
\let\pgfutil@selectfont=\rm |
| 221 |
|
| 222 |
|
| 223 |
% Extra counters, registers, boxes |
| 224 |
|
| 225 |
\newcount\pgfutil@tempcnta |
| 226 |
\newcount\pgfutil@tempcntb |
| 227 |
|
| 228 |
\newbox\pgfutil@tempboxa |
| 229 |
|
| 230 |
\let\pgfmath@tempdima\pgfutil@tempdima |
| 231 |
\let\pgfmath@tempdima\pgfutil@tempdima |
| 232 |
\let\pgfmath@tempcnta\pgfutil@tempcnta |
| 233 |
\let\pgfmath@tempcntb\pgfutil@tempcntb |
| 234 |
|
| 235 |
% From LaTeX |
| 236 |
\newskip\pgfutil@flushglue |
| 237 |
\pgfutil@flushglue=0pt plus 1fil |
| 238 |
|
| 239 |
% Module stuff |
| 240 |
|
| 241 |
\def\pgfutil@usemodule#1{\input #1.tex} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
% End of file stuff |
| 246 |
|
| 247 |
\let\pgfutil@origend=\end |
| 248 |
\def\end{\the\pgfutil@everybye\pgfutil@origend} |
| 249 |
|
| 250 |
% Link to existing stuff |
| 251 |
\let\pgfutil@voidb@x\voidb@x |
| 252 |
\let\pgfutil@toks@\toks@ |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
% Hack shipout. Now use atbegshi |
| 258 |
|
| 259 |
\def\pgfutil@insertatbegincurrentpagefrombox#1{% |
| 260 |
\edef\pgf@temp{\the\wd\pgfutil@abb}% |
| 261 |
\global\setbox\pgfutil@abb\hbox{% |
| 262 |
\unhbox\pgfutil@abb |
| 263 |
% |
| 264 |
% the order in which \pgfutil@insertatbegincurrentpagefrombox |
| 265 |
% matters unless we make the following -shift! |
| 266 |
% To see this, consider writing two such statements. The second |
| 267 |
% one will (naturally) be placed more to the right, although there |
| 268 |
% is no apparent reason why it should. |
| 269 |
% |
| 270 |
% CF observed problems when placing patterns in XObjects without |
| 271 |
% this skip (dvipdfmx driver for pgfplots shader=interp) |
| 272 |
\hskip-\pgf@temp\relax |
| 273 |
#1% |
| 274 |
}% |
| 275 |
} |
| 276 |
\newbox\pgfutil@abb% |
| 277 |
\def\pgfutil@insertatbegincurrentpage#1{% |
| 278 |
\expandafter\gdef\expandafter\pgfutil@abc\expandafter{\pgfutil@abc#1}% |
| 279 |
} |
| 280 |
\let\pgfutil@abc\pgfutil@empty% |
| 281 |
\def\pgfutil@insertatbegineverypage#1{% |
| 282 |
\expandafter\gdef\expandafter\pgfutil@abe\expandafter{\pgfutil@abe#1}% |
| 283 |
} |
| 284 |
\let\pgfutil@abe\pgfutil@empty% |
| 285 |
|
| 286 |
% Code by Heiko Oberdiek on ctt |
| 287 |
\input atbegshi.sty\relax |
| 288 |
\AtBeginShipout{% |
| 289 |
\setbox\AtBeginShipoutBox=\vbox{% |
| 290 |
\setbox0=\hbox{% |
| 291 |
\begingroup |
| 292 |
% the boxes \pgfutil@abe ("every page") and \pgfutil@abb ("current page") |
| 293 |
% are used to generate pdf objects / dictionaries which are |
| 294 |
% required for the graphics which are somewhere in the "real" |
| 295 |
% page content. |
| 296 |
% BUT: these pdf objects MUST NOT be affected by text layout |
| 297 |
% shifts! Consequently, we have to undo \hoffset and \voffset |
| 298 |
% (which are h/v shifts to the page layout). |
| 299 |
% |
| 300 |
% Note that this of importance for shadings. To be more |
| 301 |
% specific: try out shadings with standalone (which uses |
| 302 |
% \hoffset) and with xdvipdfmx (which appears to be more |
| 303 |
% fragile than pdflatex) - they break unless we undo \hoffset |
| 304 |
% and \voffset. |
| 305 |
\ifdim\hoffset=0pt \else \hskip-\hoffset\fi |
| 306 |
\pgfutil@abe |
| 307 |
\unhbox\pgfutil@abb |
| 308 |
\pgfutil@abc |
| 309 |
\global\let\pgfutil@abc\pgfutil@empty |
| 310 |
\ifdim\hoffset=0pt \else \hskip+\hoffset\fi |
| 311 |
\endgroup |
| 312 |
}% |
| 313 |
\wd0=0pt\relax |
| 314 |
\ht0=0pt\relax |
| 315 |
\dp0=0pt\relax |
| 316 |
% ... see remark above regarding \hoffset/\voffset: |
| 317 |
\ifdim\voffset=0pt \else \vskip-\voffset\fi |
| 318 |
\box0 % |
| 319 |
\ifdim\voffset=0pt \else \vskip+\voffset\fi |
| 320 |
\nointerlineskip |
| 321 |
\box\AtBeginShipoutBox |
| 322 |
}% |
| 323 |
}% |
| 324 |
% End of HO code |
| 325 |
|
| 326 |
% The following is still messy and needs to be cleanup up (everything |
| 327 |
% prefixed by pgfutil@): |
| 328 |
|
| 329 |
%\def\PackageInfo#1#2{} |
| 330 |
%\def\PackageWarning#1#2{\immediate\write17{Package #1: Warning! #2.}}% |
| 331 |
%\def\PackageError#1#2#3{\immediate\write17{Package #1: Error! #2.}}% |
| 332 |
\long\def\AtBeginDocument#1{#1}% |
| 333 |
|
| 334 |
% pgfcalendar uses translations |
| 335 |
|
| 336 |
\def\pgfutil@translate#1{#1} % is there a translator package for plain? |
| 337 |
|
| 338 |
% e-TeX primitives and beyond |
| 339 |
|
| 340 |
\let\pgfutil@protected\protected |
| 341 |
\let\pgfutil@unexpanded\unexpanded |
| 342 |
% the check for the availability of \expanded primitive is done in pgfkeys |
| 343 |
\let\pgfutil@expanded\expanded |
| 344 |
|
| 345 |
\endinput |