| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
% |
| 3 |
% Module: ZzTeX PostScript Facilities |
| 4 |
% |
| 5 |
% Synopsis: This module contains any and all facilities that rely on |
| 6 |
% PostScript output. |
| 7 |
% |
| 8 |
% Author: Paul C. Anagnostopoulos |
| 9 |
% Created: 21 January 1994 |
| 10 |
% |
| 11 |
% Copyright 1989--2020 by Paul C. Anagnostopoulos |
| 12 |
% under The MIT License (opensource.org/licenses/MIT) |
| 13 |
% |
| 14 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 15 |
|
| 16 |
% Extra Encoded Characters |
| 17 |
% ----- ------- ---------- |
| 18 |
|
| 19 |
|
| 20 |
\def \PSbackslash {\char 134\relax} |
| 21 |
\def \PSbar {\char 138\relax} |
| 22 |
\def \PSbullet {\char 142\relax} |
| 23 |
\def \PSbraceleft {\char 137\relax} |
| 24 |
\def \PSbraceright {\char 139\relax} |
| 25 |
\def \PScent {\char 148\relax} |
| 26 |
\def \PScopyright {\char 145\relax} |
| 27 |
\def \PScurrency {\char 149\relax} |
| 28 |
\def \PSdagger {\char 140\relax} |
| 29 |
\def \PSddagger {\char 141\relax} |
| 30 |
\def \PSdollar {\char 131\relax} |
| 31 |
\def \PSgreater {\char 133\relax} |
| 32 |
\def \PSless {\char 132\relax} |
| 33 |
\def \PSordfeminine {\char 155\relax} |
| 34 |
\def \PSordmasculine {\char 156\relax} |
| 35 |
\def \PSparagraph {\char 143\relax} |
| 36 |
\def \PSperthousand {\char 157\relax} |
| 37 |
\def \PSpolishL {\char "A1\relax} |
| 38 |
\def \PSpolishl {\char "A2\relax} |
| 39 |
\def \PSregistered {\char 146\relax} |
| 40 |
\def \PSsection {\char 144\relax} |
| 41 |
\def \PSsterling {\char 158\relax} |
| 42 |
\def \PStrademark {\char 147\relax} |
| 43 |
\def \PSunderscore {\char 136\relax} |
| 44 |
\def \PSudquote {\char 135\relax} |
| 45 |
\def \PSusquote {\char 160\relax} |
| 46 |
\def \PSyen {\char 159\relax} |
| 47 |
|
| 48 |
% Import EPS File |
| 49 |
% ------ --- ---- |
| 50 |
|
| 51 |
|
| 52 |
% The illustration \special is compatible with DVIPSONE, and with TeXtures |
| 53 |
% if clip? is false. |
| 54 |
% The scale is interpreted as follows: |
| 55 |
% <= 33.333: normal scale, 1.0 = 100% |
| 56 |
% > 33.333: TeX scale factor, 1000 = 100% |
| 57 |
|
| 58 |
\def \specialimportartfile #1#2#3{% {name}{scale}{clip?} |
| 59 |
\special{illustration #1 scaled #2 |
| 60 |
\if #3clip\fi}} |
| 61 |
|
| 62 |
% This macro is a better variant of the preceding one. The scale |
| 63 |
% argument is a true scale specified in points. |
| 64 |
|
| 65 |
\def \specialplaceepsfile #1#2#3{% {name}{scale}{clip?} |
| 66 |
{\tdimena = #2% |
| 67 |
\if \dimgtrp{\tdimena}{33.333pt}% % Compensate for bizarre |
| 68 |
\multiply \tdimena by 1000\relax % design of scaled option. |
| 69 |
\fi |
| 70 |
\special{illustration #1 scaled \thefactor\tdimena |
| 71 |
\if #3\space clip\fi}}} |
| 72 |
|
| 73 |
% This macro is used to import an EPS file for a glyph. The scale |
| 74 |
% is specified as a percentage IN POINTS. |
| 75 |
|
| 76 |
\def \specialplaceglyph #1#2#3{% {name}{percentage}{clip?} |
| 77 |
{\tdimena = #2% |
| 78 |
\divide \tdimena by 100 |
| 79 |
\special{illustration #1 scaled \thefactor\tdimena |
| 80 |
\if #3\space clip\fi}}} |
| 81 |
|
| 82 |
% Read EPS Bounding Box |
| 83 |
% ---- --- -------- --- |
| 84 |
|
| 85 |
|
| 86 |
\definedimen{\zbbxorigin}{0pt} |
| 87 |
\definedimen{\zbbyorigin}{0pt} |
| 88 |
|
| 89 |
|
| 90 |
{\catcode`\%=\catother |
| 91 |
\gdef \zpercent {%} |
| 92 |
} % \catcode |
| 93 |
|
| 94 |
\edef \zboundingbox {\zpercent\zpercent BoundingBox} |
| 95 |
\def \zatend {atend} |
| 96 |
\definecount{\zbbstate}{0} |
| 97 |
|
| 98 |
|
| 99 |
\def \zreadepsbb #1#2#3{% {\width}{\height}{file} |
| 100 |
\def \zbbinfo {}% |
| 101 |
\begingroup |
| 102 |
\zsetepscatcodes |
| 103 |
\openin \zreada #3\relax |
| 104 |
\zbbstate = 0 |
| 105 |
\loop |
| 106 |
\read \zreada to \zline |
| 107 |
\ifeof \zreada |
| 108 |
\zbbstate = 2 |
| 109 |
\else |
| 110 |
\expandafter\zcheckbb \zline:.\zmark |
| 111 |
\fi |
| 112 |
\ifnum \zbbstate < 2 \repeat |
| 113 |
\closein \zreada |
| 114 |
\endgroup |
| 115 |
\zsetbbsizes{#1}{#2}{#3}} |
| 116 |
|
| 117 |
\def \zsetepscatcodes {% |
| 118 |
\catcoderange{0}{"1F}{\catcomment}% |
| 119 |
\catcode `\^^I = \catspace |
| 120 |
\catcode \endlinechar = \catendofline |
| 121 |
\uncatcode{\false}{\false}{\false}% |
| 122 |
\catcode `\: = \catother |
| 123 |
\catcoderange{"7E}{"FF}{\catcomment}} |
| 124 |
|
| 125 |
\long \def \zcheckbb #1:#2#3\zmark{% |
| 126 |
\def \znext {#1}% |
| 127 |
\ifx \znext \zboundingbox |
| 128 |
\zcheckatend #2#3()\zmark |
| 129 |
\fi} |
| 130 |
|
| 131 |
\long \def \zcheckatend #1(#2)#3\zmark{% |
| 132 |
\def \znext {#2}% |
| 133 |
\ifx \znext \zatend |
| 134 |
\zbbstate = 1 |
| 135 |
\else |
| 136 |
\gdef \zbbinfo {#1}% |
| 137 |
\ifnum \zbbstate = 0 \zbbstate = 2\fi |
| 138 |
\fi} |
| 139 |
|
| 140 |
\def \zsetbbsizes #1#2#3{% |
| 141 |
\if \emptydefp{\zbbinfo}% |
| 142 |
\warning{missbb}{Art file `#3' has no bounding box}% |
| 143 |
#1 = 20pc #2 = 10pc |
| 144 |
\else |
| 145 |
\expandafter \zcalcbb \zbbinfo \zmark{#1}{#2}% |
| 146 |
\fi} |
| 147 |
|
| 148 |
\def \zcalcbb #1 #2 #3 #4 #5\zmark#6#7{% |
| 149 |
\calculate #6= {#3pt,-,#1pt,+,1pt}% |
| 150 |
\calculate #7= {#4pt,-,#2pt,+,1pt}% |
| 151 |
\global\zbbxorigin = #1pt |
| 152 |
\global\zbbyorigin = #2pt\relax} |
| 153 |
|
| 154 |
% Rotate Boxes |
| 155 |
% ------ ----- |
| 156 |
|
| 157 |
|
| 158 |
\def \rotatebox #1#2{% {\box}{degrees} |
| 159 |
\special{CTM: push rotate #2}% |
| 160 |
\box #1% |
| 161 |
\special{CTM: pop}} |
| 162 |
|
| 163 |
\def \rotatetext #1#2{% {text}{degrees} |
| 164 |
\setbox \zboxa = \hbox{#1}% |
| 165 |
\rotatebox{\zboxa}{#2}} |
| 166 |
|
| 167 |
% Colors |
| 168 |
% ------ |
| 169 |
|
| 170 |
|
| 171 |
\def \colorspecial #1{% |
| 172 |
\if \allowcolor |
| 173 |
\special{#1}% |
| 174 |
\fi} |
| 175 |
|
| 176 |
% These commands are called in the output routine to make sure that |
| 177 |
% everything added in the output routine is black. |
| 178 |
|
| 179 |
\def \zoutputbeginblack {% |
| 180 |
\colorspecial{color push gray 0}} |
| 181 |
|
| 182 |
\def \zoutputendblack {% |
| 183 |
\colorspecial{color pop}} |
| 184 |
|
| 185 |
% Color Block |
| 186 |
% ---- ------ |
| 187 |
|
| 188 |
|
| 189 |
\defineblock{\color}{\endcolor}{\false}{} |
| 190 |
|
| 191 |
%~block color Type |
| 192 |
% \colorspec = {...} % Color specifier. |
| 193 |
%~end |
| 194 |
|
| 195 |
\definetoks{\colorspec} |
| 196 |
|
| 197 |
|
| 198 |
\def \color #1{% {type} |
| 199 |
\beginblockscope{color}% |
| 200 |
\global\increment \colordepth |
| 201 |
\processdesign{\color}{#1}% |
| 202 |
\global\increment \colornumber |
| 203 |
\colorspecial{color push}% |
| 204 |
\the\colorspec\zmark |
| 205 |
\if \vmodep \vpenalty{\breaknever}\fi} |
| 206 |
|
| 207 |
\def \endcolor {% |
| 208 |
\global\decrement \colordepth |
| 209 |
\endblockscope{color}% |
| 210 |
\colorspecial{color pop}} |
| 211 |
|
| 212 |
|
| 213 |
\def \setcolor #1{% |
| 214 |
\begingroup |
| 215 |
\processdesign{\color}{#1}% |
| 216 |
\the\colorspec\zmark |
| 217 |
\endgroup} |
| 218 |
|
| 219 |
% Color specifiers: |
| 220 |
|
| 221 |
\def \cmykcolor #1 #2 #3 #4\zmark{% c m y k\zmark |
| 222 |
\colorspecial{color cmyk #1 #2 #3 #4}} |
| 223 |
|
| 224 |
\def \graycolor #1\zmark{% gray\zmark |
| 225 |
\colorspecial{color gray #1}} |
| 226 |
|
| 227 |
\def \rgbcolor #1 #2 #3\zmark{% r g b\zmark |
| 228 |
\colorspecial{color rgb #1 #2 #3}} |
| 229 |
|
| 230 |
% Built-in colors: |
| 231 |
|
| 232 |
\def \colorblackdesign {% |
| 233 |
\colorspec = {\graycolor 0}} |
| 234 |
|
| 235 |
\def \colorwhitedesign {% |
| 236 |
\colorspec = {\graycolor 1}} |
| 237 |
|
| 238 |
\def \colorproofnotereddesign {% |
| 239 |
\colorspec = {\rgbcolor .5 0 0}} |
| 240 |
|
| 241 |
% A useful shorthand: |
| 242 |
|
| 243 |
\def \colortext #1#2{% {color}{text} |
| 244 |
\color{#1}#2\endcolor} |
| 245 |
|
| 246 |
% TeXtures |
| 247 |
% -------- |
| 248 |
|
| 249 |
|
| 250 |
\def \TeXtures {% |
| 251 |
\input zztures\relax} |