| 1 |
%% dvisvgm.def |
| 2 |
%% Copyright 2015 by Till Tantau |
| 3 |
%% Copyright 2016-2022 by Till Tantau and LaTeX3 Project |
| 4 |
% |
| 5 |
%% This work may be distributed and/or modified under the |
| 6 |
%% conditions of the LaTeX Project Public License, either version 1.3c |
| 7 |
%% of this license or (at your option) any later version. |
| 8 |
%% The latest version of this license is in |
| 9 |
%% http://www.latex-project.org/lppl.txt |
| 10 |
%% and version 1.3c or later is part of all distributions of LaTeX |
| 11 |
%% version 2005/12/01 or later. |
| 12 |
%% |
| 13 |
%% This work has the LPPL maintenance status `maintained'. |
| 14 |
%% |
| 15 |
%% The Current Maintainer of this work is the LaTeX3 Project. |
| 16 |
%% |
| 17 |
%% https://github.com/latex3/graphics-def/issues |
| 18 |
% |
| 19 |
\ProvidesFile{dvisvgm.def}[2022/09/22 v1.6 dvisvgm graphics driver for latex] |
| 20 |
% The following is copied from dvips.def: |
| 21 |
\def\GPT@space{ } |
| 22 |
\def\c@lor@arg#1{% |
| 23 |
\dimen@#1\p@ |
| 24 |
\ifdim\dimen@<\z@\dimen@\maxdimen\fi |
| 25 |
\ifdim\dimen@>\p@ |
| 26 |
\PackageError{color}{Argument `#1' not in range [0,1]}\@ehd |
| 27 |
\fi} |
| 28 |
\def\color@gray#1#2{% |
| 29 |
\c@lor@arg{#2}% |
| 30 |
\edef#1{gray #2}% |
| 31 |
} |
| 32 |
\def\color@cmyk#1#2{\c@lor@@cmyk#2\@@#1} |
| 33 |
\def\c@lor@@cmyk#1,#2,#3,#4\@@#5{% |
| 34 |
\c@lor@arg{#4}% |
| 35 |
\c@lor@arg{#1}% |
| 36 |
\c@lor@arg{#2}% |
| 37 |
\c@lor@arg{#3}% |
| 38 |
\edef#5{cmyk #1 #2 #3 #4}% |
| 39 |
} |
| 40 |
\def\color@rgb#1#2{\c@lor@@rgb#2\@@#1} |
| 41 |
\def\c@lor@@rgb#1,#2,#3\@@#4{% |
| 42 |
\c@lor@arg{#1}% |
| 43 |
\c@lor@arg{#2}% |
| 44 |
\c@lor@arg{#3}% |
| 45 |
\edef#4{rgb #1 #2 #3}% |
| 46 |
} |
| 47 |
\def\color@RGB#1#2{\c@lor@@RGB#2\@@#1} |
| 48 |
\def\c@lor@@RGB#1,#2,#3\@@#4{% |
| 49 |
\c@lor@RGB@rgb{#1}\@tempa |
| 50 |
\c@lor@RGB@rgb{#2}\@tempb |
| 51 |
\c@lor@RGB@rgb{#3}\@tempc |
| 52 |
\c@lor@@rgb\@tempa,\@tempb,\@tempc\@@#4% |
| 53 |
} |
| 54 |
\def\c@lor@RGB@rgb#1#2{% |
| 55 |
\dimen@#1\p@ |
| 56 |
\divide\dimen@\@cclv |
| 57 |
\edef#2{\strip@pt\dimen@}} |
| 58 |
\def\color@hsb#1#2{\c@lor@@hsb#2\@@#1} |
| 59 |
\def\c@lor@@hsb#1,#2,#3\@@#4{% |
| 60 |
\c@lor@arg{#1}% |
| 61 |
\c@lor@arg{#2}% |
| 62 |
\c@lor@arg{#3}% |
| 63 |
\edef#4{hsb #1 #2 #3}% |
| 64 |
} |
| 65 |
\def\color@named#1#2{\c@lor@@named#2,,\@@#1} |
| 66 |
\def\c@lor@@named#1,#2,#3\@@#4{% |
| 67 |
\@ifundefined{col@#1}% |
| 68 |
{\PackageError{color}{Undefined color `#1'}\@ehd}% |
| 69 |
{\edef#4{ #1}}% |
| 70 |
} |
| 71 |
% Mapping to literal Postscript, matching dvips.def, used by PSTricks |
| 72 |
\def\c@lor@to@ps#1 #2\@@{\csname c@lor@ps@#1\endcsname#2 \@@} |
| 73 |
\def\c@lor@ps@#1 #2\@@{TeXDict begin #1 end} |
| 74 |
\def\c@lor@ps@rgb#1\@@{#1 setrgbcolor} |
| 75 |
\def\c@lor@ps@hsb#1\@@{#1 sethsbcolor} |
| 76 |
\def\c@lor@ps@cmyk#1\@@{#1 setcmykcolor} |
| 77 |
\def\c@lor@ps@gray#1\@@{#1 setgray} |
| 78 |
\def\current@color{ Black} |
| 79 |
\def\set@color{\special{color push \current@color}\aftergroup\reset@color} |
| 80 |
\def\reset@color{\special{color pop}} |
| 81 |
\def\set@page@color{\special{background \current@color}} |
| 82 |
\def\define@color@named#1#2{\expandafter\let\csname col@#1\endcsname\@nnil} |
| 83 |
\def\Grot@start{% |
| 84 |
\special{ps: gsave currentpoint currentpoint translate \Grot@angle\GPT@space neg rotate neg exch neg exch translate}% |
| 85 |
\special{dvisvgm:bbox \strip@pt\wd\z@ pt \strip@pt\ht\z@ pt \strip@pt\dp\z@ pt transform}% |
| 86 |
\special{ps: grestore}% |
| 87 |
\special{dvisvgm:raw <g transform="translate({?x},{?y})scale(1,-1)rotate(\Grot@angle)scale(-1,1)translate({?x},{?y})scale(-1)">}% |
| 88 |
\special{dvisvgm:bbox lock}% |
| 89 |
} |
| 90 |
\def\Grot@end{\special{dvisvgm:bbox unlock}\special{dvisvgm:raw </g>}} |
| 91 |
\def\Gscale@start{% |
| 92 |
\special{ps: gsave currentpoint currentpoint translate \Gscale@x\GPT@space \Gscale@y\GPT@space scale neg exch neg exch translate}% |
| 93 |
\special{dvisvgm:bbox \strip@pt\wd\z@ pt \strip@pt\ht\z@ pt \strip@pt\dp\z@ pt transform}% |
| 94 |
\special{ps: grestore}% |
| 95 |
\special{dvisvgm:raw <g transform="translate({?x},{?y})scale(\Gscale@x,\Gscale@y)scale(-1)translate({?x},{?y})scale(-1)">}% |
| 96 |
\special{dvisvgm:bbox lock}% |
| 97 |
} |
| 98 |
\let\Gscale@end\Grot@end |
| 99 |
\def\Gin@extensions{.svg,.eps,.pdf,.png,.jpg,.jpeg} |
| 100 |
\def\Ginclude@pdf#1{\Ginclude@psorpdf{#1}{pdffile}} |
| 101 |
\def\Ginclude@eps#1{\let\Gin@page\@empty\Ginclude@psorpdf{#1}{PSfile}} |
| 102 |
\def\Ginclude@psorpdf#1#2{% |
| 103 |
\message{<#1>}% |
| 104 |
\bgroup |
| 105 |
\def\@tempa{!}% |
| 106 |
\dimen@\Gin@req@width |
| 107 |
\[email protected]% |
| 108 |
\divide\dimen@\dimen@ii |
| 109 |
\@tempdima\Gin@req@height |
| 110 |
\divide\@tempdima\dimen@ii |
| 111 |
\special{#2="#1"\GPT@space |
| 112 |
\ifx\Gin@page\@empty\else page=\Gin@page\GPT@space\fi |
| 113 |
llx=\Gin@llx\GPT@space |
| 114 |
lly=\Gin@lly\GPT@space |
| 115 |
urx=\Gin@urx\GPT@space |
| 116 |
ury=\Gin@ury\GPT@space |
| 117 |
\ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\GPT@space\fi |
| 118 |
\ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\GPT@space\fi |
| 119 |
\ifGin@clip clip\fi |
| 120 |
}% |
| 121 |
\egroup} |
| 122 |
\@namedef{Gin@[email protected]}#1{{eps}{.ps}{#1}} |
| 123 |
\@namedef{Gin@[email protected]}#1{{eps}{.eps}{#1}} |
| 124 |
\@namedef{Gin@[email protected]}#1{{eps}{.mps}{#1}} |
| 125 |
\@namedef{Gin@[email protected]}#1{{pdf}{.xbb}{#1}} |
| 126 |
% BoundingBox determination (from dvipdfmx.def) |
| 127 |
\def\Gread@pdf#1{% |
| 128 |
\Gread@generic{#1}\Gread@extractbb@aux% |
| 129 |
}% |
| 130 |
\def\Gread@extractbb@aux#1{% |
| 131 |
\ifeof\@inputcheck% |
| 132 |
\immediate\openin\@inputcheck=% |
| 133 |
"|extractbb % |
| 134 |
\ifx\Gin@page\@empty\else -p \Gin@page\GPT@space\fi |
| 135 |
\ifx\Gin@pagebox\@empty\else -B \Gin@pagebox\GPT@space\fi |
| 136 |
-O \Gin@base\Gin@ext"% |
| 137 |
\fi% |
| 138 |
\Gread@true% |
| 139 |
\let\@tempb\Gread@false% |
| 140 |
\ifeof\@inputcheck% |
| 141 |
\@latex@error% |
| 142 |
{Cannot run pipe command. Try --shell-escape\MessageBreak% |
| 143 |
(--enable-pipes in MikTeX) option}% |
| 144 |
{Alternatively, execute\MessageBreak\space\space |
| 145 |
extractbb |
| 146 |
\ifx\Gin@page\@empty\else -p \Gin@page\GPT@space\fi |
| 147 |
\ifx\Gin@pagebox\@empty\else -B \Gin@pagebox\GPT@space\fi |
| 148 |
\Gin@base\Gin@ext\MessageBreak in a terminal.}% |
| 149 |
\else% |
| 150 |
\loop% |
| 151 |
\read\@inputcheck to\@tempa% |
| 152 |
\ifeof\@inputcheck% |
| 153 |
\Gread@false% |
| 154 |
\else% |
| 155 |
\expandafter\Gread@find@bb\@tempa:.\\% |
| 156 |
\fi% |
| 157 |
\ifGread@% |
| 158 |
\repeat% |
| 159 |
\immediate\closein\@inputcheck% |
| 160 |
\fi% |
| 161 |
} |
| 162 |
\def\Ginclude@bitmap#1{% |
| 163 |
\dimen@\Gin@urx pt% |
| 164 |
\advance\dimen@ by-\Gin@llx pt% |
| 165 |
\edef\Gin@svg@view@width{\strip@pt\dimen@}% |
| 166 |
\dimen@\Gin@ury pt% |
| 167 |
\advance\dimen@ by-\Gin@lly pt% |
| 168 |
\edef\Gin@svg@view@height{\strip@pt\dimen@}% |
| 169 |
\dimen@\Gin@svg@real@height@bp pt% |
| 170 |
\advance\dimen@ by-\Gin@ury pt% |
| 171 |
\edef\Gin@svg@view@base{\strip@pt\dimen@}% |
| 172 |
\special{dvisvgm:bbox \strip@pt\Gin@req@width pt \strip@pt\Gin@req@height pt transform}% |
| 173 |
\Gin@[email protected]\Gin@req@width% |
| 174 |
\Gin@[email protected]\Gin@req@height% |
| 175 |
\raise\strip@pt\Gin@req@height bp\hbox{% |
| 176 |
\special{dvisvgm: raw |
| 177 |
<g transform="translate({?x},{?y})">% |
| 178 |
<svg overflow="\ifGin@clip hidden\else visible\fi" width="\strip@pt\Gin@req@width" height="\strip@pt\Gin@req@height" |
| 179 |
viewBox="\Gin@llx\GPT@space\Gin@svg@view@base\GPT@space\Gin@svg@view@width\GPT@space\Gin@svg@view@height">% |
| 180 |
<image width="\Gin@svg@real@width@bp" height="\Gin@svg@real@height@bp" xlink:href="#1"/>% |
| 181 |
</svg>% |
| 182 |
</g>}% |
| 183 |
}% |
| 184 |
} |
| 185 |
|
| 186 |
\@namedef{Gin@[email protected]}#1{{svg}{.svg}{#1}} |
| 187 |
\let\Ginclude@svg\Ginclude@bitmap |
| 188 |
\def\Gread@svg#1{% |
| 189 |
\begingroup |
| 190 |
\catcode`\"12\relax% |
| 191 |
\immediate\openin\@inputcheck#1 % |
| 192 |
\ifeof\@inputcheck |
| 193 |
\@latex@error{File `#1' not found}\@ehc |
| 194 |
\else |
| 195 |
\let\Gin@urx\relax |
| 196 |
\let\Gin@ury\relax |
| 197 |
\Gread@true |
| 198 |
\let\@tempb\Gread@false |
| 199 |
\loop |
| 200 |
\read\@inputcheck to\@tempa |
| 201 |
\ifeof\@inputcheck |
| 202 |
\Gread@false |
| 203 |
\else |
| 204 |
\ifx\@tempa\Gin@partext\else |
| 205 |
\ifx\Gin@ury\relax\expandafter\Gread@svg@height\@tempa height=\relax\fi% |
| 206 |
\ifx\Gin@urx\relax\expandafter\Gread@svg@width\@tempa width=\relax\fi% |
| 207 |
\fi% |
| 208 |
\fi |
| 209 |
\ifx\Gin@urx\relax\else\ifx\Gin@ury\relax\else\Gread@false\fi\fi% |
| 210 |
\ifGread@ |
| 211 |
\repeat |
| 212 |
\immediate\closein\@inputcheck |
| 213 |
\ifx\Gin@urx\relax |
| 214 |
\@latex@error{Cannot determine width of graphic in #1 (no BoundingBox)}\@ehc |
| 215 |
\def\Gin@urx{72}% |
| 216 |
\fi |
| 217 |
\ifx\Gin@ury\relax |
| 218 |
\@latex@error{Cannot determine height of graphic in #1 (no BoundingBox)}\@ehc |
| 219 |
\def\Gin@ury{72}% |
| 220 |
\fi |
| 221 |
\fi |
| 222 |
\edef\Gin@setter{\def\noexpand\Gin@urx{\Gin@urx}\def\noexpand\Gin@ury{\Gin@ury}}% |
| 223 |
\expandafter\endgroup\Gin@setter% |
| 224 |
\def\Gin@llx{0}% |
| 225 |
\def\Gin@lly{0}% |
| 226 |
\edef\Gin@svg@real@width@bp{\Gin@urx}% |
| 227 |
\edef\Gin@svg@real@height@bp{\Gin@ury}% |
| 228 |
} |
| 229 |
\def\Gin@partext{\par} |
| 230 |
\def\Gread@svg@height#1height={\@ifnextchar\relax{}{\@ifnextchar'\Gread@svg@height@apo\Gread@svg@height@double}} |
| 231 |
\def\Gread@svg@height@apo'#1'#2\relax{\afterassignment\Gin@gobble@till@relax\dimen@#1pt\relax\edef\Gin@ury{\strip@pt\dimen@}} |
| 232 |
\def\Gread@svg@height@double"#1"#2\relax{\afterassignment\Gin@gobble@till@relax\dimen@#1pt\relax\edef\Gin@ury{\strip@pt\dimen@}} |
| 233 |
\def\Gread@svg@width#1width={\@ifnextchar\relax{}{\@ifnextchar'\Gread@svg@width@apo\Gread@svg@width@double}} |
| 234 |
\def\Gread@svg@width@apo'#1'#2\relax{\afterassignment\Gin@gobble@till@relax\dimen@#1pt\relax\edef\Gin@urx{\strip@pt\dimen@}} |
| 235 |
\def\Gread@svg@width@double"#1"#2\relax{\afterassignment\Gin@gobble@till@relax\dimen@#1pt\relax\edef\Gin@urx{\strip@pt\dimen@}} |
| 236 |
\def\Gin@gobble@till@relax#1\relax{} |
| 237 |
\edef\Gin@hash@tag{\string#} |
| 238 |
|
| 239 |
\@namedef{Gin@[email protected]}#1{{bitmap}{.xbb}{#1}} |
| 240 |
\@namedef{Gin@[email protected]}#1{{bitmap}{.xbb}{#1}} |
| 241 |
\@namedef{Gin@[email protected]}#1{{bitmap}{.xbb}{#1}} |
| 242 |
|
| 243 |
% Replace |
| 244 |
\def\Gread@bitmap#1{% |
| 245 |
\Gread@generic{#1}\Gread@extractbb@aux% |
| 246 |
\dimen@\Gin@urx pt% |
| 247 |
\advance\dimen@ by-\Gin@llx pt% |
| 248 |
\edef\Gin@svg@real@width@bp{\strip@pt\dimen@}% |
| 249 |
\dimen@\Gin@ury pt% |
| 250 |
\advance\dimen@ by-\Gin@lly pt% |
| 251 |
\edef\Gin@svg@real@height@bp{\strip@pt\dimen@}% |
| 252 |
} |
| 253 |
|
| 254 |
\endinput |
| 255 |
%% |
| 256 |
%% End of file `dvisvgm.def'. |