1 %% This is file `xetex.def
' for XeTeX,
2 %% based upon other drivers for LaTeX color and graphics support.
4 %% Copyright 2004-2007, 2009, 2013-2014
5 %% Ross Moore <ross@maths.mq.edu.au>
6 %% modified by Jonathan Kew et al.
8 %% This file is not part of the Standard LaTeX `Graphics Bundle'.
9 %% It may be distributed under the terms of the LaTeX Project Public
10 %% License
, as described in lppl.txt in the base LaTeX distribution.
11 %% Either version
1.0 or
, at your option
, any later version.
13 %% This driver is developed at
:
14 %% http
://puszcza.gnu.org.ua
/projects
/latexfmxdef
15 %% Please report bugs and patches through the tracker there.
16 %% Official releases
, though
, are made through CTAN
:
17 %% http
://www.ctan.org
/pkg
/xetex
-def
18 %% http
://www.ctan.org
/pkg
/xetex
-def
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23 %% 2014/04/28 [KB
] [v4.03
] \newif outside \def. Skipped
4.02.
25 %% 2014/04/28 [HO
] [v4.01
] .CAPS extensions.
26 %% [KB
] ordering
: find .jpeg just after .jpg
,
27 %% more like dvipdfmx.def. Also remove .sga
/.sgi
,
28 %% which were mismatched and never noticed.
29 %% Change version number to match dvipdfmx.def.
31 %% 2014/04/07 [AK
] [v0.99
] remove spurious spaces.
33 %% 2014/03/24 [AK
] [v0.98
] non
-origin viewport
, avoid double bp conversion.
35 %% 2014/03/21 [KB
] doc tweaks for project home at puszcza.gnu.org.ua.
37 %% 2013/05/27 [KB
] Version v0.97 non
-commutative operations.
38 %% (code provided by Bruno Voisin
)
40 %% 2013/04/29 [KB
] Version v0.96 handle non
-origin ll corner.
41 %% (code provided by Bruno Voisin
)
43 %% 2013/02/04 [RRM
] Version v0.95 added clipping support.
44 %% (code provided by Joseph Wright and Martin Scharrer
)
46 %% 2009/11/21 [KB
] Version v0.94 merge the two
0.93's.
48 %% 2009/10/28 [RRM] Version v0.93 fix big-point incompatibility;
50 %% 2007/10/25 [JK] Version v0.93 added EPS support from dvipdfmx.def
51 %% (for use with xdvipdfmx, default driver in xetex 0.997)
53 %% 2006/08/10 [JK] Version v0.92 correct type-check in \G@measure@QTm;
54 %% remove \G@PDF@ext, apply \lowercase instead;
55 %% make \XeTeXquote have catcode 12 rather than 11;
56 %% explicit space after "filename.ext" (reqd by xetex 0.995)
58 %% 2006/07/19 [JK] Version v0.91 use \special{color ...} rather than
59 %% \special{x:textcolor ...} etc, for compatibility with
60 %% both xdv2pdf and xdvipdfmx drivers;
61 %% added .bmp to list of recognized graphics extensions
63 %% 2006/01/09 [JK] Version v0.9 removed support for XeTeX versions
64 %% prior to 0.6 (when the \XeTeXpicfile parameters were
65 %% modified), to avoid problem when \XeTeXrevision inc. letters
67 %% 2005/10/12 Version v0.8 removed spurious space in \convertHEX@
68 %% -- found by Morten Hogholm
70 %% 2004/05/09 Version v0.7 changed support for \pagecolor, adapted
71 %% from pdftex.def, to put a \special in the \shipout ;
72 %% this driver should now work with miniltx.tex ;
73 %% changed some control-sequence names;
74 %% implemented HSB to RGB color conversion
75 %% identified the redundant (v0.5) coding more clearly.
77 %% 2004/05/08 Version v0.6 properly implements scaling and rotations
78 %% following the coding used with pdftex.def ;
79 %% implemented `viewport' and prepared for `clip
';
80 %% don't rely on
" to have correct catcode;
81 %% altered the suffix order for graphics, to be:
82 %% .pdf .png .jpg .pict .tif ....
84 %% 2004/04/29 Version v0.5 adapts to the changed names for the
85 %% graphics inclusion primitives, and version strings.
87 %% 2004/04/23 Version v0.41 works with graphics.sty as well as
88 %% graphicx.sty ; \G@pdf@ext is '.pdf';
89 %% similarly define and use \G@PDF@ext for '.PDF';
90 %% removed some log-messages.
92 %% 2004/04/22 Version v0.4 designed to work with XeTeX v0.4
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 \ProvidesFile{xetex.def}
97 [2014/07/25 v4.03 LaTeX color/graphics driver for XeTeX (RRM/JK)]
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 % make sure we can use " with correct catcode
105 % miniltx.tex does not define \PackageWarning
106 % or \PackageWarningNoLine.
107 \@ifundefined{PackageWarning}{%
108 \def\PackageWarning#1#2{%
112 ^^J(#1)\@spaces\@spaces\@spaces\@spaces
114 \immediate\write16{^^JPackage #1 Warning: #2\on@line.^^J}%
118 \@ifundefined{PackageWarningNoLine}{%
119 \def\PackageWarningNoLine#1#2{%
120 \PackageWarning{#1}{#2\@gobble}%
123 \@ifundefined{on@line}{%
124 \def\on@line{ on input line \the\inputlineno}%
126 \@ifundefined{@spaces}{%
127 \def\@spaces{\space\space\space\space}%
129 \def\GXT@warn{\PackageWarning{xetex.def}}%
130 \ifx\Gin@log\@undefined
131 \def\Gin@log{\message}
134 % Colour Support. The following models may be used.
137 % * gray /-- all passed directly to the driver
139 % * RGB ---- converted to rgb here
144 \ifdim\dimen@<\z@\dimen@\maxdimen\fi
146 \PackageError{color}{Argument `#1' not in range [0,1]}\@ehd
148 \def\color@gray#1#2{%
152 \def\color@cmyk#1#2{\c@lor@@cmyk#2\@@#1}
153 \def\c@lor@@cmyk#1,#2,#3,#4\@@#5{%
158 \edef#5{cmyk #1 #2 #3 #4}%
160 \def\color@rgb#1#2{\c@lor@@rgb#2\@@#1}
161 \def\c@lor@@rgb#1,#2,#3\@@#4{%
165 \edef#4{rgb #1 #2 #3}%
167 \def\color@RGB#1#2{\c@lor@@RGB#2\@@#1}
168 \def\c@lor@@RGB#1,#2,#3\@@#4{%
169 \c@lor@RGB@rgb{#1}\@tempa
170 \c@lor@RGB@rgb{#2}\@tempb
171 \c@lor@RGB@rgb{#3}\@tempc
172 \c@lor@@rgb\@tempa,\@tempb,\@tempc\@@#4%
174 \def\c@lor@RGB@rgb#1#2{%
177 \edef#2{\strip@pt\dimen@}}
178 \def\color@hsb#1#2{\c@lor@@hsb#2\@@#1}
179 \def\c@lor@@hsb#1,#2,#3\@@#4{%
183 \edef#4{hsb #1 #2 #3}%
185 \def\color@named#1#2{\c@lor@@named#2,,\@@#1}
186 \def\c@lor@@named#1,#2,#3\@@#4{%
187 \@ifundefined{col@#1}%
188 {\PackageError{color}{Undefined color `#1'}\@ehd}%
192 \def\current@color{ Black}% Match dvips to reduce test diffs
195 % v0.02t: support for \pagecolor
196 \def\set@page@color{%
197 \global\let\current@page@color\current@color
198 \@ifundefined{GXTorg@shipout}{%
199 \global\let\GXTorg@shipout\shipout
201 \afterassignment\GXT@shipout
202 \global\setbox\@cclv=%
206 \aftergroup\GXT@@shipout
209 \GXTorg@shipout\vbox{%
216 \GXTorg@shipout\box\@cclv\relax
218 \gdef\GXT@setpagecolor{%
219 \special{background \current@page@color}%
224 \def\set@color@stack{%
225 \special{color push \current@color}%
226 \aftergroup\reset@color
228 \def\set@color@nostack{%
229 \special{color \current@color}%
230 \aftergroup\reset@color
232 \def\reset@color@nostack{%
233 \special{color \current@color}%
234 \expandafter\checkfor@moreresets
236 \def\reset@color@stack{%
238 \expandafter\checkfor@moreresets
240 \def\checkfor@moreresets{\futurelet\tmp\checkfor@moreresets@}
241 \def\checkfor@moreresets@{%
242 \ifx\tmp\reset@color\expandafter\gobble@color\fi}
243 \def\gobble@color#1{\checkfor@moreresets}
245 \def\define@color@named#1#2{%
246 \expandafter\edef\csname col@#1\endcsname{#2}}
248 \def\check@for@XeTeX@colorstack{%
249 \expandafter\ifx\csname use@XeTeX@colorstack\endcsname\relax
250 \let\set@color\set@color@stack
251 \let\reset@color\reset@color@stack
252 \let\checkfor@moreresets\relax
254 \let\set@color\set@color@nostack
255 \let\reset@color\reset@color@nostack
259 % use \noXeTeXcolorstack to turn off the color-stack
260 % mechanism; use it within the preamble only.
261 % This may be useful with some packages
262 % e.g. TeXpower which makes partial page-builds.
264 \def\noXeTeXcolorstack{\def\use@XeTeX@colorstack{}}
265 \AtBeginDocument{\check@for@XeTeX@colorstack}
267 % < end of color support for XeTeX >
269 % < graphics inclusion for XeTeX >
271 % PDF is a special case which has extra features
274 % \Gin@XeTeX@page: page number of pdf image or \@empty otherwise.
275 % This code adapted from pdftex.def
276 \let\Gin@XeTeX@page\@empty
278 \toks@{\define@key{Gin}{page}{\def\Gin@XeTeX@page{#1}}}%
279 \@ifundefined{define@key}{%
280 \edef\x{\endgroup\noexpand\AtBeginDocument{%
281 \noexpand\@ifundefined{define@key}{}{\the\toks@}}%
283 }{\expandafter\endgroup\the\toks@}
285 % rotating graphics is supported, but
286 % rotation of arbitrary material is not supported yet
288 \def\GXT@erotate#1#2{\Grot@setangle{#1}\hbox{#2}}%
289 \def\set@GXT@erotate{\let\Gin@erotate\GXT@erotate}
290 %\AtBeginDocument{\set@GXT@erotate}
292 \expandafter\ifx\csname XeTeXpicfile\endcsname\relax
293 \let\picfile@cmd\picfile
294 \let\pdffile@cmd\pdffile
296 \let\picfile@cmd\XeTeXpicfile
297 \let\pdffile@cmd\XeTeXpdffile
300 % all graphics are handled by Apple's QuickTime
302 \def\XeTeX@include@QTm#1{%
305 \noexpand\lowercase{%
306 \noexpand\def\noexpand\type@ext{\Gin@ext}%
309 \ifx\type@ext\G@pdf@ext
310 \ifx\Gin@XeTeX@page\@empty\else
311 \edef\picpage{ page\Gin@XeTeX@page}\fi
312 \def\picfilecommand{\pdffile@cmd}%
314 \def\picfilecommand{\picfile@cmd}%
316 \edef\picfileargs{ \XeTeXquote#1\XeTeXquote\space\picpage}%
320 \ifx\Gscale@start\relax
321 \setbox\z@=\hbox{\expandafter\picfilecommand\picfileargs}%
322 \edef\next{\box\z@\egroup
323 \def\noexpand\width{\the\wd\z@}\relax
324 \def\noexpand\height{\the\ht\z@}\bgroup}%
327 \XeTeX@scaleinclude{#1}%
330 \def\XeTeX@scaleinclude#1{%
332 \ifx\Gin@scaley\@tempa
333 \let\Gin@scaley\Gin@scalex
335 \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi
338 \Gscale@box{\Gin@scalex}[\Gin@scaley]{%
339 \@ifundefined{Gin@vllx}{%
341 % without viewport/trim clipping does not make sense
346 \if!\Gin@vllx\Gin@vlly\Gin@vurx\Gin@vury!%
348 \let\GXT@clipend\GXT@DoClipEnd
349 \setbox\@tempboxa\hbox\bgroup
353 \ifdim\Gin@vlly\p@=\z@
355 \lower\Gin@vlly bp\hbox\bgroup
357 \ifdim\Gin@vllx\p@=\z@
359 \hskip-\Gin@vllx bp\relax
363 \expandafter\picfilecommand\picfileargs
366 \ifdim\Gin@vlly\p@=\z@
375 \newif\ifGXT@viewport
377 \let\GXT@clipend\relax
381 % \Gin@urx and \Gin@ury already contain the correct values,
382 % so both cases viewport and trim can be handled together:
384 \advance\dimen@ -\Gin@vllx\p@
385 \wd\@tempboxa\strip@pt\dimen@ bp\relax
386 % \wd\@tempboxa\dimen@ \relax
388 \advance\dimen@ -\Gin@vlly\p@
389 \ht\@tempboxa\strip@pt\dimen@ bp\relax
390 % \ht\@tempboxa\dimen@ \relax
391 % Clip box to its official size
392 \GXT@clipbox\@tempboxa
395 % Clipping support added by Martin Scharrer and Joseph Wright, Nov 2011
396 % under the LPPL v1.0 or later.
399 \Gin@defaultbp\WIDTH{\wd#1}%
400 \Gin@defaultbp\DEPTH{\dp#1}%
402 \advance\@tempdima\dp#1%
403 \Gin@defaultbp\TOTALHEIGHT{\@tempdima}%
404 \special{pdf:content q }%
407 0 -\DEPTH\space \WIDTH\space \TOTALHEIGHT\space re
409 \special{pdf:literal direct W }%
410 \special{pdf:literal direct n }%
411 \special{pdf:literal direct -1 0 0 -1 0 0 cm }%
412 \special{pdf:content q }%
413 \special{pdf:literal direct -1 0 0 -1 0 0 cm }%
415 \special{pdf:literal direct Q }%
416 \special{pdf:literal direct Q }%
419 % End of clipping code
422 \def\Gread@QTm#1{\IfFileExists{\Gin@base.bb}%
423 {\Gread@eps{\Gin@base.bb}}%
424 {\G@measure@QTm{\Gin@base}{\Gin@ext}}%
426 \def\G@measure@QTm#1#2{%
427 % \@warning{measuring size of QuickTime graphic #1#2}%
430 \noexpand\lowercase{%
431 \noexpand\def\noexpand\type@ext{#2}%
434 \ifx\type@ext\G@pdf@ext
435 \ifx\Gin@XeTeX@page\@empty \def\picpage{}%
436 \else \edef\picpage{ page\Gin@XeTeX@page}\fi
439 \ifx\type@ext\G@pdf@ext
440 \edef\piccommand{\noexpand\pdffile@cmd
441 \XeTeXquote#1#2\XeTeXquote\space\picpage}%
443 \edef\piccommand{\noexpand\picfile@cmd
444 \XeTeXquote#1#2\XeTeXquote\space}%
447 }\dimen0=\wd0 \dimen2=\ht0
449 \edef\noexpand\Gin@urx{\the\dimen0}%
450 \edef\noexpand\Gin@ury{\the\dimen2}%
453 \Gin@defaultbp\Gin@llx{0}%
454 \Gin@defaultbp\Gin@lly{0}%
455 \expandafter\Gin@defaultbp\expandafter\Gin@urx\expandafter{\Gin@urx}%
456 \expandafter\Gin@defaultbp\expandafter\Gin@ury\expandafter{\Gin@ury}%
457 % \typeout{XeTeX: HiRes BoundingBox = (0,0)\space x (\Gin@urx,\Gin@ury) }%
458 \Gin@nat@width=\Gin@urx\p@
459 \Gin@nat@height=\Gin@ury\p@
460 % these emulate \@begin@tempboxa
461 \edef\width{\the\Gin@nat@width}%
462 \edef\height{\the\Gin@nat@height}%
464 \let\totalheight\@ovri
468 \let\Ginclude@QTm\XeTeX@include@QTm
470 % For a new graphics type, you can include a line here ...
471 \@namedef{Gin@rule@.pdf}#1{{QTm}{QTm}{#1}}
472 \@namedef{Gin@rule@.PDF}#1{{QTm}{QTm}{#1}}
474 \@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
475 \@namedef{Gin@rule@.EPS}#1{{eps}{.EPS}{#1}}
477 \@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
478 \@namedef{Gin@rule@.PS}#1{{eps}{.PS}{#1}}
480 \@namedef{Gin@rule@.png}#1{{QTm}{QTm}{#1}}
481 \@namedef{Gin@rule@.PNG}#1{{QTm}{QTm}{#1}}
483 \@namedef{Gin@rule@.jpg}#1{{QTm}{QTm}{#1}}
484 \@namedef{Gin@rule@.JPG}#1{{QTm}{QTm}{#1}}
485 \@namedef{Gin@rule@.jpeg}#1{{QTm}{QTm}{#1}}
486 \@namedef{Gin@rule@.JPEG}#1{{QTm}{QTm}{#1}}
488 \@namedef{Gin@rule@.bmp}#1{{QTm}{QTm}{#1}}
489 \@namedef{Gin@rule@.BMP}#1{{QTm}{QTm}{#1}}
491 \@namedef{Gin@rule@.pict}#1{{QTm}{QTm}{#1}}
492 \@namedef{Gin@rule@.PICT}#1{{QTm}{QTm}{#1}}
494 \@namedef{Gin@rule@.psd}#1{{QTm}{QTm}{#1}}
495 \@namedef{Gin@rule@.PSD}#1{{QTm}{QTm}{#1}}
497 \@namedef{Gin@rule@.mac}#1{{QTm}{QTm}{#1}}
498 \@namedef{Gin@rule@.MAC}#1{{QTm}{QTm}{#1}}
499 \@namedef{Gin@rule@.tga}#1{{QTm}{QTm}{#1}}
500 \@namedef{Gin@rule@.TGA}#1{{QTm}{QTm}{#1}}
502 \@namedef{Gin@rule@.gif}#1{{QTm}{QTm}{#1}}
503 \@namedef{Gin@rule@.GIF}#1{{QTm}{QTm}{#1}}
505 \@namedef{Gin@rule@.tif}#1{{QTm}{QTm}{#1}}
506 \@namedef{Gin@rule@.TIF}#1{{QTm}{QTm}{#1}}
507 \@namedef{Gin@rule@.tiff}#1{{QTm}{QTm}{#1}}
508 \@namedef{Gin@rule@.TIFF}#1{{QTm}{QTm}{#1}}
510 % movies not supported yet:
511 %\@namedef{Gin@rule@.qt}#1{{QTm}{QTm}{#1}}
512 %\@namedef{Gin@rule@.mpg}#1{{QTm}{QTm}{#1}}
513 %\@namedef{Gin@rule@.mov}#1{{QTm}{QTm}{#1}}
514 %\@namedef{Gin@rule@.moov}#1{{QTm}{QTm}{#1}}
517 % ... though this default rule will try QuickTime anyway ...
518 \@namedef{Gin@rule@*}#1{{QTm}{QTm}{#1}}
520 % ... and add its extension here
521 \def\Gin@extensions{% order here is like dvipdfmx.def, except for PS
522 .pdf,.PDF,.eps,.EPS,.ps,.PS,%
523 .png,.PNG,.jpg,.JPG,.jpeg,.JPEG,.bmp,.BMP,%
524 .pict,.PICT,.psd,.PSD,.mac,.MAC,.TGA,.tga,%
525 .gif,.GIF,.tif,.TIF,.tiff,.TIFF,%
528 % xdvipdfmx is now the default driver, and can support EPS images,
529 % so we borrow code for this from dvipdfmx.def (and add the extensions above)
531 \def\Ginclude@eps#1{%
534 \ifx\Undefined\Gin@vllx\else\@trim@vporttrue\fi
537 \advance\dimen@ -\Gin@llx\p@
539 \advance\dimen@ \Gin@vllx\p@
541 \edef\Gin@urx{\strip@pt\dimen@}%
543 \advance\dimen@ -\Gin@lly\p@
545 \advance\dimen@ \Gin@vlly\p@
547 \edef\Gin@ury{\strip@pt\dimen@}%
548 \dimen@\Gin@req@width
550 \divide\dimen@\dimen@ii
551 \@tempdima\Gin@req@height
552 \divide\@tempdima\dimen@ii
553 \special{PSfile="#
1"\space
560 \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi
561 \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi
562 \ifGin@clip clip\fi}%
567 % supported from xetex v0.6 onwards
570 \def\Grot@start{\wd\z@\z@
571 \special{x:gsave}\special{x:rotate \Grot@angle}}
572 \def\Grot@end{\special{x:grestore}}
575 \special{x:gsave}\special{x:scale \Gscale@x\space\Gscale@y}}
576 \let\Gscale@end\Grot@end
581 %% End of file `xetex.def'.