texlive[44576] Master/texmf-dist/tex/latex/graphics-def: graphics-def

commits+karl at tug.org commits+karl at tug.org
Mon Jun 12 23:42:50 CEST 2017


Revision: 44576
          http://tug.org/svn/texlive?view=revision&revision=44576
Author:   karl
Date:     2017-06-12 23:42:50 +0200 (Mon, 12 Jun 2017)
Log Message:
-----------
graphics-def (12jun17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/tex/latex/graphics-def/dvipdfmx.def
    trunk/Master/texmf-dist/tex/latex/graphics-def/dvips.def
    trunk/Master/texmf-dist/tex/latex/graphics-def/dvisvgm.def
    trunk/Master/texmf-dist/tex/latex/graphics-def/luatex.def
    trunk/Master/texmf-dist/tex/latex/graphics-def/pdftex.def
    trunk/Master/texmf-dist/tex/latex/graphics-def/xetex.def

Modified: trunk/Master/texmf-dist/tex/latex/graphics-def/dvipdfmx.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/graphics-def/dvipdfmx.def	2017-06-12 21:42:28 UTC (rev 44575)
+++ trunk/Master/texmf-dist/tex/latex/graphics-def/dvipdfmx.def	2017-06-12 21:42:50 UTC (rev 44576)
@@ -1,13 +1,13 @@
-%% This is file `dvipdfmx.def' for DVIPDFMx by J.-H. Cho and S. Hirata
-%% based upon `dvipdf.def' in the LaTeX `Graphics Bundle'.
+%% dvipdfmx.def Copyright (C) 2005-2017 LaTeX3 Project, Jin-Hwan Cho, Shunsaku Hirata
+%%                                      (with contributions from many others)
 %%
-%% Copyright 2005-2016 LaTeX3 Project, Jin-Hwan Cho, Shunsaku Hirata
-%% (with contributions from many others)
-%% 
-%% This file is not part of the Standard LaTeX `Graphics Bundle'.
-%% It may be distributed under the terms of the LaTeX Project Public
-%% License, as described in lppl.txt in the base LaTeX distribution.
-%% Either version 1.0 or, at your option, any later version.
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%%   http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
 %%
 %% This work has the LPPL maintenance status `maintained'.
 %%
@@ -16,25 +16,7 @@
 %% https://github.com/latex3/graphics-def/issues
 %%
 \ProvidesFile{dvipdfmx.def}
-  [2016/07/11 v4.12 LaTeX color/graphics driver for dvipdfmx (L3/ChoF)]
-%
-% miniltx.tex does not define \PackageWarning
-\@ifundefined{PackageWarning}{%
-  \def\PackageWarning#1#2{%
-    \begingroup
-      \def\@spaces{\space\space\space\space}%
-      \ifx\on at line\@undefined\def\on at line{}\fi
-      \newlinechar=10 %
-      \def\MessageBreak{%
-        ^^J(#1)\@spaces\@spaces\@spaces\@spaces
-      }%
-      \immediate\write16{^^JPackage #1 Warning: #2\on at line.^^J}%
-    \endgroup
-  }%
-}{}
-
-\def\GPT at warn{\PackageWarning{dvipdfmx.def}}%
-
+  [2017/06/01 v5.0a Graphics/color driver for dvipdfmx]
 \def\c at lor@arg#1{%
   \dimen@#1\p@
   \ifdim\dimen@<\z@\dimen@\maxdimen\fi
@@ -71,15 +53,6 @@
   \dimen@#1\p@
   \divide\dimen@\@cclv
   \edef#2{\strip at pt\dimen@}}
-%%
-%% the following 7 lines do not work. (2016/06/22)
-%%\def\color at hsb#1#2{\c at lor@@hsb#2\@@#1}
-%%\def\c at lor@@hsb#1,#2,#3\@@#4{%
-%%  \c at lor@arg{#1}%
-%%  \c at lor@arg{#2}%
-%%  \c at lor@arg{#3}%
-%%  \edef#4{[#1 #2 #3] hsb}%
-%%  }
 \def\color at named#1#2{\c at lor@@named#2,,\@@#1}
 \def\c at lor@@named#1,#2,#3\@@#4{%
   \@ifundefined{col@#1}%
@@ -102,87 +75,25 @@
          pdf:bgcolor \current at color}}
 \def\define at color@named#1#2{%
   \expandafter\let\csname col@#1\endcsname\@nnil}
-%
-% Graphics
-%
-\def\declareimagemask{%
-  \@ifnextchar[\declareimagemask at i{\declareimagemask at i[]}}
-\def\declareimagemask at i[#1]#2#3{%
-  \special{pdf:image @#2\space hide (#3) #1}}
-%
-% import from pdftex.def
-%
-\let\GPT at pagebox@option\@empty
-\begingroup
-\toks@{%
-\define at key{Gin}{page}{\def\Gin at page{#1}}
-\define at key{Gin}{mask}{\def\Gin at mask{#1}}
-\define at key{Gin}{interpolate}[true]{%
-  \lowercase{\Gin at boolkey{#1}}{interpolate}}
-\define at key{Gin}{pagebox}{%
-  \expandafter\let\expandafter\GPT at pagebox%
-      \csname GPT at pagebox@#1\endcsname
-  \ifx\GPT at pagebox\relax
-    \let\GPT at pagebox\@empty
-    \GPT at warn{%
-      Unknown value `#1' for `pagebox'.\MessageBreak
-      Supported values:\MessageBreak
-      mediabox, cropbox, bleedbox, trimbox, artbox%
-    }%
-  \else%
-    \def\GPT at pagebox@option{-B \GPT at pagebox\space}%
-  \fi%
-}%
+\@ifundefined{Gin at page}
+  {\let\Gin at page\@empty}
+  {}
+\@ifundefined{Gin at pagebox}
+  {\def\Gin at page{cropbox}}
+  {}
+\@ifundefined{Gin at interpolate}
+  {\csname newif\endcsname\ifGin at interpolate}
+  {}
+\def\Gread at pdf#1{%
+  \Gread at generic{#1}\Gread at extractbb@aux
 }
-\@ifundefined{define at key}{
-    \edef\x{\endgroup
-      \noexpand\AtBeginDocument{%
-        \noexpand\@ifundefined{define at key}{}{\the\toks@}%
-      }%
-    }\x
-  }{%
-    \expandafter\endgroup\the\toks@
-  }%
-
-\def\GPT at pagebox@cropbox{cropbox}%
-\def\GPT at pagebox@mediabox{mediabox}%
-\def\GPT at pagebox@artbox{artbox}%
-\def\GPT at pagebox@trimbox{trimbox}%
-\def\GPT at pagebox@bleedbox{bleedbox}%
-%
-% end (import from pdftex.def)
-%
-% improved by N. Abe to cache BoundingBox for pdfpages package
-%
-\def\Gread at pdf#1{%
-\edef\@tempa{pdf at bbox@cache@\Gin at page @\GPT at pagebox @#1}%
-\expandafter\expandafter\expandafter\@ifundefined\expandafter{\@tempa}{\Gread@@pdf{#1}}{%
-\edef\@gtempa{\csname\@tempa\endcsname}%
-\expandafter\Gread at parse@bb\@gtempa\\}}
-\def\Gread@@pdf#1{%
-  \begingroup
-  \@tempcnta\z@
-  \loop\ifnum\@tempcnta<\@xxxii
-     \catcode\@tempcnta14 %
-     \advance\@tempcnta\@ne
-  \repeat
-  \catcode`\^^?14 %
-  \let\do\@makeother
-  \dospecials
-  \catcode`\ 10 %
-  \catcode`\^^I10 %
-  \catcode\endlinechar5 %
-  \@makeother\:%
-  \@makeother\-%
-  \immediate\openin\@inputcheck"#1" % allow spaces in a name of a .xbb file
+\def\Gread at extractbb@aux#1{%
   \ifeof\@inputcheck
-    \def\@tempc{!}%
-    \ifx\Gin at page\@tempc
-      \def\@tempc{}%
-    \else
-      \def\@tempc{-p \Gin at page\space}%
-    \fi
-    \immediate\openin\@inputcheck="|extractbb \GPT at pagebox@option \@tempc -O \Gin at base\Gin at ext"%
+    \immediate\openin\@inputcheck=%
+      "|extractbb %
+      \ifx\Gin at page\@empty\else -p \Gin at page\space\fi
+      \ifx\Gin at pagebox\@empty\else -B \Gin at pagebox\space\fi
+      -O \Gin at base\Gin at ext"%
   \fi
   \Gread at true
   \let\@tempb\Gread at false
@@ -203,102 +114,34 @@
       \repeat
     \immediate\closein\@inputcheck
   \fi
-%
-% If BoundingBox is not obtained, extractbb may be an old one which does not
-% support the -p and/or -B options, and usage of extractbb is printed to stdout.
-% Thus we retry without the -p and/or -B optons.
-%
-  \ifGin at bbox\else
-    \immediate\openin\@inputcheck="|extractbb -O \Gin at base\Gin at ext"%
-    \message{^^JI try without the new options^^J}%
-    \Gread at true
-    \let\@tempb\Gread at false
-    \ifeof\@inputcheck
-      \@latex at error
-        {Cannot run pipe command. Try --shell-escape^^J%
-         (--enable-pipes in MikTeX) option}%
-        {}%
-    \else
-      \loop
-        \read\@inputcheck to\@tempa
-        \ifeof\@inputcheck
-          \Gread at false
-        \else
-          \expandafter\Gread at find@bb\@tempa:.\\%
-        \fi
-        \ifGread@
-        \repeat
-      \immediate\closein\@inputcheck
-      \aftergroup\Gin at clear@pagebox
-    \fi
-  \fi
-%
-% improved by N. Abe to cache BoundingBox for pdfpages package
-%
-  \ifGin at bbox
-    \edef\@tempa{pdf at bbox@cache@\Gin at page @\GPT at pagebox @#1}%
-    \expandafter\expandafter\expandafter\xdef\expandafter\csname\@tempa\endcsname{\@gtempa}%
-  \else
-    \@latex at error
-      {Cannot determine size of image (no BoundingBox)}%
-      {}%
-    \gdef\@gtempa{0 0 72 72 }%
-  \fi
-  \endgroup
-  \expandafter\Gread at parse@bb\@gtempa\\}
-\def\Gin at clear@pagebox{%
-  \let\GPT at pagebox\@empty}
+}
 \let\Gread at bmp\Gread at pdf
-\def\Gin at page{!}
-\def\Gin at mask{!}
-\newif\ifGin at interpolate\Gin at interpolatefalse
-\let\GPT at pagebox\@empty
 \def\Ginclude at pdf#1{%
- \message{<#1>}%
+  \Gin at interpolatefalse
+  \Ginclude at dvipdfmx{#1}{epdf}%
+}
+\def\Ginclude at bmp#1{%
+  \let\Gin at page\@empty
+  \let\Gin at pagebox\@empty
+  \Ginclude at dvipdfmx{#1{image}}%
+}
+\def\Ginclude at dvipdfmx#1#2{%
+  \Gin at log{<#1>}%
   \bgroup
   \def\@tempa{!}%
-    \special{pdf:epdf\space
-      \ifx\Gin at page\@tempa\else page\space\Gin at page\space\fi
-      \ifx\GPT at pagebox\@empty\else pagebox\space\GPT at pagebox\space\fi
+    \special{pdf:#2\space
+      \ifx\Gin at page\@empty\else page\space\Gin at page\space\fi
+      \ifx\Gin at pagebox\@empty\else pagebox\space\Gin at pagebox\space\fi
       bbox\space\Gin at llx\space\Gin at lly\space\Gin at urx\space\Gin at ury\space
       clip\space\ifGin at clip 1\else 0\fi\space
       \ifx\Gin at scalex\@tempa\else width\space\the\Gin at req@width\space\fi
       \ifx\Gin at scaley\@tempa\else height\space\the\Gin at req@height\space\fi
       (#1)\space
-      \ifx\Gin at mask\@tempa
-        \ifGin at interpolate<</Interpolate\space true>>\fi
-      \else
-        <</SMask @\Gin at mask\space%
-        \ifGin at interpolate/Interpolate\space true\fi>>%
-      \fi}%
+      \ifGin at interpolate<</Interpolate\space true>>\fi}%
   \egroup}
-\def\Ginclude at bmp#1{%
- \message{<#1>}%
-  \bgroup
-  \def\@tempa{!}%
-    \special{pdf:image\space
-      \ifx\Gin at page\@tempa\else page\space\Gin at page\space\fi
-      % The next line was \ifGin at bbox previously. However, LaTeX can read
-      % BoundingBox from a .xbb file even when \Gin at bboxfalse.
-      % Thus, we give bbox in the cases of trim/viewport, since
-      % trim/viewport don't work without bbox.
-      \ifx\Gin at ollx\@undefined\else
-        bbox\space\Gin at llx\space\Gin at lly\space\Gin at urx\space\Gin at ury\space
-        clip\space\ifGin at clip 1\else 0\fi\space
-      \fi
-      \ifx\Gin at scalex\@tempa\else width\space\the\Gin at req@width\space\fi
-      \ifx\Gin at scaley\@tempa\else height\space\the\Gin at req@height\space\fi
-      (#1)\space
-      \ifx\Gin at mask\@tempa
-        \ifGin at interpolate<</Interpolate\space true>>\fi
-      \else
-        <</SMask @\Gin at mask\space%
-        \ifGin at interpolate/Interpolate\space true\fi>>%
-      \fi}%
-  \egroup}
 \newif\if at trim@vport
 \def\Ginclude at eps#1{%
- \message{<#1>}%
+  \Gin at log{<#1>}%
   \bgroup
   \ifx\Undefined\Gin at vllx\else\@trim at vporttrue\fi
   \def\@tempa{!}%
@@ -345,7 +188,7 @@
 % the option --mvorigin.
 %
 \def\Ginclude at mps#1{%
- \message{<#1>}%
+  \Gin at log{<#1>}%
   \bgroup
   \def\@tempa{!}%
   \dimen@\Gin at req@width
@@ -366,9 +209,25 @@
 \def\Grot at start{%
 \special{pdf:btrans rotate \Grot at angle}}
 \def\Grot at end{\special{pdf:etrans}}
+
+% 4.13 add support for ptex vertical writing mode
+% inspired by pxtatescale package (Hironobu Yamashita)
+\ifx\kanjiskip\@undefined
 \def\Gscale at start{%
   \special{pdf:btrans}%
-  \special{pdf:literal \Gscale at x\space 0 0 \Gscale at y\space 0 0 cm}}
+  \special{x:scale \Gscale at x\space\Gscale at y}%
+}
+\else
+\edef\Gscale at start{%
+  \special{pdf:btrans}%
+  \special{x:scale
+  \expandafter\noexpand\csname iftdir\endcsname
+    \noexpand\Gscale at y\noexpand\space\noexpand\Gscale at x
+  \expandafter\noexpand\csname else\endcsname
+    \noexpand\Gscale at x\noexpand\space\noexpand\Gscale at y
+  \expandafter\noexpand\csname fi\endcsname}}
+\fi
+%
 \def\Gscale at end{\special{pdf:etrans}}
 \def\Gin at PS@raw#1{\special{ps: #1}}
 \def\Gin at PS@restored#1{\special{" #1}}
@@ -459,7 +318,3 @@
 }
 \fi
 \fi 
-
-\endinput
-%%
-%% End of file `dvipdfmx.def'.

Modified: trunk/Master/texmf-dist/tex/latex/graphics-def/dvips.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/graphics-def/dvips.def	2017-06-12 21:42:28 UTC (rev 44575)
+++ trunk/Master/texmf-dist/tex/latex/graphics-def/dvips.def	2017-06-12 21:42:50 UTC (rev 44576)
@@ -1,15 +1,7 @@
+%% dvips.def Copyright (C) 1994      David Carlisle Sebastian Rahtz
+%%           Copyright (C) 1995-1999 David Carlisle
+%%           Copyright (C) 2000-2017 David Carlisle, LaTeX3 Project
 %%
-%% This is file `dvips.def',
-%% original generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% drivers.dtx  (with options: `dvips,color1,psrulesZ,dosrules,macrules')
-%% 
-%% drivers.dtx Copyright (C) 1994      David Carlisle Sebastian Rahtz
-%%             Copyright (C) 1995 1996 1997 1998 1999 David Carlisle
-%%             Copyright (C) 2000--2016 David Carlisle, LaTeX3 Project
-%%
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3c
 %% of this license or (at your option) any later version.
@@ -25,7 +17,7 @@
 %% https://github.com/latex3/graphics-def/issues
 %%
 \ProvidesFile{dvips.def}
-        [2016/07/10 v3.1a Driver-dependent file (DPC,SPQR)]
+  [2017/06/01 v3.1b Graphics/color driver for dvips]
 \def\c at lor@arg#1{%
   \dimen@#1\p@
   \ifdim\dimen@<\z@\dimen@\maxdimen\fi
@@ -191,5 +183,3 @@
 \@namedef{Gin at rule@.pict}#1{{pict}{}{#1}}
 \@namedef{Gin at rule@.pntg}#1{{pntg}{}{#1}}
 \endinput
-%%
-%% End of file `dvips.def'.

Modified: trunk/Master/texmf-dist/tex/latex/graphics-def/dvisvgm.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/graphics-def/dvisvgm.def	2017-06-12 21:42:28 UTC (rev 44575)
+++ trunk/Master/texmf-dist/tex/latex/graphics-def/dvisvgm.def	2017-06-12 21:42:50 UTC (rev 44576)
@@ -15,7 +15,7 @@
 %%
 %% https://github.com/latex3/graphics-def/issues
 %
-\ProvidesFile{dvisvgm.def}[2016/05/09 v1.0a dvisvgm graphics driver for latex]
+\ProvidesFile{dvisvgm.def}[2017/06/01 v1.0a dvisvgm graphics driver for latex]
 % The following is copied from dvips.def:
 \def\c at lor@arg#1{%
   \dimen@#1\p@

Modified: trunk/Master/texmf-dist/tex/latex/graphics-def/luatex.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/graphics-def/luatex.def	2017-06-12 21:42:28 UTC (rev 44575)
+++ trunk/Master/texmf-dist/tex/latex/graphics-def/luatex.def	2017-06-12 21:42:50 UTC (rev 44576)
@@ -1,17 +1,8 @@
-\ProvidesFile{luatex.def}[2017/01/12 v0.01h Graphics/Color for luaTeX]
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% luatex.def Copyright (C) 2000-2015 David Carlisle, Sebastian Rahtz,
+%%                                    Hans Hagen, Heiko Oberdiek and
+%%                                    Martin Schr\"oder
+%%            Copyright (C) 2016-2017 LaTeX3 project and Heiko Oberdiek 
 %%
-%% LaTeX Colour and Graphics support for luatex
-%%
-%% License
-%% =======
-%%
-%% Copyright (C) 2000-2017 LaTeX3 Project
-%%
-%% based on pdftex.def by the following authors
-%% David Carlisle, Sebastian Rahtz, Hans Hagen,
-%% Heiko Oberdiek and Martin Schr\"oder
-%%
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3c
 %% of this license or (at your option) any later version.
@@ -26,138 +17,18 @@
 %%
 %% https://github.com/latex3/graphics-def/issues
 %%
-%% This work consists of the file luatex.def.
-%%
-%% Usage
-%% =====
-%%
-%% It may be used by specifying the luatex option to any of the
-%% supported packages, for example:
-%%
-%% \usepackage[luatex]{graphicx}
-%%
-%% * luatex determines the bounding box of the images itself
-%%   Therefore the bounding box options should not be used.
-%%   In this cases a warning is issued and viewport is used instead.
-%% * Option "page" (graphicx) for selecting a page of a multipage
-%%   PDF document.
-%% * \pagecolor is supported. \nopagecolor disables the page color.
-%% * Option "quiet" (graphicx/experimental): log messages are suppressed.
-%% * Option "resolution" (graphicx/experimental): this sets
-%%   \pdfvariable imageresolution, see luaTeX documentation.
-%% * Option "print" (graphicx/experimental): specifies an alternate
-%%   print image (bitmaps only), see PDF specification.
-%% * luatex.def can be used under plain-TeX with miniltx support.
-%%
-%% "Experimental" means that these features can change or vanish
-%% in later versions.
-%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% History
-%
-% 2015/12/30 Version 0.01a derived from pdftex.def
-% 2016/01/23 Version 0.01b Moved to latex3 github, documentation changes
-% 2016/05/21 Version 0.01c fix for graphics/4472
-% 2016/06/24 Version 0.01d support the (no)setpagesize option.
-% 2016/06/17 Version 0.01e guards for contributed packages and plain TeX
-% 2016/07/11 Version 0.01f test for \mag added to all drivers, missing \fi in pagebox 
-% 2016/08/17 Version 0.01g Guard for non-LaTeX use
-% 2017/01/12 Version 0.01h graphics options as viewport for graphics/4499
-%
-% Prefix of internal commands for this file `luatex.def':
-% \GPT@ (Graphics bundle PdfTex driver, even though this is for luatex)
-
-
-% if not luatex, complain,
-% on old luatex, use pdftex.def
-\ifx\luatexversion\@undefined
-  \PackageError{graphics}{Unexpected luatex driver}{}
-\else
-  \ifnum\luatexversion<87\relax
-    \input pdftex.def
-    \expandafter\expandafter\expandafter\endinput
-  \fi
-\fi
-
-
-\protected\edef\GPT at compresslevel       {\pdfvariable compresslevel}
-
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname RequirePackage\endcsname\relax
-  \input infwarerr.sty\relax
-  \input ltxcmds.sty\relax
-\else
-  \RequirePackage{infwarerr}[2007/09/09]%
-  \RequirePackage{ltxcmds}[2010/12/07]%
-\fi
-
-\def\GPT at error{\@PackageError{luatex.def}}%
-\def\GPT at warn{\@PackageWarning{luatex.def}}%
-\ifx\Gin at log\@undefined
-  \def\Gin at log{\message}%
-\fi
-\def\GPT at info{\@PackageInfoNoLine{luatex.def}}%
-
-
-
-% Ensure PDF mode
-\ifnum\outputmode<1 %
-  \GPT at error{%
-    PDF mode expected, but DVI mode detected!\MessageBreak
-    If you are using `dvilualatex', then call `lualatex'.\MessageBreak
-    Otherwise check and  correct the driver options.\MessageBreak
-    Error recovery by switching to PDF mode%
-  }\@ehc
-  \outputmode=1 %
-\fi
-\@ifundefined{ifGin at setpagesize}
-  {\expandafter\let\csname ifGin at setpagesize\expandafter\endcsname
-                    \csname iftrue\endcsname}
-  {}
-\ifGin at setpagesize
-\ifx\paperwidth\@undefined\else
-\AtBeginDocument{%
-% If a package has changed \mag, assume it knows what it is doing
-% and leave page size alone
-\ifnum\mag=\@m
-\ltx at IfUndefined{stockwidth}{%
-  \ltx at IfUndefined{paperwidth}{%
-  }{%
-    \ifdim\paperwidth>0pt\relax
-      \ifdim\paperheight>0pt\relax
-        \pagewidth=\paperwidth
-        \pageheight=\paperheight
-      \fi
-    \fi
-  }%
-}{%
-  \ifdim\stockwidth>0pt\relax
-    \ifdim\stockheight>0pt\relax
-      \pagewidth=\stockwidth
-      \pageheight=\stockheight
-    \fi
-  \fi
-}%
-\fi
-}
-\fi
-\fi
-
-% Colour Support. The following models may be used.
-%   * cmyk   supported directly.
-%   * rgb    supported directly.
-%   * RGB    converted to rgb by this file.
-%   * gray   supported directly.
-%   * named  converted to cmyk by this file.
-%
+\ProvidesFile{luatex.def}
+  [2017/06/01 v1.0a Graphics/color driver for luatex]
 \def\c at lor@arg#1{%
   \dimen@#1\p@
   \ifdim\dimen@<\z@\dimen@\maxdimen\fi
   \ifdim\dimen@>\p@
     \PackageError{color}{Argument `#1' not in range [0,1]}\@ehd
-  \fi
-}
+  \fi}
+\def\color at gray#1#2{%
+  \c at lor@arg{#2}%
+  \edef#1{#2 g #2 G}%
+  }
 \def\color at cmyk#1#2{\c at lor@@cmyk#2\@@#1}
 \def\c at lor@@cmyk#1,#2,#3,#4\@@#5{%
   \c at lor@arg{#4}%
@@ -165,11 +36,7 @@
   \c at lor@arg{#2}%
   \c at lor@arg{#3}%
   \edef#5{#1 #2 #3 #4 k #1 #2 #3 #4 K}%
-}
-\def\color at gray#1#2{%
-  \c at lor@arg{#2}%
-  \edef#1{#2 g #2 G}%
-}
+  }
 \def\color at rgb#1#2{\c at lor@@rgb#2\@@#1}
 \def\c at lor@@rgb#1,#2,#3\@@#4{%
   \c at lor@arg{#1}%
@@ -176,76 +43,51 @@
   \c at lor@arg{#2}%
   \c at lor@arg{#3}%
   \edef#4{#1 #2 #3 rg #1 #2 #3 RG}%
-}
+  }
 \def\color at RGB#1#2{\c at lor@@RGB#2\@@#1}
 \def\c at lor@@RGB#1,#2,#3\@@#4{%
-  \c at lor@RGB at rgb{#1}\@tempa
-  \c at lor@RGB at rgb{#2}\@tempb
-  \c at lor@RGB at rgb{#3}\@tempc
-  \c at lor@@rgb\@tempa,\@tempb,\@tempc\@@#4%
-}
+ \c at lor@RGB at rgb{#1}\@tempa
+ \c at lor@RGB at rgb{#2}\@tempb
+ \c at lor@RGB at rgb{#3}\@tempc
+ \c at lor@@rgb\@tempa,\@tempb,\@tempc\@@#4%
+  }
 \def\c at lor@RGB at rgb#1#2{%
   \dimen@#1\p@
   \divide\dimen@\@cclv
-  \edef#2{\strip at pt\dimen@}%
-}
-
+  \edef#2{\strip at pt\dimen@}}
 \def\color at named#1#2{\c at lor@@named#2,,\@@#1}
 \def\c at lor@@named#1,#2,#3\@@#4{%
-  \ltx at IfUndefined{col@#1}{%
-    \PackageError{color}{Undefined color `#1'}\@ehd
-  }{%
-    \edef#4{\csname col@#1\endcsname}%
-  }%
-}
-
-
-  \chardef\main at pdfcolorstack=0 %
-  \ltx at ifundefined{@pdfcolorstack}{%
-    \def\@pdfcolorstack{\main at pdfcolorstack}%
-  }{}%
-  \def\set at color{%
-    \pdfextension colorstack\@pdfcolorstack push{\current at color}%
-    \aftergroup\reset at color
-  }%
-  \def\reset at color{%
-    \pdfextension colorstack\@pdfcolorstack pop\relax
-  }%
-
-\def\define at color@named#1#2{%
-  \expandafter\edef\csname col@#1\endcsname{#2}%
-}
+  \@ifundefined{col@#1}%
+    {\PackageError{color}{Undefined color `#1'}\@ehd}%
+  {\edef#4{\csname col@#1\endcsname}}%
+  }
+\chardef\main at pdfcolorstack=0 %
+\@ifundefined{@pdfcolorstack}
+  {\def\@pdfcolorstack{\main at pdfcolorstack}}{}
 \def\current at color{0 g 0 G}
-
-% v0.02t: support for \pagecolor
-% fixed in v0.02p by using a box register, see
-% http://tug.org/pipermail/pdftex/2005-August/005916.html
-%
-% v0.03r: \nopagecolor/\no at page@color added.
-\ltx at newglobalif\ifGPT at pagecolor
-\ltx at ifundefined{nopagecolor}{%
-  \def\nopagecolor{\no at page@color}%
-}{}
-\def\no at page@color{%
-  \GPT at pagecolorfalse
-}
+\def\set at color{%
+  \pdfextension colorstack\@pdfcolorstack push{\current at color}%
+  \aftergroup\reset at color}
+\def\reset at color{\pdfextension colorstack\@pdfcolorstack pop\relax}
+\newif\ifGPT at pagecolor
+\begingroup\expandafter\expandafter\expandafter\endgroup
 \def\set at page@color{%
   \GPT at pagecolortrue
   \global\let\current at page@color\current at color
-  \ltx at ifundefined{GPT at outputbox}{%
+  \ifundefined{GPT at outputbox}{%
     % \newbox is outer in plain
     \csname newbox\endcsname\GPT at outputbox
   }{}%
-  \ltx at ifundefined{GPTorg at shipout}{%
+  \@ifundefined{GPTorg at shipout}{%
     \global\let\GPTorg at shipout\shipout
     \gdef\shipout{%
-      \edef\GPT at saved@grouplevel{\number\currentgrouplevel}%
+     \edef\GPT at saved@grouplevel{\number\currentgrouplevel}%
       \afterassignment\GPT at shipout
       \global\setbox\GPT at outputbox=%
     }%
     \gdef\GPT at shipout{%
-      \ifnum\GPT at saved@grouplevel=\currentgrouplevel
-      \else
+     \ifnum\GPT at saved@grouplevel=\currentgrouplevel
+     \else
         \expandafter\aftergroup
       \fi
       \GPT@@shipout
@@ -252,7 +94,7 @@
     }%
     \gdef\GPT@@shipout{%
       \ifvoid\GPT at outputbox\relax
-        \GPT at warn{Ignoring void output box}%
+        \PackageInfo{pdftex.def}{Ignoring void output box}%
       \else
         \setbox\GPT at outputbox=\vbox{%
           \GPT at pageliteral
@@ -265,10 +107,10 @@
       \ifGPT at pagecolor
         \pdfextension literal page{%
           q % gsave
-          \current at page@color\ltx at space
+          \current at page@color\space
           n % newpath
-          0 0 \strip at pt\pagewidth\ltx at space
-          \strip at pt\pageheight\ltx at space re % rectangle
+          0 0 \strip at pt\pagewidth\space
+          \strip at pt\pageheight\space re % rectangle
           % there is no need to convert to bp
           f % fill
           Q% grestore
@@ -277,543 +119,98 @@
     }%
   }{}%
 }
-
-
-
-
-%
-% Graphic inclusion. Currently supports .png, .jpg, .mps and .pdf inclusion;
-% .mps is MetaPost output.
-%
-%
-% support for
-% * multipage pdf images 
-% * alternate print image (bitmaps only)
-%   * printed image can be resused, but not the base image,
-%     because it's dictionary contains the additional key /Alternates.
-%   * not supported by Ghostscript or xpdf.
-% * option quiet
-% * option resetcolor
-% * option xmpfile
-%
-% \GPT at page: page number of pdf image or \ltx at empty otherwise.
-\let\GPT at page\ltx at empty
-% \GPT at print: file name for alternate image or \ltx at empty otherwise.
-\let\GPT at print\ltx at empty
-\let\GPT at xmpfile\ltx at empty
-\let\GPT at pagebox\ltx at empty
-\let\GPT at pagebox@\ltx at empty
-\let\GPT at interpolate\ltx at empty
-\let\GPT at decodearray\ltx at empty
-\let\GPT at mask\ltx at empty
-\let\GPT at intent\ltx at empty
-\let\GPT at ocobjnum\ltx at empty
-\ltx at newif\ifGPT at ResetColor
-\let\GPT at ResetColorEnd\relax
-\def\GPT at ResetColorBegin{%
-  \ifGPT at ResetColor
-    \ifGPT at IsBitmap
-    \else
-      \begingroup
-      \normalcolor
-      \let\GPT at ResetColorEnd\endgroup
-    \fi
-  \fi
+\def\define at color@named#1#2{%
+  \expandafter\edef\csname col@#1\endcsname{#2}}
+\def\no at page@color{%
+  \GPT at pagecolorfalse
 }
-
-% \pdfmatch may be emulated in lua
-% (may be better to use lua patterns than bring in full
-% regex, do nothing for now
-  \def\GPT at match#1#2#3#4{}%
-  \def\GPT at pat@real/{}%
-
-
-\begingroup
-  \toks@{%
-    \define at key{Gin}{resetcolor}[true]{%
-      \csname GPT at ResetColor%
-        \expandafter\ifx\csname iftrue\expandafter\endcsname
-                        \csname if#1\endcsname
-          true%
-        \else
-          false%
-        \fi
-      \endcsname
+\def\Gread at pdftex#1{%
+  \IfFileExists{#1}
+    {\Gread@@pdftex{#1}}%
+    {%
+      \def\Gin at llx{0}%
+      \let\Gin at lly\Gin at llx
+      \def\Gin at urx{72}%
+      \let\Gin at ury\Gin at urx
+      \ifGin at draft
+      \else
+        \PackageError{luatex.def}{File `#1' not found: using draft setting}%
+        \@ehc
+        \Gin at drafttrue
+      \fi
     }%
-%
-      \define at key{Gin}{page}{%
-        \def\GPT at page{#1}%
-        \ifx\GPT at page\ltx at empty
-        \else
-          \edef\GPT at page{\number\GPT at page}%
-        \fi
-      }%
-      \define at key{Gin}{print}{%
-        \def\GPT at print{#1}%
-      }%
-%
-      % option pagebox
-      \define at key{Gin}{pagebox}{%
-        \expandafter\let\expandafter\GPT at pagebox
-            \csname GPT at pagebox@#1\endcsname
-        \ifx\GPT at pagebox\relax
-          \let\GPT at pagebox\ltx at empty
-          \GPT at warn{%
-            Unknown value `#1' for `pagebox'.\MessageBreak
-            Supported values:\MessageBreak
-            mediabox, cropbox, bleedbox, trimbox, artbox%
-          }%
-	\fi
-      }%
-      \def\GPT at pagebox@mediabox{mediabox}%
-      \let\GPT at pagebox@cropbox\ltx at empty
-      \def\GPT at pagebox@bleedbox{bleedbox}%
-      \def\GPT at pagebox@trimbox{trimbox}%
-      \def\GPT at pagebox@artbox{artbox}%
-      % option interpolate
-      \define at key{Gin}{interpolate}[true]{%
-        \expandafter\let\expandafter\GPT at interpolate
-            \csname GPT at interpolate@#1\endcsname
-        \ifx\GPT at interpolate\relax
-          \let\GPT at interpolate\ltx at empty
-          \GPT at warn{%
-            Unknown value `#1' for `interpolate'.\MessageBreak
-            Supported values: true, false%
-          }%
-        \fi
-      }%
-      \let\GPT at interpolate@false\ltx at empty
-      \def\GPT at interpolate@true{1}% non-empty, value does not matter
-      % option decodearray
-      \define at key{Gin}{decodearray}{%
-        \def\GPT at decodearray{#1}%
-        \ifx\GPT at decodearray\ltx at empty
-        \else
-          \GPT at match\GPT at decodearray{%
-            ((^| )\GPT at pat@real/ \GPT at pat@real/)+$%
-          }{}{%
-            \GPT at warn{%
-              Invalid value (\GPT at decodearray)\MessageBreak
-              for `decodearray' is ignored%
-            }%
-            \let\GPT at decodearray\ltx at empty
-          }%
-        \fi
-      }%
-      % option maskarray
-      \define at key{Gin}{maskarray}{%
-        \def\GPT at mask{#1}%
-        \ifx\GPT at mask\ltx at empty
-        \else
-          \GPT at match\GPT at mask{%
-            ((^| )[0-9]+ [0-9]+)+$%
-          }{}{%
-            \GPT at warn{%
-              Invalid value (\GPT at mask)\MessageBreak
-              for `maskarray' is ignored%
-            }%
-            \let\GPT at mask\ltx at empty
-          }%
-          \ifx\GPT at mask\ltx at empty
-          \else
-            \edef\GPT at mask{[\GPT at mask]}%
-          \fi
-        \fi
-      }%
-      % option intent
-      \define at key{Gin}{intent}{%
-        \def\GPT at intent{#1}%
-        \ifx\GPT at intent\ltx at empty
-        \else
-          \GPT at match\GPT at intent{%
-            ^((Absolute|Relative)Colorimetric|Saturation|Perceptual)$%
-          }{}{%
-            \GPT at match\GPT at intent{%
-              ^[A-Za-z0-9_]+$%
-            }{%
-              \GPT at warn{%
-                Rendering intent `\GPT at intent'\MessageBreak
-                is not a standard name of the PDF specification%
-              }%
-            }{%
-              \GPT at warn{%
-                Ignoring intent `\GPT at intent'\MessageBreak
-                with unusual characters%
-              }%
-              \let\GPT at intent\ltx at empty
-            }%
-          }%
-        \fi
-      }%
-      % option ocobjnum
-      \define at key{Gin}{ocobjnum}{%
-        \edef\GPT at ocobjnum{#1}%
-        \ifx\GPT at ocobjnum\ltx at empty
-        \else
-          \edef\GPT at ocobjnum{\number\GPT at ocobjnum}%
-          \GPT at match\GPT at ocobjnum{^[1-9]+[0-9]*$}{%
-          }{%
-            \GPT at warn{%
-              Invalid value (\GPT at ocobjnum)\MessageBreak
-              for `ocobjnum' is ignored%
-            }%
-            \let\GPT at ocobjnum\ltx at empty
-          }%
-          \ifx\GPT at ocobjnum\ltx at empty
-          \else
-            \edef\GPT at ocobjnum{\number\GPT at ocobjnum}%
-          \fi
-        \fi
-      }%
-      % option ocobjref
-      \define at key{Gin}{ocobjref}{%
-        \edef\GPT at ocobjnum{#1}%
-        \ifx\GPT at ocobjnum\ltx at empty
-        \else
-          \edef\GPT at ocobjnum{%
-            \expandafter\strip at prefix\meaning\GPT at ocobjnum
-          }%
-          \GPT at match\GPT at ocobjnum{^[1-9]+[0-9]* 0 R$}{%
-          }{%
-            \GPT at warn{%
-              Invalid value (\GPT at ocobjnum)\MessageBreak
-              for `ocobjref' is ignored%
-            }%
-            \let\GPT at ocobjnum\ltx at empty
-          }%
-          \ifx\GPT at ocobjnum\ltx at empty
-          \else
-            \begingroup
-              \def\GPT at temp##1 ##2\@nil{\endgroup
-                \def\GPT at ocobjnum{##1}%
-              }%
-            \expandafter\GPT at temp\GPT at ocobjnum\@nil
-            \edef\GPT at ocobjnum{\number\GPT at ocobjnum}%
-          \fi
-        \fi
-      }%
-    \define at key{Gin}{quiet}[]{%
-      \let\Gin at log\ltx at gobble
-    }%
-    \define at key{Gin}{resolution}{%
-      \pdfvariable imageresolution#1\relax
-    }%
-    \define at key{Gin}{xmpfile}[\Gin at base.xmp]{%
-      \def\GPT at xmpfile{#1}%
-    }%
-  }%
-  \ltx at IfUndefined{define at key}{%
-    \edef\x{\endgroup
-      \noexpand\AtBeginDocument{%
-        \noexpand\ltx at IfUndefined{define at key}{}{\the\toks@}%
-      }%
-    }\x
-  }{%
-    \expandafter\endgroup\the\toks@
-  }%
-
-% redefinitions of some graphicx options:
-\def\GPT at disable#1{%
-  \GPT at warn{%
-    Option `#1' is not supported, use\MessageBreak
-    option `viewport' instead%
-  }%
 }
-\def\GPT at fix{%
-  \begingroup\expandafter\expandafter\expandafter\endgroup
-  \expandafter\ifx\csname define at key\endcsname\relax
-  \else
-    \def\KV at Gin@bb{%
-      \GPT at warn{%
-        Option `bb' does not make sense,\MessageBreak
-        using `viewport' instead%
-      }%
-      \KV at Gin@viewport
-    }%
-    \define at key{Gin}{bbllx}{\GPT at disable{bbllx}}%
-    \define at key{Gin}{bblly}{\GPT at disable{bblly}}%
-    \define at key{Gin}{bburx}{\GPT at disable{bburx}}%
-    \define at key{Gin}{bbury}{\GPT at disable{bbury}}%
-  \fi
-}
-\AtBeginDocument{\GPT at fix}
-
-%
-% Check for image file existence
-%
-    \def\GPT at IfFileExists#1{%
-      \IfFileExists{#1}%
-    }%
-
-%
-% Wrapper for \Gread at ... that checks image existence first.
-%
-\def\GPT at read#1#2{%
-  \GPT at IfFileExists{#2}%
-  {%
-    #1{#2}%
-  }{%
-    \def\Gin at llx{0}%
-    \let\Gin at lly\Gin at llx
-    \def\Gin at urx{72}%
-    \let\Gin at ury\Gin at urx
-    \ifGin at draft
-    \else
-      \GPT at error{File `#2' not found}{%
-        Using draft setting for this image.\MessageBreak
-        \@ehc
-      }%
-      \Gin at drafttrue
-    \fi
-  }%
-}
-
-%
-% mechanism for re-use of objects also
-% allows us to get the size by deriving it from the initial storage;
-% this works for all graphics types.
-%
-\ltx at ifundefined{Gread at gobject}{%
-  \csname newcount\endcsname\Gread at gobject
-}{}
-\def\GPT at ReusedName#1{%
-  \ifx\GPT at print\ltx at empty
-    #1%
-  \else
-    \GPT at print
-  \fi
-}
-\def\GPT at objref{ 0 R}
-\def\Gread at pdftex{%
-  \GPT at read\Gread@@pdftex
-}
+\let\Gin at attr@hash\@empty
+\@ifundefined{Gin at log}
+  {\let\Gin at log\wlog}
+  {}
+\@ifundefined{Gin at page}
+  {\let\Gin at page\@empty}
+  {}
+\@ifundefined{Gin at pagebox}
+  {\def\Gin at page{cropbox}}
+  {}
+\@ifundefined{Gin at interpolate}
+  {\csname newif\endcsname\ifGin at interpolate}
+  {}
 \def\Gread@@pdftex#1{%
-  % Ensure that option `print' works only on bitmap images.
-  \let\GPT at Attr\ltx at empty
-  \let\GPT at AttrShort\ltx at empty
-    \ifx\GPT at ocobjnum\ltx at empty
+  \edef\Gin at attr@hash{%
+    \ifx\Gin at pagebox\@empty
     \else
-      \edef\GPT at AttrShort{\GPT at AttrShort
-        :OC\GPT at ocobjnum
-      }%
-      \edef\GPT at Attr{\GPT at Attr
-        /OC \GPT at ocobjnum\GPT at objref
-      }%
+      :\Gin at pagebox
     \fi
-  \ifGPT at IsBitmap
-    \let\GPT at page\ltx at empty
-    \let\GPT at pagebox\ltx at empty
-      \ifx\GPT at xmpfile\ltx at empty
-      \else
-        \ltx at IfUndefined{GPT at XMP@\GPT at xmpfile}{%
-          \GPT at IMfFileExists{\GPT at xmpfile}{%
-            \begingroup
-              \GPT at compresslevel=0 %
-              \immediate\pdfextension obj stream attr{%
-                /Type/Metadata%
-                /Subtype/XML%
-              }file{\GPT at xmpfile}%
-              \expandafter\xdef\csname GPT at XMP@\GPT at xmpfile\endcsname{%
-                \the\numexpr\pdffeedback lastobj\relax
-              }%
-            \endgroup
-          }{%
-            \GPT at warn{Missing XMP file (\GPT at xmpfile)}%
-          }%
-        }{}%
-        \ltx at IfUndefined{GPT at XMP@\GPT at xmpfile}{}{%
-          \edef\GPT at Attr{\GPT at Attr
-            /Metadata \@nameuse{GPT at XMP@\GPT at xmpfile}\GPT at objref
-          }%
-          \edef\GPT at AttrShort{\GPT at AttrShort
-            :MD\@nameuse{GPT at XMP@\GPT at xmpfile}%
-          }%
-        }%
-      \fi
-      \ifx\GPT at interpolate\ltx at empty
-      \else
-        \edef\GPT at Attr{\GPT at Attr
-          /Interpolate true%
-        }%
-        \edef\GPT at AttrShort{\GPT at AttrShort
-          :I%
-        }%
-      \fi
-      \ifx\GPT at decodearray\ltx at empty
-      \else
-        \edef\GPT at Attr{\GPT at Attr
-          /Decode[\GPT at decodearray]%
-        }%
-        \edef\GPT at AttrShort{\GPT at AttrShort
-          :D[\GPT at decodearray]%
-        }%
-      \fi
-      \ifx\GPT at mask\ltx at empty
-      \else
-        \edef\GPT at Attr{\GPT at Attr
-          /Mask\GPT at mask
-        }%
-        \edef\GPT at AttrShort{\GPT at AttrShort
-          :M\GPT at mask
-        }%
-      \fi
-      \ifx\GPT at intent\ltx at empty
-      \else
-        \edef\GPT at AttrShort{\GPT at AttrShort
-          :RI\GPT at intent
-        }%
-          \edef\GPT at intent{\TODOescapename{\GPT at intent}}%
-        \edef\GPT at Attr{\GPT at Attr
-          /Intent/\GPT at intent
-        }%
-      \fi
-  \else
-    \let\GPT at interpolate\ltx at empty
-    \let\GPT at decodearray\ltx at empty
-    \let\GPT at mask\ltx at empty
-    \let\GPT at intent\ltx at empty
-    \ifx\GPT at page\ltx at empty
+    \ifx\Gin at page\@empty
     \else
-      \edef\GPT at AttrShort{\GPT at AttrShort
-        :P\GPT at page
-      }%
+      :P\Gin at page
     \fi
-    \ifx\GPT at pagebox\ltx at empty
-    \else
-      \edef\GPT at AttrShort{%
-        \GPT at AttrShort
-        :\expandafter\ltx at car\GPT at pagebox{}\@nil b%
-      }%
+    \ifGin at interpolate
+      :I%
     \fi
-    \ifx\GPT at print\ltx at empty
-    \else
-      \GPT at warn{%
-        Option `print' can only be used\MessageBreak
-        for bitmap images%
+  }%
+  \@ifundefined{#1 image\Gin at attr@hash}%
+    {%
+      \saveimageresource
+        \ifGin at interpolate attr{/Interpolate true}\fi
+        \ifx\Gin at page\@empty\else page \Gin at page\fi
+        \Gin at pagebox
+        {#1}%
+      \setbox\@tempboxa=\hbox{\useimageresource\lastsavedimageresourceindex}%
+      \def\Gin at llx{0}\let\Gin at lly\Gin at llx
+      \Gin at defaultbp\Gin at urx{\wd\@tempboxa}%
+      \Gin at defaultbp\Gin at ury{\ht\@tempboxa}%
+      \expandafter\xdef\csname #1 image\Gin at attr@hash\endcsname
+        {\useimageresource\the\lastsavedimageresourceindex}%
+      \expandafter\xdef\csname #1 height\Gin at attr@hash\endcsname
+        {\the\ht\@tempboxa}%
+      \expandafter\xdef\csname #1 width\Gin at attr@hash\endcsname
+        {\the\wd\@tempboxa}%
+      \Gin at log{%
+        <#1, %
+        id=\the\lastsavedimageresourceindex, %
+        \ifx\Gin at page\@empty\else page=\Gin at page , \fi
+        \ifx\Gin at pagebox\@empty\else pagebox=\Gin at pagebox , \fi
+        \ifGin at interpolate interpolate=true, \fi
+        \the\wd\@tempboxa\space x \the\ht\@tempboxa
+        >%
       }%
-      \let\GPT at print\ltx at empty
-    \fi
-  \fi
-  % Check if print image exists.
-  \ifx\GPT at print\ltx at empty
-  \else
-    \GPT at IfFileExists{\GPT at print}{%
     }{%
-      \GPT at error{Print image `\GPT at print' not found}{%
-        The print version of the image is ignored.\MessageBreak
-        \@ehc
-      }%
-      \let\GPT at print\ltx at empty
+      \def\Gin at llx{0}\let\Gin at lly\Gin at llx
+      \Gin at defaultbp\Gin at urx{\csname #1 width\Gin at attr@hash\endcsname}%
+      \Gin at defaultbp\Gin at ury{\csname #1 height\Gin at attr@hash\endcsname}%
     }%
-  \fi
-  % If option `print' is set, the screen image object
-  % will contain an additional /Alternate entry
-  % and will not be reused.
-  \ifx\GPT at print\ltx at empty
-  \else
-    \expandafter\expandafter\expandafter\ltx at firstoftwo\expandafter\ltx at gobbletwo
-  \fi
-  \ltx at ifundefined{#1 image\GPT at AttrShort}{%
-        \ifx\GPT at print\ltx at empty
-          \ifx\GPT at Attr\ltx at empty
-            \let\GPT at RuleAttr\ltx at empty
-          \else
-            \edef\GPT at RuleAttr{attr{\GPT at Attr}}%
-          \fi
-        \else
-          \ltx at ifundefined{\GPT at print\ltx at space image\GPT at AttrShort}{%
-            \immediate\saveimageresource{\GPT at print}%
-            \setbox\@tempboxa=\hbox{\useimageresource\lastsavedimageresourceindex}%
-            \edef\GPT at PrintObj{\the\lastsavedimageresourceindex}%
-            \expandafter\xdef\csname\GPT at print\ltx at space
-                image\GPT at AttrShort\endcsname{%
-              \useimageresource\GPT at PrintObj\relax
-            }%
-            \immediate\pdfextension obj{%
-              [<<%
-                /Image \GPT at PrintObj\GPT at objref
-                /DefaultForPrinting true%
-              >>]%
-            }%
-            \def\GPT at RuleAttr{%
-              width\wd\@tempboxa height\ht\@tempboxa
-              attr{%
-                \GPT at Attr
-                /Alternates \the\numexpr\pdffeedback lastobj\relax\GPT at objref
-              }%
-            }%
-          }{%
-            \edef\GPT at PrintObj{%
-              \expandafter\expandafter\expandafter\ltx at gobble
-              \csname\GPT at print\ltx at space image\GPT at AttrShort\endcsname
-            }%
-            \immediate\pdfextension obj{%
-              [<<%
-                /Image \GPT at PrintObj\GPT at objref
-                /DefaultForPrinting true%
-              >>]%
-            }%
-            \def\GPT at RuleAttr{%
-              width \csname\GPT at print\ltx at space width\GPT at AttrShort\endcsname
-              height \csname\GPT at print\ltx at space height\GPT at AttrShort\endcsname
-              attr{%
-                \GPT at Attr
-                /Alternates \the\numexpr\pdffeedback lastobj\relax\GPT at objref
-              }%
-            }%
-          }%
-        \fi
-        \saveimageresource\GPT at RuleAttr
-        \ifx\GPT at page\ltx at empty
-        \else
-          page \GPT at page
-        \fi
-        \GPT at pagebox
-        {#1}%
-        \setbox\@tempboxa=\hbox{\useimageresource\lastsavedimageresourceindex}%
-    \def\Gin at llx{0}\let\Gin at lly\Gin at llx
-    \Gin at defaultbp\Gin at urx{\wd\@tempboxa}%
-    \Gin at defaultbp\Gin at ury{\ht\@tempboxa}%
-    \expandafter\xdef\csname\GPT at ReusedName{#1} width\GPT at AttrShort\endcsname{%
-      \the\wd\@tempboxa
-    }%
-    \expandafter\xdef\csname\GPT at ReusedName{#1} height\GPT at AttrShort\endcsname{%
-      \the\ht\@tempboxa
-    }%
-      \expandafter\xdef\csname #1 image\GPT at AttrShort
-        \ifx\GPT at print\ltx at empty\else!\fi\endcsname{%
-        \useimageresource\the\lastsavedimageresourceindex
-      }%
-    \Gin at log{%
-       <#1, id=%
-         \the\lastsavedimageresourceindex
-         \ifx\GPT at page\ltx at empty\else , page=\GPT at page\fi
-         \ifx\GPT at pagebox\ltx at empty\else, pagebox=\GPT at pagebox\fi
-         \ifx\GPT at interpolate\ltx at empty\else, interpolate=true\fi
-         \ifx\GPT at print\ltx at empty
-         \else
-            , print=\GPT at print, id=\GPT at PrintObj
-         \fi
-       , \the\wd\@tempboxa\ltx at space x \the\ht\@tempboxa
-       >%
-     }%
-  }{%
-    \def\Gin at llx{0}\let\Gin at lly\Gin at llx
-    \Gin at defaultbp\Gin at urx{\csname#1 width\GPT at AttrShort\endcsname}%
-    \Gin at defaultbp\Gin at ury{\csname#1 height\GPT at AttrShort\endcsname}%
-  }%
 }
-\def\Ginclude at pdftex#1{%
-  % basic faking of viewport settings so graphic-s- interface
-  % does something sensible
-  \ifx\GPT at AttrShort\@undefined
-    \GPT at info{Interpreting graphics options as viewport}%
-    \let\GPT at AttrShort\@empty
-    \let\Gin at vllx\Gin at llx
-    \let\Gin at vlly\Gin at lly
-    \let\Gin at vurx\Gin at urx
-    \let\Gin at vury\Gin at ury
-  \fi
+\def\Gread at png#1{%
+  \let\Gin at page\@empty
+  \Gread at pdftex{#1}%
+}
+\let\Gread at jpg\Gread at png
+\expandafter\let\csname Gread at jbig2\endcsname\Gread at png
+\def\Gread at pdf#1{%
+  \Gin at interpolatefalse
+  \Gread at pdftex{#1}%
+}
+\let\Gread at mps\Gread at eps
+\def\GPT at setup@scale{%
   \def\@tempa{!}%
   \ifx\Gin at scaley\@tempa
     \let\Gin at scaley\Gin at scalex
@@ -820,21 +217,31 @@
   \else
     \ifx\Gin at scalex\@tempa\let\Gin at scalex\Gin at scaley\fi
   \fi
+}
+\def\Ginclude at pdftex#1{%
+  \GPT at setup@scale
   \Gin at log{%
     <use #1%
-    \ifx\GPT at page\ltx at empty\else, page \GPT at page\fi
+    \ifx\Gin at page\@empty\else, page \Gin at page\fi
     >%
   }%
-  \GPT at info{%
-    #1\ifx\GPT at page\ltx at empty\else, page\GPT at page\fi
-    \ltx at space used\on at line.\MessageBreak
+  \PackageInfo{luatex.def}{%
+    #1 \ifx\Gin at page\@empty\else, page\Gin at page\fi
+    \space used\ifx\on at line\@undefined\else\on at line\fi.}%
+  \PackageInfo{luatex.def}{%
     Requested size: %
-    \the\Gin at req@width\ltx at space x \the\Gin at req@height
+    \the\Gin at req@width\space x \the\Gin at req@height
   }%
+  \Ginclude@@pdftex{\@nameuse{#1 image\Gin at attr@hash}}%
+}
+\def\Ginclude at mps#1{%
+  \GPT at setup@scale
+  \Ginclude@@pdftex{\convertMPtoPDF{#1}{1}{1}}%
+}
+\def\Ginclude@@pdftex#1{%
   \hbox{%
-    \GPT at ResetColorBegin
     \Gscale at box{\Gin at scalex}[\Gin at scaley]{%
-      \ltx at IfUndefined{Gin at vllx}{%
+      \@ifundefined{Gin at vllx}{%
         \GPT at viewportfalse
         % without viewport/trim clipping does not make sense
         % for pdfTeX
@@ -841,12 +248,12 @@
         \Gin at clipfalse
       }{}%
       \ifGin at clip
-          \if!\Gin at vllx\Gin at vlly\Gin at vurx\Gin at vury!%
-          \else
-            \let\GPT at clipend\GPT at DoClipEnd
-            \setbox\@tempboxa\hbox\bgroup
-          \fi
+        \if!\Gin at vllx\Gin at vlly\Gin at vurx\Gin at vury!%
+        \else
+          \let\GPT at clipend\GPT at DoClipEnd
+          \setbox\@tempboxa\hbox\bgroup
         \fi
+      \fi
       \ifGPT at viewport
         \ifdim\Gin at vlly\p@=\z@
         \else
@@ -857,9 +264,7 @@
           \hskip-\Gin at vllx bp\relax
         \fi
       \fi
-      \csname#1 image\GPT at AttrShort
-        \ifx\GPT at print\ltx at empty\else!\fi
-      \endcsname
+      #1%
       \ifGPT at viewport
         \ifdim\Gin at vlly\p@=\z@
         \else
@@ -868,10 +273,9 @@
         \GPT at clipend
       \fi
     }%
-    \GPT at ResetColorEnd
   }%
 }
-\ltx at newif\ifGPT at viewport
+\newif\ifGPT at viewport
 \GPT at viewporttrue
 \let\GPT at clipend\relax
 \def\GPT at DoClipEnd{%
@@ -880,177 +284,36 @@
   % \Gin at urx and \Gin at ury already contain the correct values,
   % so both cases viewport and trim can be handled together:
   \dimen@\Gin at urx\p@
-  % v0.03k \Gin at vllx replaced by \Gin at llx
   \advance\dimen@ -\Gin at llx\p@
   \wd\@tempboxa\strip at pt\dimen@ bp\relax
   \dimen@\Gin at ury\p@
-  % v0.03k \Gin at vlly replaced by \Gin at lly
   \advance\dimen@ -\Gin at lly\p@
   \ht\@tempboxa\strip at pt\dimen@ bp\relax
-  \let\GPT at temp\ltx at empty
-    \ifx\GPT at ocobjnum\ltx at empty
-  \fi
-  \expandafter\saveboxresource\GPT at temp\@tempboxa
+  \saveboxresource\@tempboxa
   \useboxresource\lastsavedboxresourceindex
 }
-\ltx at newif\ifGPT at IsBitmap
-\def\Gread at pdfbitmap#1{%
-  \GPT at IsBitmaptrue
-  \Gread at pdftex{#1}%
-  \GPT at IsBitmapfalse
-}
-
-\edef\Gread at MBox{/MediaBox}
-\def\Gread at pdf{%
-  \GPT at read\Gread@@pdf
-}
-\def\Gread@@pdf#1{%
-  \begingroup
-    \@tempcnta\z@
-    \loop
-    \ifnum\@tempcnta<\@xxxii
-      \catcode\@tempcnta14 %
-      \advance\@tempcnta\@ne
-    \repeat
-    \catcode127=14 %
-    \let\do\@makeother\dospecials\catcode`\ 10 %
-    \catcode\endlinechar5 %
-    \immediate\openin\@inputcheck#1 %
-    \ifeof\@inputcheck
-      \@latex at error{File `#1' not found}\@ehc
-    \else
-      \Gread at true
-      \let\@tempb\Gread at false
-      \loop
-% v0.02e: use \. not \@tempa so the space is preserved before [
-        \read\@inputcheck to\.%
-        \ifeof\@inputcheck
-          \Gread at false
-        \else
-          \expandafter\Gread at find@mbox\. []\\%
-        \fi
-      \ifGread@
-      \repeat
-      \immediate\closein\@inputcheck
-    \fi
-    \ifGin at bbox
-    \else
-      \@latex at error
-      {Cannot determine size of graphic in #1 (no BoundingBox)}%
-      \@ehc
-      \gdef\@gtempa{0 0 72 72 }%
-    \fi
-  \endgroup
-  \expandafter\Gread at parse@bb\@gtempa\\%
-}
-\long\def\Gread at find@mbox#1 [#2]#3\\{% hash-ok
-  \def\@tempa{#1}%
-  \ifx\@tempa\Gread at MBox
-    \gdef\@gtempa{#2 }%
-    \@tempb
-    \Gin at bboxtrue
-  \fi
-}
-
-\def\Ginclude at mps#1{%
-  \def\@tempa{!}%
-  \ifx\Gin at scaley\@tempa
-    \let\Gin at scaley\Gin at scalex
-  \else
-    \ifx\Gin at scalex\@tempa\let\Gin at scalex\Gin at scaley\fi
-  \fi
-  \hbox{%
-    \GPT at ResetColorBegin
-    \Gscale at box{\Gin at scalex}[\Gin at scaley]{%
-      \ltx at IfUndefined{Gin at vllx}{%
-        \GPT at viewportfalse
-        % without viewport/trim clipping does not make sense
-        % for pdfTeX
-        \Gin at clipfalse
-      }{}%
-      \ifGin at clip
-          \if!\Gin at vllx\Gin at vlly\Gin at vurx\Gin at vury!%
-          \else
-            \let\GPT at clipend\GPT at DoClipEnd
-            \setbox\@tempboxa\hbox\bgroup
-          \fi
-        \fi
-      \ifGPT at viewport
-        \ifdim\Gin at vlly\p@=\z@
-        \else
-          \lower\Gin at vlly bp\hbox\bgroup
-        \fi
-        \ifdim\Gin at vllx\p@=\z@
-        \else
-          \hskip-\Gin at vllx bp\relax
-        \fi
-      \fi
-%%%%%      \GPT at catcodes{mps}%
-      \convertMPtoPDF{#1}{1}{1}%
-%%%%%      \GPT at restore@mps
-      \ifGPT at viewport
-        \ifdim\Gin at vlly\p@=\z@
-        \else
-          \egroup
-        \fi
-        \GPT at clipend
-      \fi
-    }%
-    \GPT at ResetColorEnd
-  }%
-}
-\def\Gread at mps{%
-  \GPT at read\Gread at eps
-}
-  \let\Ginclude at png\Ginclude at pdftex
-  \let\Ginclude at jpg\Ginclude at pdftex
-  \let\Ginclude at pdf\Ginclude at pdftex
-  \let\Gread at pdf\Gread at pdftex
-  \let\Gread at png\Gread at pdfbitmap
-  \let\Gread at jpg\Gread at pdfbitmap
-        \expandafter\let\csname Gread at jbig2\endcsname\Gread at pdfbitmap
-        \expandafter\let\csname Ginclude at jbig2\endcsname\Ginclude at pdftex
-
-  \@namedef{Gin at rule@.jpg}#1{{jpg}{.jpg}{#1}}%
-  \@namedef{Gin at rule@.jpeg}#1{{jpg}{.jpeg}{#1}}%
-  \@namedef{Gin at rule@.JPG}#1{{jpg}{.JPG}{#1}}%
-  \@namedef{Gin at rule@.JPEG}#1{{jpg}{.JPEG}{#1}}%
-       \def\Gin at extensions{%
-          .png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,%
-          .PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2}%
-        \@namedef{Gin at rule@.jb2}#1{{jbig2}{.jb2}{#1}}%
-        \@namedef{Gin at rule@.jbig2}#1{{jbig2}{.jbig2}{#1}}%
-
-\@namedef{Gin at rule@.png}#1{{png}{.png}{#1}}
-\@namedef{Gin at rule@.PNG}#1{{png}{.PNG}{#1}}
-\@namedef{Gin at rule@.mps}#1{{mps}{.mps}{#1}}
-\@namedef{Gin at rule@.pdf}#1{{pdf}{.pdf}{#1}}
-\@namedef{Gin at rule@.PDF}#1{{pdf}{.PDF}{#1}}
-\@namedef{Gin at rule@.eps}#1{{eps}{.eps}{#1}}
-
-
-% Rotation
-% slightly hacky, but set width of box 0 to 0pt otherwise
-% the CTM gets restored in the wrong place.
-
+\let\Ginclude at png\Ginclude at pdftex
+\let\Ginclude at jpg\Ginclude at pdftex
+\let\Ginclude at pdf\Ginclude at pdftex
+\expandafter\let\csname Ginclude at jbig2\endcsname\Ginclude at pdftex
 \def\GPT at MatrixIdentity{1 0 0 1}
 \def\GPT at Zero{0}
 \def\GPT at Minus{-}
 \def\GPT at NormalizeNumber#1{%
   \edef#1{#1}%
-  \edef#1{\expandafter\ltx at zapspace\expandafter{#1}}%
+  \edef#1{\expandafter\zap at space#1 \@empty}%
   \edef#1{\expandafter\GPT at ZapPlus#1+\@nil}%
   \edef#1{\expandafter\GPT at ZapMinusMinus#1--\@nil}%
   \expandafter\GPT at Split#1..\@nil
-  \ifx\GPT at frac\ltx at empty
+  \ifx\GPT at frac\@empty
   \else
     \edef\GPT at frac{%
       \expandafter\GPT at Reverse\expandafter{\expandafter}\GPT at frac\@nil
     }%
     \edef\GPT at frac{%
-      \expandafter\GPT at ZapLeadingZeros\GPT at frac\ltx at empty
+      \expandafter\GPT at ZapLeadingZeros\GPT at frac\@empty
     }%
-    \ifx\GPT at frac\ltx at empty
+    \ifx\GPT at frac\@empty
     \else
       \edef\GPT at frac{%
         \expandafter\GPT at Reverse\expandafter{\expandafter}\GPT at frac\@nil
@@ -1057,23 +320,23 @@
       }%
     \fi
   \fi
-  \edef\GPT at sign{\expandafter\ltx at car\GPT at int\ltx at empty\@nil}%
+  \edef\GPT at sign{\expandafter\@car\GPT at int\@empty\@nil}%
   \ifx\GPT at sign\GPT at Minus
-    \edef\GPT at int{\expandafter\ltx at cdr\GPT at int\@nil}%
+    \edef\GPT at int{\expandafter\@cdr\GPT at int\@nil}%
   \else
     \def\GPT at sign{}%
   \fi
   \edef\GPT at int{%
-    \expandafter\GPT at ZapLeadingZeros\GPT at int\ltx at empty
+    \expandafter\GPT at ZapLeadingZeros\GPT at int\@empty
   }%
   \edef\GPT at temp{\GPT at int\GPT at frac}%
-  \ifx\GPT at temp\ltx at empty
+  \ifx\GPT at temp\@empty
     \def#1{0}%
   \else
     \edef#1{%
       \GPT at sign
       \GPT at int
-      \ifx\GPT at frac\ltx at empty
+      \ifx\GPT at frac\@empty
       \else
         .\GPT at frac
       \fi
@@ -1082,8 +345,8 @@
 }
 \def\GPT at ZapPlus#1+#2\@nil{%
   #1%
-  \ifx\ltx at empty#2\ltx at empty
-    \expandafter\ltx at gobble
+  \ifx\@empty#2\@empty
+    \expandafter\@gobble
   \else
     \expandafter\@firstofone
   \fi
@@ -1093,8 +356,8 @@
 }
 \def\GPT at ZapMinusMinus#1--#2\@nil{%
   #1%
-  \ifx\ltx at empty#2\ltx at empty
-    \expandafter\ltx at gobble
+  \ifx\@empty#2\@empty
+    \expandafter\@gobble
   \else
     \expandafter\@firstofone
   \fi
@@ -1104,18 +367,18 @@
 }
 \def\GPT at Split#1.#2.#3\@nil{%
   \def\GPT at int{#1}%
-  \ifx\ltx at empty#2\ltx at empty
-    \let\GPT at frac\ltx at empty
+  \ifx\@empty#2\@empty
+    \let\GPT at frac\@empty
   \else
     \def\GPT at frac{#2}%
   \fi
 }
 \def\GPT at Reverse#1#2#3\@nil{%
-  \ifx\ltx at empty#3\ltx at empty
+  \ifx\@empty#3\@empty
     #2#1%
-    \expandafter\ltx at gobble
+    \expandafter\@gobble
   \else
-    \expandafter\ltx at firstofone
+    \expandafter\@firstofone
   \fi
   {%
     \GPT at Reverse{#2#1}#3\@nil
@@ -1128,57 +391,104 @@
     #1%
   \fi
 }
-  \def\Grot at start{%
-    \GPT at NormalizeNumber\Grot at sin
-    \GPT at NormalizeNumber\Grot at cos
-    \edef\GPT at temp{%
-      \Grot at cos\ltx at space\Grot at sin\ltx at space
-      \if-\Grot at sin
+\def\Grot at start{%
+  \GPT at NormalizeNumber\Grot at sin
+  \GPT at NormalizeNumber\Grot at cos
+  \edef\GPT at temp{%
+    \Grot at cos\space\Grot at sin\space
+    \if-\Grot at sin
+    \else
+      \ifx\Grot at sin\GPT at Zero
+        \GPT at Zero
       \else
-        \ifx\Grot at sin\GPT at Zero
-          \GPT at Zero
-        \else
-          -\Grot at sin
-        \fi
+        -\Grot at sin
       \fi
-      \ltx at space\Grot at cos
-    }%
-    \ifx\GPT at temp\GPT at MatrixIdentity
-      \def\Grot at end{}%
-    \else
-      \pdfextension save\relax
-      \pdfextension setmatrix{\GPT at temp}%
-      \wd\z@\z@
     \fi
+    \space\Grot at cos
   }%
-  \def\Grot at end{\pdfextension restore\relax}%
-  \def\Gscale at start{%
-    \GPT at NormalizeNumber\Gscale at x
-    \GPT at NormalizeNumber\Gscale at y
-    \edef\GPT at temp{%
-      \Gscale at x\ltx at space0 0 \Gscale at y
-    }%
-    \ifx\GPT at temp\GPT at MatrixIdentity
-      \def\Gscale at end{}%
-    \else
-      \pdfextension save\relax
-      \pdfextension setmatrix{\GPT at temp}%
+  \ifx\GPT at temp\GPT at MatrixIdentity
+    \def\Grot at end{}%
+  \else
+    \pdfextension save\relax
+    \pdfextension setmatrix{\GPT at temp}%
+    % Slightly hacky, but set width of box 0 to 0pt otherwise
+    % the CTM gets restored in the wrong place
+    \wd\z@\z@
+  \fi
+}
+\def\Grot at end{\pdfextension restore\relax}
+\def\Gscale at start{%
+  \GPT at NormalizeNumber\Gscale at x
+  \GPT at NormalizeNumber\Gscale at y
+  \edef\GPT at temp{%
+    \Gscale at x\space0 0 \Gscale at y
+  }%
+  \ifx\GPT at temp\GPT at MatrixIdentity
+    \def\Gscale at end{}%
+  \else
+    \pdfextension save\relax
+    \pdfextension setmatrix{\GPT at temp}%
+  \fi
+}
+\def\Gscale at end{\pdfextension restore\relax}
+\@ifundefined{ifGin at setpagesize}
+  {\expandafter\let\csname ifGin at setpagesize\expandafter\endcsname
+                    \csname iftrue\endcsname}
+  {}
+\ifGin at setpagesize
+\ifx\paperwidth\@undefined\else
+  \AtBeginDocument{%
+% If a package has changed \mag, assume it knows what it is doing
+% and leave page size alone
+\ifnum\mag=\@m
+  \@ifundefined{stockwidth}{%
+  \@ifundefined{paperwidth}{%
+  }{%
+    \ifdim\paperwidth>0pt\relax
+      \ifdim\paperheight>0pt\relax
+        \pagewidth=\paperwidth
+        \pageheight=\paperheight
+      \fi
     \fi
   }%
-
-\let\Gscale at end\Grot at end
-
-% Trig patching no longer needed (trig.sty updated)
-
-
+}{%
+  \ifdim\stockwidth>0pt\relax
+    \ifdim\stockheight>0pt\relax
+      \pagewidth=\stockwidth
+      \pageheight=\stockheight
+    \fi
+  \fi
+}%
+\fi
+}
+\fi
+\fi
+\def\Gin at extensions{%
+  .pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,%
+  .PDF,.PNG,.JPG,.JPEG,.JBIG2,.JB2
+}
+\@namedef{Gin at rule@.jpg}#1{{jpg}{.jpg}{#1}}
+\@namedef{Gin at rule@.jpeg}#1{{jpg}{.jpeg}{#1}}
+\@namedef{Gin at rule@.JPG}#1{{jpg}{.JPG}{#1}}
+\@namedef{Gin at rule@.JPEG}#1{{jpg}{.JPEG}{#1}}
+\@namedef{Gin at rule@.jb2}#1{{jbig2}{.jb2}{#1}}%
+\@namedef{Gin at rule@.jbig2}#1{{jbig2}{.jbig2}{#1}}%
+\@namedef{Gin at rule@.png}#1{{png}{.png}{#1}}
+\@namedef{Gin at rule@.PNG}#1{{png}{.PNG}{#1}}
+\@namedef{Gin at rule@.mps}#1{{mps}{.mps}{#1}}
+\@namedef{Gin at rule@.pdf}#1{{pdf}{.pdf}{#1}}
+\@namedef{Gin at rule@.PDF}#1{{pdf}{.PDF}{#1}}
+\@namedef{Gin at rule@.eps}#1{{eps}{.eps}{#1}}
 % MPS conversion
 \def\GPT at LoadSuppPdf{%
-  \ltx at IfUndefined{convertMPtoPDF}{%
-%%%%%    \GPT at catcodes{supp}%
-    \InputIfFileExists{supp-pdf.mkii}{}{%
-      \InputIfFileExists{supp-pdf}{}{}%
-    }%
-%%%%%%    \GPT at restore@supp
+  \@ifundefined{convertMPtoPDF}{%
+    \edef\@tempa{%
+      \catcode`\noexpand\<\the\catcode`\<\relax
+      \catcode`\noexpand\>\the\catcode`\>\relax
+      }%
+    \@makeother\<\@makeother\<%
+    \InputIfFileExists{supp-pdf.mkii}{}{}%
+    \@tempa
   }{%
     % supp-pdf is probably already loaded.
   }%
@@ -1187,19 +497,18 @@
   % of \InputIfFileExists will not work:
   % * \InputIfFileExists has problems with parameters (#1).
   % * Implementation of \providecommand is insufficient in miniltx.tex
-  \ltx at ifundefined{convertMPtoPDF}{%
+  \@ifundefined{convertMPtoPDF}{%
 % 2016/05/21 v0.01c use \newcommand here not \newcommand*  graphics/4472
 \newcommand{\convertMPtoPDF}[3]{%
-      \GPT at error{%
-        Cannot convert ##1 from MPS to PDF.\MessageBreak
+      \PackageError{luatex.def}{%
+        Cannot convert ##1 from MPS to PDF.
         The support file `supp-pdf.mkii' (supp-pdf.tex) is missing%
       }{%
-        The graphics driver for pdfTeX needs `supp-pdf.mkii'\MessageBreak
-        (or `supp-pdf.tex' and/or `supp-mis.tex')\MessageBreak
-        to convert MetaPost output files to PDF.\MessageBreak
+        The graphics driver for pdfTeX needs `supp-pdf.mkii'
+        (or `supp-pdf.tex' and/or `supp-mis.tex')
+        to convert MetaPost output files to PDF.
         These files are part of ConTeXt and can also be found here:%
-        \MessageBreak
-        \ltx at space\ltx at space CTAN:macros/pdftex/graphics/\MessageBreak
+        \space\space CTAN:macros/pdftex/graphics/.
         You'll get more errors if you'll continue now.%
       }%
     }%
@@ -1209,79 +518,47 @@
 \AtBeginDocument{%
   \GPT at LoadSuppPdf
 }
-
-% Adds support for extended MetaPost features (transparency)
-%  \GPT at catcodes removed
-% should replace with luatex catcodetable support, TODO
-\def\LoadMetaPostSpecialExtensions{%
-  \AtBeginDocument{%
-    \ltx at IfUndefined{assignMPStransparency}{%
-%%%%      \GPT at catcodes{mpe}%
-      \let\GPT at found=N%
-      \IfFileExists{supp-pdf.mkii}{\let\GPT at found=Y}{%
-        \IfFileExists{supp-pdf}{\let\GPT at found=Y}{}%
-      }%
-      \ifx Y\GPT at found
-        \InputIfFileExists{supp-mis.mkii}{}{%
-          \InputIfFileExists{supp-mis}{}{\let\GPT at found=N}%
-        }%
-        \ifx Y\GPT at found
-          \InputIfFileExists{supp-mpe.mkii}{}{%
-            \InputIfFileExists{supp-mpe}{}{\let\GPT at found=N}%
-          }%
-          \ifx Y\GPT at found
-            \MPcmykcolorstrue
-            \MPspotcolorstrue
-            \chardef\makeMPintoPDFobject=1 %
-          \else
-            \GPT at warn{%
-              Cannot enable MetaPost Special Extensions,\MessageBreak
-              because `supp-mpe.mkii' (or `supp-mpe.tex')\MessageBreak
-              is missing%
-            }%
-          \fi
-        \else
-          \GPT at warn{%
-            Cannot enable MetaPost Special Extensions,\MessageBreak
-            because `supp-mis.mkii' (or `supp-mis.tex')\MessageBreak
-            is missing%
-          }%
-        \fi
-      \else
-        \GPT at warn{%
-          Cannot enable support for MetaPost images,\MessageBreak
-          because `supp-pdf.mkii' (or `supp-pdf.tex')\MessageBreak
-          is missing%
-        }%
-      \fi
-%%%      \GPT at restore@mpe
-    }{}%
-  }%
-  \let\LoadMetaPostSpecialExtensions\relax
-}
-\ltx at IfUndefined{@onlypreamble}{%
-}{%
-  \@onlypreamble\LoadMetaPostSpecialExtensions
-}
-
-
-% Bail out here if it's not latex or a better emulation than miniltx
-\ifx\@ifpackageloaded\@undefined\expandafter\endinput\fi
-
-\ifx\DoNotLoadEpstopdf\@undefined
-% EPS to PDF conversion
-% delay to begin document to check graphics is loaded (shared
-% config with color) if \DoNotLoadEpstopdf is defined (to anything)
-% skip this.
- \AtBeginDocument{%
-   \ifx\includegraphics\@undefined\else
+% Load package epstopdf if
+% a) LaTeX is running (plain TeX users are on their own),
+% b) and shell escape is enabled (possibly restricted),
+% c) and \DoNotLoadEpstopdf either does not exist or is not \relax,
+% d) and neither pst-pdf nor pdftricks is loaded (by \begin{document}).
+% 
+% In other words, by default .eps files will be automatically
+% converted to .pdf files when outputting pdf.  This can be wrong!
+% If the .pdf is the source, rather than the .eps, you should put
+%  \newcommand{\DoNotLoadEpstopdf}{}
+% before even the \documentclass line of your document.
+% 
+% More information about the epstopdf run will be in the .log file;
+% see http://ctan.org/pkg/epstopdf-pkg for more info about the
+% epstopdf package itself.  In turn, it calls the epstopdf script
+% (http://ctan.org/pkg/epstopdf).
+% 
+% For the first discussion and background on this, see the thread on latex-l:
+% http://thread.gmane.org/gmane.comp.tex.latex.latex3/1465
+%
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname DoNotLoadEpstopdf\endcsname\relax
+  \begingroup\expandafter\expandafter\expandafter\endgroup
+  \expandafter\ifx\csname AtEndOfPackage\endcsname\relax
+  \else
+    \AtEndOfPackage{%
+      \AtBeginDocument{%
+        \ifx\includegraphics\@undefined\else
         \@ifpackageloaded{pst-pdf}{}{%
           \@ifpackageloaded{pdftricks}{}{%
-	   % only add .eps to file extension list if epstopdf is loaded
-	    \edef\Gin at extensions{\Gin at extensions,.eps}%
-            \RequirePackage{epstopdf-base}%
-	    }%
-	    }%
-   \fi
-  }
-\fi
\ No newline at end of file
+            \@ifpackageloaded{graphics}{%
+              \ifnum\directlua{tex.sprint(status.shell_escape)}>0 %
+          % only add .eps to file extension list if epstopdf is loaded
+                \edef\Gin at extensions{\Gin at extensions,.eps}%
+                \RequirePackage{epstopdf-base}[2009/07/12]%
+              \fi}{}
+          }% pdftricks not loaded
+        }% pst-pdf not loaded
+        \fi
+      }% AtBeginDocument block
+    }% AtEndofPackage block
+  \fi % AtEndofPackage not defined
+\fi % DoNotLoadEpstopdf not defined
+\endinput

Modified: trunk/Master/texmf-dist/tex/latex/graphics-def/pdftex.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/graphics-def/pdftex.def	2017-06-12 21:42:28 UTC (rev 44575)
+++ trunk/Master/texmf-dist/tex/latex/graphics-def/pdftex.def	2017-06-12 21:42:50 UTC (rev 44576)
@@ -1,18 +1,8 @@
-\ProvidesFile{pdftex.def}[2017/01/12 v0.06k Graphics/color for pdfTeX]
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% pdftex.def Copyright (C) 2000-2015 David Carlisle, Sebastian Rahtz,
+%%                                    Hans Hagen, Heiko Oberdiek and
+%%                                    Martin Schr\"oder
+%%            Copyright (C) 2016-2017 LaTeX3 project and Heiko Oberdiek 
 %%
-%% LaTeX Colour and Graphics support for PDFTeX
-%%
-%% License
-%% =======
-%%
-%% Copyright (C) 2000-2015 
-%% David Carlisle, Sebastian Rahtz, Hans Hagen,
-%% Heiko Oberdiek and Martin Schr\"oder
-%%
-%% 2016-2017 LaTeX3 project and Heiko Oberdiek 
-%%      https://github.com/latex3/graphics-def/issues
-%%
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3c
 %% of this license or (at your option) any later version.
@@ -23,481 +13,22 @@
 %%
 %% This work has the LPPL maintenance status `maintained'.
 %%
-%% The Current Maintainers of this work are
-%% LaTeX3 project and Heiko Oberdiek 
+%% The Current Maintainer of this work is the LaTeX3 Project.
 %%
-%% This work consists of the file pdftex.def.
+%% https://github.com/latex3/graphics-def/issues
 %%
-%% Usage
-%% =====
-%%
-%% It may be used by specifying the pdftex option to any of the
-%% supported packages, for example:
-%%
-%% \usepackage[pdftex]{graphicx}
-%%
-%% * pdfTeX determines the bounding box of the images by means of
-%%   itself. Therefore the bounding box options should not be used.
-%%   In this cases a warning is issued and viewport is used instead.
-%% * Option "page" (graphicx) for selecting a page of a multipage
-%%   PDF document.
-%% * \pagecolor is supported. \nopagecolor disables the page color.
-%% * Option "quiet" (graphicx/experimental): log messages are suppressed.
-%% * Option "resolution" (graphicx/experimental): this sets
-%%   \pdfimageresolution, see pdfTeX documentation.
-%% * Option "print" (graphicx/experimental): specifies an alternate
-%%   print image (bitmaps only), see PDF specification.
-%% * pdftex.def can be used under plain-TeX with miniltx support.
-%%
-%% "Experimental" means that these features can change or vanish
-%% in later versions.
-%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% History
-% ...
-% 2000/04/20 v0.02s:
-%  * gray color model directly supported (HO).
-% 2000/05/02 v0.02t:
-%  * \pagecolor supported (HO).
-% 2000/05/12 v0.02u:
-%  * support for multipage pdf files, option `page' added (HO).
-% 2000/05/31 v0.02v:
-%  * Option `page' is defined at begin document,
-%    if package `keyval' is loaded after `pdftex.def'.
-% 2000/06/16 v0.03a:
-%  * Added Heiko to author list (DPC).
-% 2000/08/31 v0.03b:
-%  * support for alternate print images: option `print' added (HO).
-%    * This feature is not supported by Ghostscript, xpdf, or AR3.
-%    * The images should have the same dimensions/resolution.
-%  * Two experimental options added (HO):
-%    * `quiet': log messages are suppressed.
-%    * `resolution': sets \pdfimageresolution.
-%    Because these options are not supported by graphicx,
-%    they have to be set after \usepackage{graphicx}, eg.
-%      \setkeys{Gin}{quiet,resolution=300}
-%    Option `quiet' (for pdftex) can be make known to graphic{s,x}
-%    with this line in graphics.cfg:
-%      \DeclareOption{quiet}{\let\Gin at log\@gobble}
-%    Caution: both options are experimental and can be
-%    change in next versions!
-%  * \pdfpage{width,height} are only set, if \paperwidth
-%    is defined (HO).
-% 2000/09/04 v0.03c
-%  * Redefinition of `natwidth' and `natheight' \AtBeginDocument (HO).
-% 2000/09/14 v0.03d
-%  * Fixes for `viewport' and `trim' (HO).
-%  * Clip support added for viewport and trim (HO).
-% 2000/09/14 v0.03e
-%  * Options `bbllx', `bblly', `bburx', `bbury' disabled,
-%    option `bb' redirected with a warning to `viewport' (HO).
-% 2000/11/10 v0.03f
-%  * Bug, that produces an error message, if package `graphics'
-%    is used (introduced in 0.03d), fixed: If \Gin at vllx is not
-%    defined (graphics), then clipping and the moves of options
-%    viewport/trim are silently disabled (HO).
-% 2001/05/25 v0.03g
-%  * \pdfpagewidth and \pdfpageheight are not set to zero,
-%    if \paperwidth and \paperheight are not set (HO).
-% 2001/09/01 v0.03h
-%  * Compatibilty for miniltx.tex, problems fixed:
-%    \@ifpackageloaded, \PackageWarning, \PackageWarningNoLine,
-%    \@currname.
-% 2001/11/29 v0.03i
-%  * Problem with \if at inlabel (plain format) fixed.
-% 2002/06/18 v0.03j
-%  * Contribution by P\'etiard Fran\c{c}ois <petiard at math.univ-fcomte.fr>:
-%    Improvement of \Ginclude at mps (support of viewport and clip).
-% 2002/06/19 v0.03k
-%  * Correction by P\'etiard Fran\c{c}ois for \GPT at DoEndClip.
-% 2005/06/15 v0.03l
-%  * \usebox patch fixed (\aftergroup part removed) (HO).
-% 2005/06/20 v0.03m
-%  * .tif support is removed for pdfTeX >= 1.10a (HO).
-% 2006/02/23 v0.03n
-%  * Compatibility for plain-TeX: file can be loaded multiple times;
-%    colorfix is not applied for undefined macros (HO).
-% 2006/02/24 v0.03o
-%  * Catcode protections mainly because of babel's shorthands (HO).
-% 2006/03/02 v0.03p
-%  * \pagecolor support for plain-TeX fixed (HO).
-% 2006/05/17 v0.03q
-%  * Error message if ConTeXt's supp-pdf.tex is missing and
-%    support of MPS files is not available (Markus Kohm = MK, HO).
-% 2006/06/06 v0.03r
-%  * \nopagecolor/\no at page@color added (HO).
-% 2006/07/16 v0.03s (HO)
-%  * LPPL 1.3c.
-%  * A little usage.
-%  * Test for \MessageBreak changed (comp.text.tex,
-%    message id: <44baca88$0$10529$9b4e6d93 at newsread4.arcor-online.net>).
-% 2006/08/14 v0.03t (HO)
-%  * Extensions added: .jpeg, .JPG, .JPEG, .PNG, .PDF
-%    No variants for .tif, because TIFF support is no longer available.
-%    No need for uppercase variant of .mps.
-% 2007/01/01 v0.04a (HO)
-%  * Support of color stack, introduced in pdfTeX 1.40.0.
-%  * Support of transform matrix commands of pdfTeX 1.40.0.
-%  * The argument for option `page' can be a register.
-% 2007/01/02 v0.04b (HO)
-%  * Internal change: Switching of color stacks is easier by using
-%    \@pdfcolorstack for the stack number. Thus this command
-%    should be redefined, if someone wants to use another color stack
-%    (e.g. for footnotes). \main at pdfcolorstack should not be changed
-%    for this purpose.
-% 2007/01/06 v0.04c (HO)
-%  * Support for JBIG2 added (pdfTeX 1.40.0).
-% 2007/01/08 v0.04d (HO)
-%  * Bug fix: .mps forgotten for extension list if pdfTeX >= 1.40.0
-%  * .jbig2 and .jb2 are not listed in the extension list
-%    if \pdfminorversion < 4. Thus \pdfminorversion should have
-%    the correct value, if pdftex.def is loaded.
-% 2007/03/15 v0.04e (HO)
-%  * Missing comma in \Gin at extensions added (found by Reinhard Kotucha).
-% 2007/04/06 v0.04f (HO)
-%  * Fix for \pagecolor, text before page color can lead to an invalid
-%    page stream. Therefore "page" is now used instead of "direct"
-%    as modifier for \pdfliteral.
-%  * Boolean option `resetcolor' added (pdfTeX >= 0.12n).
-%    The current color is used for PDF or MPS images, unless
-%    the images contain their own color settings.
-%    If option `resetcolor' is set to `true', then the current color
-%    is reset to \normalcolor during image inclusion.
-% 2007/04/17 v0.04g (HO)
-%  * Small improvement of robustness of \pagecolor
-%    and using e-TeX if available.
-% 2007/06/12 v0.04h (HO)
-%  * Fix for \pagecolor: v0.04f uses keyword `page' for \pdfliteral,
-%    but this keyword is not available before pdfTeX 1.30.0.
-% 2007/12/04 v0.04i (HO)
-%  * Fatal error is avoided if image file does not exists.
-% 2007/12/06 v0.04j (HO)
-%  * Option xmpfile added for adding metadata (experimental).
-% 2008/07/16 v0.04k (HO)
-%  * \LoadMetaPostSpecialExtensions
-%    loads additional support for MetaPost images (transparency)
-%    by loading supp-mpe.tex and supp-mis.tex
-%    (method posted in comp.text.tex by Jeremy Lea).
-%    As side effect MetaPost images are put in separate objects
-%    and are not inlined in the page stream.
-%    Status: experimental.
-% 2008/09/08 v0.04l (HO)
-%  * Adds an error message, if pdfTeX is called in DVI mode.
-%  * Aborts loading of the package with an error message,
-%    if pdfTeX is missing.
-% 2009/08/25 v0.04m (HO)
-%  * Catcodes are preserved and initialized for loading of
-%    pdftex.def and ConTeXt's support files.
-%  * ConTeXt's support files have now the extension `.mkii' instead
-%    of `.tex'.
-% 2010/02/14 v0.04n (HO)
-%  * \GPT at catcodes extended for xmlTeX (pdftex.def loads
-%    supp-pdf.mkii at begin document where xmlTeX's catcodes
-%    are already active).
-% 2010/03/11 v0.04o (HO)
-%  * Ensure that \undefined is undefined during loading of
-%    ConTeXt files.
-% 2010/03/12 v0.04p (HO)
-%  * \undefined is also undefined during conversion of MPS.
-% 2010/04/14 v0.04q (HO)
-%  * Optimizations for rotating and scaling:
-%    * remove unnecessary identity transformations
-%    * numbers are normalized
-% 2010/04/15 v0.04r (HO)
-%  * Fix for scale values without integer part.
-% 2010/09/09 v0.05a (HO)
-%  * Option `pagebox' added for specifying the pdf page box
-%    of the included image. Values are `mediabox', `cropbox',
-%    `bleedbox', `trimbox' and `artbox'. Default is `cropbox'. (MS/HO)
-%  * Option `interpolate' added for bitmaps, see PDF specification.
-%    Values are `true' or `false', default is `false'.
-%  * Option `decodearray' added for bitmaps, see PDF specification,
-%    key /Decode of image dictionaries. The value for option
-%    `decodearray' is the value for /Decode without `[' and ']'.
-%  * Option `maskarray' added for bitmaps, see PDF specification,
-%    key /Mask of image dictionaries with array as value.
-%    The value of `maskarray' is the array value for /Mask
-%    without `[' and ']'.
-%  * Option `intent' added for the rendering intent of bitmap
-%    images, see PDF specification, key /Intent of image
-%    dictionaries. The value is a name without a leading slash,
-%    the standard names of the PDF specification:
-%    `AbsoluteColorimetric', `RelativeColorimetric',
-%    `Saturation', `Perceptual'.
-%  * Options `ocobjnum' and `ocobjref' are hooks for those who wants
-%    to work with optional content. The options can be used for both
-%    bitmap and PDF images and are unsupported for MPS.
-%    The optional content dictionary is given by an external
-%    object. Option `ocobjnum' expects the number of that object
-%    (e.g. \pdflastobj). It's a positive integer (greater than zero).
-%    Option `ocobjref' takes the full object reference
-%    (positive integer, followed by ` 0 R' in case of pdfTeX).
-%    Other drivers might support `ocobjref' as well, in case of
-%    PostScript/pdfmark drivers, the object is usually referenced by
-%    a name in curly braces.
-%  * Tiff support removed for driver versions between 1.10a and 1.30.
-% 2010/09/14 v0.05b (HO)
-%  * Fix, \pagecolor got broken accidentally (in v0.05a).
-% 2010/11/26 v0.05c (HO)
-%  * \stockwidth and \stockheight of class `memoir' respected.
-% 2011/01/28 v0.05d (HO)
-%  * Patching trig.sty is improved by doing it earlier in some
-%    cases, e.g. if one of class `memoir', package `scrlfile' or
-%    package `filehook' is loaded.
-% 2011/04/21 v0.06a (HO)
-%  * The use info on the screen goes with an information
-%    entry in the .log file that also tells the requested
-%    width (feature request of Axel Berger).
-%  * Use of packages `infwarerr' and `ltxcmds'.
-% 2011/04/25 v0.06b (HO)
-%  * Fix in \GPT at NormalizeNumber.
-%  * Date fixed in \ProvidesFile.
-% 2011/05/18 v0.06c (HO)
-%  * The ConTeXt support files `supp-pdf.*' and `supp-mpe.*' do
-%    not prevent reloading. Therefore `pdftex.def' only tries to load
-%    them if \convertMPtoPDF and \assignMPStransparency are not
-%    available. This fixes a compatibilty issue with class `combine'.
-% 2011/05/27 v0.06d (HO)
-%  * Fix for v0.06a, package `ltxcmds' was not loaded in plain TeX.
-% 2016/01/23 v0.6e (DPC)
-%  * Move EPS handler here from graphics.cfg
-% 2016/06/04 v0.6f (DPC)
-%  * support graphcs/color option (no)setpagesize
-% 2016/06/15 v0.6g (DPC)
-%  * typo
-% 2016/06/17 v0.6h (DPC)
-%  * guards for contributed packages and plain TeX
-% 2016/07/10 v0.6j (DPC)
-%  * don't set page size for non standard \mag
-% 2017/01/12 v0.6k (DPC)
-%  * graphics options as viewport for graphics/4499
-%
-
-
-% Prefix of internal commands for this file `pdftex.def':
-%   \GPT@ (Graphics bundle PdfTex driver)
-
-\expandafter\edef\csname GPT at AtEnd\endcsname{%
-  \expandafter\noexpand\csname GPT at restore@\endcsname
-  \catcode35 \the\catcode35\relax % #
-  \catcode64 \the\catcode64\relax % @
-  \noexpand\endinput
-}
-\catcode35 6 % #
-\catcode64 11 % @
-\def\GPT at catcodes#1{%
-  \expandafter\edef\csname GPT at restore@#1\endcsname{%
-    \let\noexpand\undefined
-        \expandafter\noexpand\csname GPTorg@#1 at undefined\endcsname
-    \let\expandafter\noexpand\csname GPTorg@#1 at undefined\endcsname
-        \noexpand\@undefined
-    \endlinechar \the\endlinechar
-    \catcode9 \the\catcode9 % tab
-    \catcode13 \the\catcode13 % ^^M
-    \catcode32 \the\catcode32 % space
-    \catcode33 \the\catcode33 % !
-    \catcode34 \the\catcode34 % "
-    \catcode35 \the\catcode35 % #
-    \catcode36 \the\catcode36 % $
-    \catcode37 \the\catcode37 % %
-    \catcode38 \the\catcode38 % &
-    \catcode39 \the\catcode39 % '
-    \catcode40 \the\catcode40 % (
-    \catcode41 \the\catcode41 % )
-    \catcode42 \the\catcode42 % *
-    \catcode43 \the\catcode43 % +
-    \catcode44 \the\catcode44 % ,
-    \catcode45 \the\catcode45 % -
-    \catcode46 \the\catcode46 % .
-    \catcode47 \the\catcode47 % /
-    \catcode58 \the\catcode58 % :
-    \catcode59 \the\catcode59 % ;
-    \catcode60 \the\catcode60 % <
-    \catcode61 \the\catcode61 % =
-    \catcode62 \the\catcode62 % >
-    \catcode63 \the\catcode63 % ?
-    \catcode64 \the\catcode64 % @
-    \catcode91 \the\catcode91 % [
-    \catcode92 \the\catcode92 % \
-    \catcode93 \the\catcode93 % ]
-    \catcode94 \the\catcode94 % ^
-    \catcode95 \the\catcode95 % _
-    \catcode96 \the\catcode96 % `
-    \catcode123 \the\catcode123 % {
-    \catcode124 \the\catcode124 % |
-    \catcode125 \the\catcode125 % }
-    \catcode126 \the\catcode126 % ~
-  }%
-  \endlinechar 13 %
-  \catcode9 10 % tab
-  \catcode13 5 % ^^M (end of line)
-  \catcode64 11 %
-  \catcode61 12 % =
-  \catcode32 10 % space
-  \catcode33 12 % !
-  \catcode34 12 % "
-  \catcode35 6 % #
-  \catcode36 3 % $
-  \catcode37 14 % %
-  \catcode38 4 % &
-  \catcode39 12 % '
-  \catcode40 12 % (
-  \catcode41 12 % )
-  \catcode42 12 % *
-  \catcode43 12 % +
-  \catcode44 12 % ,
-  \catcode45 12 % -
-  \catcode46 12 % .
-  \catcode47 12 % /
-  \catcode58 12 % :
-  \catcode59 12 % ;
-  \catcode60 12 % <
-  \catcode61 12 % =
-  \catcode62 12 % >
-  \catcode63 12 % ?
-  \catcode64 11 % @
-  \catcode91 12 % [
-  \catcode92 0 % \
-  \catcode93 12 % ]
-  \catcode94 7 % ^
-  \catcode95 8 % _
-  \catcode96 12 % `
-  \catcode123 1 % {
-  \catcode124 12 % |
-  \catcode125 2 % }
-  \catcode126 13 % ~
-  \expandafter\let\csname GPTorg@#1 at undefined\endcsname\undefined
-  \let\undefined\@undefined
-}
-\GPT at catcodes{}
-
-% 1.10a: .tif support was dropped
-% 1.10a: keywords mediabox|cropbox|... for \pdfximage
-% 1.30.0: keyword `page' for \pdfliteral added.
-% 1.40.0: JBIG2 support added in pdfTeX 1.40.0
-
-\ifx\pdftexversion\@undefined
-  \def\driver at release{1}%
-\else
-  \ifnum\pdftexversion<12 %
-    \def\driver at release{2}%
-  \else
-    \ifnum\pdftexversion<13 %
-      \ifnum\expandafter`\pdftexrevision<`n %
-        \def\driver at release{3}%
-      \else
-        \def\driver at release{4}%
-      \fi
-    \else
-      \ifnum\pdftexversion=13 %
-        \def\driver at release{5}%
-      \else
-        \ifnum\pdftexversion=14 %
-          \def\driver at release{6}%
-        \else
-          \ifnum\pdftexversion<110 %
-            \def\driver at release{7}%
-          \else
-            \ifnum\pdftexversion<130 %
-              \def\driver at release{8}%
-            \else
-              \ifnum\pdftexversion<140 %
-                \def\driver at release{9}%
-              \else
-                \def\driver at release{10}%
-              \fi
-            \fi
-          \fi
-        \fi
-      \fi
-    \fi
-  \fi
-\fi
-
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname RequirePackage\endcsname\relax
-  \input infwarerr.sty\relax
-  \input ltxcmds.sty\relax
-\else
-  \RequirePackage{infwarerr}[2007/09/09]%
-  \RequirePackage{ltxcmds}[2010/12/07]%
-\fi
-
-\def\GPT at error{\@PackageError{pdftex.def}}%
-\def\GPT at warn{\@PackageWarning{pdftex.def}}%
-\ifx\Gin at log\@undefined
-  \def\Gin at log{\message}%
-\fi
-\def\GPT at info{\@PackageInfoNoLine{pdftex.def}}%
-
-% Are we running under PDFTeX?
-\ltx at IfUndefined{pdftexversion}{%
-  \GPT at error{%
-    Option `pdftex' requires pdfTeX,\MessageBreak
-    but pdfTeX features are missing.\MessageBreak
-    Loading of this driver file is aborted%
-  }\@ehc
-  \expandafter\GPT at AtEnd
-}{}
-
-% Ensure PDF mode
-\ifnum\pdfoutput<1 %
-  \GPT at error{%
-    PDF mode expected, but DVI mode detected!\MessageBreak
-    If you are using `latex', then call `pdflatex'.\MessageBreak
-    Otherwise check and  correct the driver options.\MessageBreak
-    Error recovery by switching to PDF mode%
-  }\@ehc
-  \pdfoutput=1 %
-\fi
-\@ifundefined{ifGin at setpagesize}
-  {\expandafter\let\csname ifGin at setpagesize\expandafter\endcsname
-                    \csname iftrue\endcsname}
-  {}
-\ifGin at setpagesize
-\ifx\paperwidth\@undefined\else
-\AtBeginDocument{%
-% If a package has changed \mag, assume it knows what it is doing
-% and leave page size alone
-\ifnum\mag=\@m
-  \ltx at IfUndefined{stockwidth}{%
-  \ltx at IfUndefined{paperwidth}{%
-  }{%
-    \ifdim\paperwidth>0pt\relax
-      \ifdim\paperheight>0pt\relax
-        \pdfpagewidth=\paperwidth
-        \pdfpageheight=\paperheight
-      \fi
-    \fi
-  }%
-}{%
-  \ifdim\stockwidth>0pt\relax
-    \ifdim\stockheight>0pt\relax
-      \pdfpagewidth=\stockwidth
-      \pdfpageheight=\stockheight
-    \fi
-  \fi
-}%
-\fi
-}
-\fi
-\fi
-
-% Colour Support. The following models may be used.
-%   * cmyk   supported directly.
-%   * rgb    supported directly.
-%   * RGB    converted to rgb by this file.
-%   * gray   supported directly.
-%   * named  converted to cmyk by this file.
-%
+\ProvidesFile{pdftex.def}
+  [2017/06/01 v1.0a Graphics/color driver for pdftex]
 \def\c at lor@arg#1{%
   \dimen@#1\p@
   \ifdim\dimen@<\z@\dimen@\maxdimen\fi
   \ifdim\dimen@>\p@
     \PackageError{color}{Argument `#1' not in range [0,1]}\@ehd
-  \fi
-}
+  \fi}
+\def\color at gray#1#2{%
+  \c at lor@arg{#2}%
+  \edef#1{#2 g #2 G}%
+  }
 \def\color at cmyk#1#2{\c at lor@@cmyk#2\@@#1}
 \def\c at lor@@cmyk#1,#2,#3,#4\@@#5{%
   \c at lor@arg{#4}%
@@ -505,11 +36,7 @@
   \c at lor@arg{#2}%
   \c at lor@arg{#3}%
   \edef#5{#1 #2 #3 #4 k #1 #2 #3 #4 K}%
-}
-\def\color at gray#1#2{%
-  \c at lor@arg{#2}%
-  \edef#1{#2 g #2 G}%
-}
+  }
 \def\color at rgb#1#2{\c at lor@@rgb#2\@@#1}
 \def\c at lor@@rgb#1,#2,#3\@@#4{%
   \c at lor@arg{#1}%
@@ -516,67 +43,33 @@
   \c at lor@arg{#2}%
   \c at lor@arg{#3}%
   \edef#4{#1 #2 #3 rg #1 #2 #3 RG}%
-}
+  }
 \def\color at RGB#1#2{\c at lor@@RGB#2\@@#1}
 \def\c at lor@@RGB#1,#2,#3\@@#4{%
-  \c at lor@RGB at rgb{#1}\@tempa
-  \c at lor@RGB at rgb{#2}\@tempb
-  \c at lor@RGB at rgb{#3}\@tempc
-  \c at lor@@rgb\@tempa,\@tempb,\@tempc\@@#4%
-}
+ \c at lor@RGB at rgb{#1}\@tempa
+ \c at lor@RGB at rgb{#2}\@tempb
+ \c at lor@RGB at rgb{#3}\@tempc
+ \c at lor@@rgb\@tempa,\@tempb,\@tempc\@@#4%
+  }
 \def\c at lor@RGB at rgb#1#2{%
   \dimen@#1\p@
   \divide\dimen@\@cclv
-  \edef#2{\strip at pt\dimen@}%
-}
-
+  \edef#2{\strip at pt\dimen@}}
 \def\color at named#1#2{\c at lor@@named#2,,\@@#1}
 \def\c at lor@@named#1,#2,#3\@@#4{%
-  \ltx at IfUndefined{col@#1}{%
-    \PackageError{color}{Undefined color `#1'}\@ehd
-  }{%
-    \edef#4{\csname col@#1\endcsname}%
-  }%
-}
-
-\ltx at IfUndefined{pdfcolorstack}{%
-  \def\set at color{%
-    \pdfliteral{\current at color}%
-    \aftergroup\reset at color
-  }%
-  \def\reset at color{%
-    \pdfliteral{\current at color}%
-  }%
-}{%
-  \chardef\main at pdfcolorstack=0 %
-  \ltx at ifundefined{@pdfcolorstack}{%
-    \def\@pdfcolorstack{\main at pdfcolorstack}%
-  }{}%
-  \def\set at color{%
-    \pdfcolorstack\@pdfcolorstack push{\current at color}%
-    \aftergroup\reset at color
-  }%
-  \def\reset at color{%
-    \pdfcolorstack\@pdfcolorstack pop\relax
-  }%
-}
-\def\define at color@named#1#2{%
-  \expandafter\edef\csname col@#1\endcsname{#2}%
-}
+  \@ifundefined{col@#1}%
+    {\PackageError{color}{Undefined color `#1'}\@ehd}%
+  {\edef#4{\csname col@#1\endcsname}}%
+  }
+\chardef\main at pdfcolorstack=0 %
+\@ifundefined{@pdfcolorstack}
+  {\def\@pdfcolorstack{\main at pdfcolorstack}}{}
 \def\current at color{0 g 0 G}
-
-% v0.02t: support for \pagecolor
-% fixed in v0.02p by using a box register, see
-% http://tug.org/pipermail/pdftex/2005-August/005916.html
-%
-% v0.03r: \nopagecolor/\no at page@color added.
-\ltx at newglobalif\ifGPT at pagecolor
-\ltx at ifundefined{nopagecolor}{%
-  \def\nopagecolor{\no at page@color}%
-}{}
-\def\no at page@color{%
-  \GPT at pagecolorfalse
-}
+\def\set at color{%
+  \pdfcolorstack\@pdfcolorstack push{\current at color}%
+  \aftergroup\reset at color}
+\def\reset at color{\pdfcolorstack\@pdfcolorstack pop\relax}
+\newif\ifGPT at pagecolor
 \begingroup\expandafter\expandafter\expandafter\endgroup
 \expandafter\ifx\csname currentgrouplevel\endcsname\relax
   \catcode`X=9  % ignore
@@ -588,11 +81,11 @@
 \def\set at page@color{%
   \GPT at pagecolortrue
   \global\let\current at page@color\current at color
-  \ltx at ifundefined{GPT at outputbox}{%
+  \ifundefined{GPT at outputbox}{%
     % \newbox is outer in plain
     \csname newbox\endcsname\GPT at outputbox
   }{}%
-  \ltx at ifundefined{GPTorg at shipout}{%
+  \@ifundefined{GPTorg at shipout}{%
     \global\let\GPTorg at shipout\shipout
     \gdef\shipout{%
 X     % ensure \GPT at outputbox is really void
@@ -613,7 +106,7 @@
     }%
     \gdef\GPT@@shipout{%
       \ifvoid\GPT at outputbox\relax
-        \GPT at warn{Ignoring void output box}%
+        \PackageInfo{pdftex.def}{Ignoring void output box}%
       \else
         \setbox\GPT at outputbox=\vbox{%
           \GPT at pageliteral
@@ -624,12 +117,12 @@
     }%
     \gdef\GPT at pageliteral{%
       \ifGPT at pagecolor
-        \pdfliteral\ifnum\driver at release>8 page\else direct\fi{%
+        \pdfliteral page{%
           q % gsave
-          \current at page@color\ltx at space
+          \current at page@color\space
           n % newpath
-          0 0 \strip at pt\pdfpagewidth\ltx at space
-          \strip at pt\pdfpageheight\ltx at space re % rectangle
+          0 0 \strip at pt\pdfpagewidth\space
+          \strip at pt\pdfpageheight\space re % rectangle
           % there is no need to convert to bp
           f % fill
           Q% grestore
@@ -640,691 +133,103 @@
 }
 \catcode`\X=11 %
 \catcode`\E=11 %
-
-% Need the `colorfix' modifications as no internal colour stack
-% is maintained
-%<*colorfix>
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname pdfcolorstack\endcsname\relax
-  \AtBeginDocument{%
-    \begingroup\expandafter\expandafter\expandafter\endgroup
-    \expandafter\ifx\csname color\endcsname\relax
-      % Without color we don't need any fixes.
-    \else
-      \ltx at ifundefined{@ldc at l@r}{%
-        \let\@ldc at l@r\color
-        \def\color{%
-          \ltx at IfUndefined{if at inlabel}{}{%
-            \csname if at inlabel\expandafter\endcsname
-            \expandafter\leavevmode\csname fi\endcsname
-          }%
-          \@ldc at l@r
-        }%
-      }{}%
-      \ltx at ifundefined{@lduseb at x}{%
-        \ltx at IfUndefined{usebox}{}{%
-          \let\@lduseb at x\usebox
-          \def\usebox#1{\@lduseb at x{#1}\reset at color}%
-        }%
-      }{}%
-    \fi
-  }%
-\fi
-%</colorfix>
-
-%
-% Graphic inclusion. Currently supports .png, .jpg, .mps and .pdf inclusion;
-% .tif support is dropped since pdfTeX 1.10a.
-% .mps is MetaPost output.
-% .mps inclusion depends on loading a CONTEXT module by Hans Hagen;
-% .pdf also needs a Context module unless pdftex 0.12n or later.
-%
-% PNG bitmaps may be scaled/rotated as usual
-% by the graphics commands or keyword arguments.
-%
-% Note the magic in front of the file name after \pdfimage, to
-% prevent it fouling up with file names starting with "depth".
-\def\Gread at png{%
-  \GPT at read\Gread@@png
+\def\define at color@named#1#2{%
+  \expandafter\edef\csname col@#1\endcsname{#2}}
+\def\no at page@color{%
+  \GPT at pagecolorfalse
 }
-\def\Gread@@png#1{%
-  \setbox\@tempboxa\hbox{%
-    \pdfimage\noexpand\noexpand\noexpand\ltx at empty#1\relax
-  }%
-  \def\Gin at llx{0}\let\Gin at lly\Gin at llx
-  \Gin at defaultbp\Gin at urx{\wd\@tempboxa}%
-  \Gin at defaultbp\Gin at ury{\ht\@tempboxa}%
-}
-
-%
-% support for
-% * multipage pdf images (pdfTeX v0.14+)
-% * alternate print image (bitmaps only)
-%   * driver version>=5 (0.14)
-%   * printed image can be resused, but not the base image,
-%     because it's dictionary contains the additional key /Alternates.
-%   * not supported by Ghostscript or xpdf.
-% * option quiet
-% * option resetcolor
-% * option xmpfile
-%
-% \GPT at page: page number of pdf image or \ltx at empty otherwise.
-\let\GPT at page\ltx at empty
-% \GPT at print: file name for alternate image or \ltx at empty otherwise.
-\let\GPT at print\ltx at empty
-\let\GPT at xmpfile\ltx at empty
-\let\GPT at pagebox\ltx at empty
-\let\GPT at pagebox@\ltx at empty
-\let\GPT at interpolate\ltx at empty
-\let\GPT at decodearray\ltx at empty
-\let\GPT at mask\ltx at empty
-\let\GPT at intent\ltx at empty
-\let\GPT at ocobjnum\ltx at empty
-\ltx at newif\ifGPT at ResetColor
-\let\GPT at ResetColorEnd\relax
-\def\GPT at ResetColorBegin{%
-  \ifGPT at ResetColor
-    \ifGPT at IsBitmap
-    \else
-      \begingroup
-      \normalcolor
-      \let\GPT at ResetColorEnd\endgroup
-    \fi
-  \fi
-}
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname pdfmatch\endcsname\relax
-  \def\GPT at match#1#2#3#4{}%
-  \def\GPT at pat@real/{}%
-\else
-  \def\GPT at match#1#2{%
-    \ifnum\pdfmatch{#2}{#1}=1 %
-      \expandafter\ltx at firstoftwo
-    \else
-      \expandafter\ltx at secondoftwo
-    \fi
-  }%
-  \def\GPT at pat@real/{%
-    (%
-      0(\ltx at backslashchar.[0-9]*)?|%
-      \ltx at backslashchar.[0-9]+|%
-      1(\ltx at backslashchar.0*)?%
-    )%
-  }%
-\fi
-\begingroup
-  \toks@{%
-    \define at key{Gin}{resetcolor}[true]{%
-      \csname GPT at ResetColor%
-        \expandafter\ifx\csname iftrue\expandafter\endcsname
-                        \csname if#1\endcsname
-          true%
-        \else
-          false%
-        \fi
-      \endcsname
-    }%
-    \ifnum\driver at release>5 %
-      \define at key{Gin}{page}{%
-        \def\GPT at page{#1}%
-        \ifx\GPT at page\ltx at empty
-        \else
-          \edef\GPT at page{\number\GPT at page}%
-        \fi
-      }%
-      \define at key{Gin}{print}{%
-        \def\GPT at print{#1}%
-      }%
-    \else
-      \define at key{Gin}{page}{%
-        \GPT at warn{%
-          pdfTeX >= 0.14 required for option\MessageBreak `page'%
-        }%
-      }%
-      \define at key{Gin}{print}{%
-        \GPT at warn{%
-          pdfTeX >= 0.14 required for option\MessageBreak `print'%
-        }%
-      }%
-    \fi
-    \ifnum\driver at release>7 %
-      % option pagebox
-      \define at key{Gin}{pagebox}{%
-        \expandafter\let\expandafter\GPT at pagebox
-            \csname GPT at pagebox@#1\endcsname
-        \ifx\GPT at pagebox\relax
-          \let\GPT at pagebox\ltx at empty
-          \GPT at warn{%
-            Unknown value `#1' for `pagebox'.\MessageBreak
-            Supported values:\MessageBreak
-            mediabox, cropbox, bleedbox, trimbox, artbox%
-          }%
-        \fi
-      }%
-      \def\GPT at pagebox@mediabox{mediabox}%
-      \let\GPT at pagebox@cropbox\ltx at empty
-      \def\GPT at pagebox@bleedbox{bleedbox}%
-      \def\GPT at pagebox@trimbox{trimbox}%
-      \def\GPT at pagebox@artbox{artbox}%
-      % option interpolate
-      \define at key{Gin}{interpolate}[true]{%
-        \expandafter\let\expandafter\GPT at interpolate
-            \csname GPT at interpolate@#1\endcsname
-        \ifx\GPT at interpolate\relax
-          \let\GPT at interpolate\ltx at empty
-          \GPT at warn{%
-            Unknown value `#1' for `interpolate'.\MessageBreak
-            Supported values: true, false%
-          }%
-        \fi
-      }%
-      \let\GPT at interpolate@false\ltx at empty
-      \def\GPT at interpolate@true{1}% non-empty, value does not matter
-      % option decodearray
-      \define at key{Gin}{decodearray}{%
-        \def\GPT at decodearray{#1}%
-        \ifx\GPT at decodearray\ltx at empty
-        \else
-          \GPT at match\GPT at decodearray{%
-            ((^| )\GPT at pat@real/ \GPT at pat@real/)+$%
-          }{}{%
-            \GPT at warn{%
-              Invalid value (\GPT at decodearray)\MessageBreak
-              for `decodearray' is ignored%
-            }%
-            \let\GPT at decodearray\ltx at empty
-          }%
-        \fi
-      }%
-      % option maskarray
-      \define at key{Gin}{maskarray}{%
-        \def\GPT at mask{#1}%
-        \ifx\GPT at mask\ltx at empty
-        \else
-          \GPT at match\GPT at mask{%
-            ((^| )[0-9]+ [0-9]+)+$%
-          }{}{%
-            \GPT at warn{%
-              Invalid value (\GPT at mask)\MessageBreak
-              for `maskarray' is ignored%
-            }%
-            \let\GPT at mask\ltx at empty
-          }%
-          \ifx\GPT at mask\ltx at empty
-          \else
-            \edef\GPT at mask{[\GPT at mask]}%
-          \fi
-        \fi
-      }%
-      % option intent
-      \define at key{Gin}{intent}{%
-        \def\GPT at intent{#1}%
-        \ifx\GPT at intent\ltx at empty
-        \else
-          \GPT at match\GPT at intent{%
-            ^((Absolute|Relative)Colorimetric|Saturation|Perceptual)$%
-          }{}{%
-            \GPT at match\GPT at intent{%
-              ^[A-Za-z0-9_]+$%
-            }{%
-              \GPT at warn{%
-                Rendering intent `\GPT at intent'\MessageBreak
-                is not a standard name of the PDF specification%
-              }%
-            }{%
-              \GPT at warn{%
-                Ignoring intent `\GPT at intent'\MessageBreak
-                with unusual characters%
-              }%
-              \let\GPT at intent\ltx at empty
-            }%
-          }%
-        \fi
-      }%
-      % option ocobjnum
-      \define at key{Gin}{ocobjnum}{%
-        \edef\GPT at ocobjnum{#1}%
-        \ifx\GPT at ocobjnum\ltx at empty
-        \else
-          \edef\GPT at ocobjnum{\number\GPT at ocobjnum}%
-          \GPT at match\GPT at ocobjnum{^[1-9]+[0-9]*$}{%
-          }{%
-            \GPT at warn{%
-              Invalid value (\GPT at ocobjnum)\MessageBreak
-              for `ocobjnum' is ignored%
-            }%
-            \let\GPT at ocobjnum\ltx at empty
-          }%
-          \ifx\GPT at ocobjnum\ltx at empty
-          \else
-            \edef\GPT at ocobjnum{\number\GPT at ocobjnum}%
-          \fi
-        \fi
-      }%
-      % option ocobjref
-      \define at key{Gin}{ocobjref}{%
-        \edef\GPT at ocobjnum{#1}%
-        \ifx\GPT at ocobjnum\ltx at empty
-        \else
-          \edef\GPT at ocobjnum{%
-            \expandafter\strip at prefix\meaning\GPT at ocobjnum
-          }%
-          \GPT at match\GPT at ocobjnum{^[1-9]+[0-9]* 0 R$}{%
-          }{%
-            \GPT at warn{%
-              Invalid value (\GPT at ocobjnum)\MessageBreak
-              for `ocobjref' is ignored%
-            }%
-            \let\GPT at ocobjnum\ltx at empty
-          }%
-          \ifx\GPT at ocobjnum\ltx at empty
-          \else
-            \begingroup
-              \def\GPT at temp##1 ##2\@nil{\endgroup
-                \def\GPT at ocobjnum{##1}%
-              }%
-            \expandafter\GPT at temp\GPT at ocobjnum\@nil
-            \edef\GPT at ocobjnum{\number\GPT at ocobjnum}%
-          \fi
-        \fi
-      }%
-    \else
-      \def\GPT at temp#1{%
-        \define at key{Gin}{#1}{%
-          \GPT at warn{%
-            pdfTeX >= 1.10a required for option `#1'%
-          }%
-        }%
-      }%
-      \GPT at temp{pagebox}%
-      \GPT at temp{interpolate}%
-      \GPT at temp{decodearray}%
-      \GPT at temp{maskarray}%
-      \GPT at temp{intent}%
-      \GPT at temp{ocobjnum}%
-      \GPT at temp{ocobjref}%
-    \fi
-    \define at key{Gin}{quiet}[]{%
-      \let\Gin at log\ltx at gobble
-    }%
-    \define at key{Gin}{resolution}{%
-      \pdfimageresolution#1\relax
-    }%
-    \define at key{Gin}{xmpfile}[\Gin at base.xmp]{%
-      \def\GPT at xmpfile{#1}%
-    }%
-  }%
-  \ltx at IfUndefined{define at key}{%
-    \edef\x{\endgroup
-      \noexpand\AtBeginDocument{%
-        \noexpand\ltx at IfUndefined{define at key}{}{\the\toks@}%
-      }%
-    }\x
-  }{%
-    \expandafter\endgroup\the\toks@
-  }%
-
-% redefinitions of some graphicx options:
-\def\GPT at disable#1{%
-  \GPT at warn{%
-    Option `#1' is not supported, use\MessageBreak
-    option `viewport' instead%
-  }%
-}
-\def\GPT at fix{%
-  \begingroup\expandafter\expandafter\expandafter\endgroup
-  \expandafter\ifx\csname define at key\endcsname\relax
+\def\Gread at pdftex#1{%
+  \expandafter\ifx\expandafter\relax\pdffilesize{#1}\relax
+    \expandafter\@secondoftwo
   \else
-    \def\KV at Gin@bb{%
-      \GPT at warn{%
-        Option `bb' does not make sense,\MessageBreak
-        using `viewport' instead%
-      }%
-      \KV at Gin@viewport
-    }%
-    \define at key{Gin}{bbllx}{\GPT at disable{bbllx}}%
-    \define at key{Gin}{bblly}{\GPT at disable{bblly}}%
-    \define at key{Gin}{bburx}{\GPT at disable{bburx}}%
-    \define at key{Gin}{bbury}{\GPT at disable{bbury}}%
+    \expandafter\@firstoftwo
   \fi
-}
-\AtBeginDocument{\GPT at fix}
-
-%
-% Check for image file existence
-%
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname pdffilesize\endcsname\relax
-  \ifnum\driver at release>9 %
-    \RequirePackage{pdftexcmds}\relax
-  \fi
-  \begingroup\expandafter\expandafter\expandafter\endgroup
-  \expandafter\ifx\csname pdf at filesize\endcsname\relax
-    \def\GPT at IfFileExists#1{%
-      \IfFileExists{#1}%
-    }%
-  \else
-    \def\GPT at IfFileExists#1{%
-      \expandafter\expandafter\expandafter\ifx
-      \expandafter\expandafter\expandafter\relax\pdf at filesize{#1}\relax
-        \expandafter\ltx at secondoftwo
+    {\Gread@@pdftex{#1}}%
+    {%
+      \def\Gin at llx{0}%
+      \let\Gin at lly\Gin at llx
+      \def\Gin at urx{72}%
+      \let\Gin at ury\Gin at urx
+      \ifGin at draft
       \else
-        \expandafter\ltx at firstoftwo
+        \PackageError{pdftex.def}{File `#1' not found: using draft setting}%
+        \@ehc
+        \Gin at drafttrue
       \fi
     }%
-  \fi
-\else
-  \def\GPT at IfFileExists#1{%
-    \expandafter\ifx\expandafter\relax\pdffilesize{#1}\relax
-      \expandafter\ltx at secondoftwo
-    \else
-      \expandafter\ltx at firstoftwo
-    \fi
-  }%
-\fi
-
-%
-% Wrapper for \Gread at ... that checks image existence first.
-%
-\def\GPT at read#1#2{%
-  \GPT at IfFileExists{#2}%
-  {%
-    #1{#2}%
-  }{%
-    \def\Gin at llx{0}%
-    \let\Gin at lly\Gin at llx
-    \def\Gin at urx{72}%
-    \let\Gin at ury\Gin at urx
-    \ifGin at draft
-    \else
-      \GPT at error{File `#2' not found}{%
-        Using draft setting for this image.\MessageBreak
-        \@ehc
-      }%
-      \Gin at drafttrue
-    \fi
-  }%
 }
-
-%
-% mechanism for re-use of objects also
-% allows us to get the size by deriving it from the initial storage;
-% this works for all graphics types.
-%
-\ltx at ifundefined{Gread at gobject}{%
-  \csname newcount\endcsname\Gread at gobject
-}{}
-\def\GPT at ReusedName#1{%
-  \ifx\GPT at print\ltx at empty
-    #1%
-  \else
-    \GPT at print
-  \fi
-}
-\def\GPT at objref{ 0 R}
-\def\Gread at pdftex{%
-  \GPT at read\Gread@@pdftex
-}
+\let\Gin at attr@hash\@empty
+\@ifundefined{Gin at log}
+  {\let\Gin at log\wlog}
+  {}
+\@ifundefined{Gin at page}
+  {\let\Gin at page\@empty}
+  {}
+\@ifundefined{Gin at pagebox}
+  {\def\Gin at page{cropbox}}
+  {}
+\@ifundefined{Gin at interpolate}
+  {\csname newif\endcsname\ifGin at interpolate}
+  {}
 \def\Gread@@pdftex#1{%
-  % Ensure that option `print' works only on bitmap images.
-  \let\GPT at Attr\ltx at empty
-  \let\GPT at AttrShort\ltx at empty
-  \ifnum\driver at release>7 %
-    \ifx\GPT at ocobjnum\ltx at empty
+  \edef\Gin at attr@hash{%
+    \ifx\Gin at pagebox\@empty
     \else
-      \edef\GPT at AttrShort{\GPT at AttrShort
-        :OC\GPT at ocobjnum
-      }%
-      \edef\GPT at Attr{\GPT at Attr
-        /OC \GPT at ocobjnum\GPT at objref
-      }%
+      :\Gin at pagebox
     \fi
-  \fi
-  \ifGPT at IsBitmap
-    \let\GPT at page\ltx at empty
-    \let\GPT at pagebox\ltx at empty
-    \ifnum\driver at release>7 %
-      \ifx\GPT at xmpfile\ltx at empty
-      \else
-        \ltx at IfUndefined{GPT at XMP@\GPT at xmpfile}{%
-          \GPT at IfFileExists{\GPT at xmpfile}{%
-            \begingroup
-              \pdfcompresslevel=0 %
-              \immediate\pdfobj stream attr{%
-                /Type/Metadata%
-                /Subtype/XML%
-              }file{\GPT at xmpfile}%
-              \expandafter\xdef\csname GPT at XMP@\GPT at xmpfile\endcsname{%
-                \the\pdflastobj
-              }%
-            \endgroup
-          }{%
-            \GPT at warn{Missing XMP file (\GPT at xmpfile)}%
-          }%
-        }{}%
-        \ltx at IfUndefined{GPT at XMP@\GPT at xmpfile}{}{%
-          \edef\GPT at Attr{\GPT at Attr
-            /Metadata \@nameuse{GPT at XMP@\GPT at xmpfile}\GPT at objref
-          }%
-          \edef\GPT at AttrShort{\GPT at AttrShort
-            :MD\@nameuse{GPT at XMP@\GPT at xmpfile}%
-          }%
-        }%
-      \fi
-      \ifx\GPT at interpolate\ltx at empty
-      \else
-        \edef\GPT at Attr{\GPT at Attr
-          /Interpolate true%
-        }%
-        \edef\GPT at AttrShort{\GPT at AttrShort
-          :I%
-        }%
-      \fi
-      \ifx\GPT at decodearray\ltx at empty
-      \else
-        \edef\GPT at Attr{\GPT at Attr
-          /Decode[\GPT at decodearray]%
-        }%
-        \edef\GPT at AttrShort{\GPT at AttrShort
-          :D[\GPT at decodearray]%
-        }%
-      \fi
-      \ifx\GPT at mask\ltx at empty
-      \else
-        \edef\GPT at Attr{\GPT at Attr
-          /Mask\GPT at mask
-        }%
-        \edef\GPT at AttrShort{\GPT at AttrShort
-          :M\GPT at mask
-        }%
-      \fi
-      \ifx\GPT at intent\ltx at empty
-      \else
-        \edef\GPT at AttrShort{\GPT at AttrShort
-          :RI\GPT at intent
-        }%
-        \expandafter\ifx\csname pdfescapename\endcsname\relax
-          \expandafter\ifx\csname pdf at escapename\endcsname\relax
-          \else
-            \edef\GPT at intent{\pdf at escapename{\GPT at intent}}%
-          \fi
-        \else
-          \edef\GPT at intent{\pdfescapename{\GPT at intent}}%
-        \fi
-        \edef\GPT at Attr{\GPT at Attr
-          /Intent/\GPT at intent
-        }%
-      \fi
-    \fi
-  \else
-    \let\GPT at interpolate\ltx at empty
-    \let\GPT at decodearray\ltx at empty
-    \let\GPT at mask\ltx at empty
-    \let\GPT at intent\ltx at empty
-    \ifx\GPT at page\ltx at empty
+    \ifx\Gin at page\@empty
     \else
-      \edef\GPT at AttrShort{\GPT at AttrShort
-        :P\GPT at page
-      }%
+      :P\Gin at page
     \fi
-    \ifx\GPT at pagebox\ltx at empty
-    \else
-      \edef\GPT at AttrShort{%
-        \GPT at AttrShort
-        :\expandafter\ltx at car\GPT at pagebox{}\@nil b%
-      }%
+    \ifGin at interpolate
+      :I%
     \fi
-    \ifx\GPT at print\ltx at empty
-    \else
-      \GPT at warn{%
-        Option `print' can only be used\MessageBreak
-        for bitmap images%
+  }%
+  \@ifundefined{#1 image\Gin at attr@hash}%
+    {%
+      \pdfximage
+        \ifGin at interpolate attr{/Interpolate true}\fi
+        \ifx\Gin at page\@empty\else page \Gin at page\fi
+        \Gin at pagebox
+        {#1}%
+      \setbox\@tempboxa=\hbox{\pdfrefximage\pdflastximage}%
+      \def\Gin at llx{0}\let\Gin at lly\Gin at llx
+      \Gin at defaultbp\Gin at urx{\wd\@tempboxa}%
+      \Gin at defaultbp\Gin at ury{\ht\@tempboxa}%
+      \expandafter\xdef\csname #1 image\Gin at attr@hash\endcsname
+        {\pdfrefximage\the\pdflastximage}%
+      \expandafter\xdef\csname #1 height\Gin at attr@hash\endcsname
+        {\the\ht\@tempboxa}%
+      \expandafter\xdef\csname #1 width\Gin at attr@hash\endcsname
+        {\the\wd\@tempboxa}%
+      \Gin at log{%
+        <#1, %
+        id=\the\pdflastximage, %
+        \ifx\Gin at page\@empty\else page=\Gin at page , \fi
+        \ifx\Gin at pagebox\@empty\else pagebox=\Gin at pagebox , \fi
+        \ifGin at interpolate interpolate=true, \fi
+        \the\wd\@tempboxa\space x \the\ht\@tempboxa
+        >%
       }%
-      \let\GPT at print\ltx at empty
-    \fi
-  \fi
-  % Check if print image exists.
-  \ifx\GPT at print\ltx at empty
-  \else
-    \GPT at IfFileExists{\GPT at print}{%
     }{%
-      \GPT at error{Print image `\GPT at print' not found}{%
-        The print version of the image is ignored.\MessageBreak
-        \@ehc
-      }%
-      \let\GPT at print\ltx at empty
+      \def\Gin at llx{0}\let\Gin at lly\Gin at llx
+      \Gin at defaultbp\Gin at urx{\csname #1 width\Gin at attr@hash\endcsname}%
+      \Gin at defaultbp\Gin at ury{\csname #1 height\Gin at attr@hash\endcsname}%
     }%
-  \fi
-  % If option `print' is set, the screen image object
-  % will contain an additional /Alternate entry
-  % and will not be reused.
-  \ifx\GPT at print\ltx at empty
-  \else
-    \expandafter\expandafter\expandafter\ltx at firstoftwo\expandafter\ltx at gobbletwo
-  \fi
-  \ltx at ifundefined{#1 image\GPT at AttrShort}{%
-    \ifnum\driver at release>4 %
-      \ifnum\driver at release>5 %
-        \ifx\GPT at print\ltx at empty
-          \ifx\GPT at Attr\ltx at empty
-            \let\GPT at RuleAttr\ltx at empty
-          \else
-            \edef\GPT at RuleAttr{attr{\GPT at Attr}}%
-          \fi
-        \else
-          \ltx at ifundefined{\GPT at print\ltx at space image\GPT at AttrShort}{%
-            \immediate\pdfximage{\GPT at print}%
-            \setbox\@tempboxa=\hbox{\pdfrefximage\pdflastximage}%
-            \edef\GPT at PrintObj{\the\pdflastximage}%
-            \expandafter\xdef\csname\GPT at print\ltx at space
-                image\GPT at AttrShort\endcsname{%
-              \pdfrefximage\GPT at PrintObj\relax
-            }%
-            \immediate\pdfobj{%
-              [<<%
-                /Image \GPT at PrintObj\GPT at objref
-                /DefaultForPrinting true%
-              >>]%
-            }%
-            \def\GPT at RuleAttr{%
-              width\wd\@tempboxa height\ht\@tempboxa
-              attr{%
-                \GPT at Attr
-                /Alternates \the\pdflastobj\GPT at objref
-              }%
-            }%
-          }{%
-            \edef\GPT at PrintObj{%
-              \expandafter\expandafter\expandafter\ltx at gobble
-              \csname\GPT at print\ltx at space image\GPT at AttrShort\endcsname
-            }%
-            \immediate\pdfobj{%
-              [<<%
-                /Image \GPT at PrintObj\GPT at objref
-                /DefaultForPrinting true%
-              >>]%
-            }%
-            \def\GPT at RuleAttr{%
-              width \csname\GPT at print\ltx at space width\GPT at AttrShort\endcsname
-              height \csname\GPT at print\ltx at space height\GPT at AttrShort\endcsname
-              attr{%
-                \GPT at Attr
-                /Alternates \the\pdflastobj\GPT at objref
-              }%
-            }%
-          }%
-        \fi
-        \pdfximage\GPT at RuleAttr
-        \ifx\GPT at page\ltx at empty
-        \else
-          page \GPT at page
-        \fi
-        \GPT at pagebox
-        {#1}%
-        \setbox\@tempboxa=\hbox{\pdfrefximage\pdflastximage}%
-      \else
-        \setbox\@tempboxa=\hbox{\pdfimage{#1}}%
-      \fi
-    \else
-      \setbox\@tempboxa=\hbox{%
-        \pdfimage\noexpand\noexpand\noexpand\ltx at empty#1\relax
-      }%
-    \fi
-    \def\Gin at llx{0}\let\Gin at lly\Gin at llx
-    \Gin at defaultbp\Gin at urx{\wd\@tempboxa}%
-    \Gin at defaultbp\Gin at ury{\ht\@tempboxa}%
-    \expandafter\xdef\csname\GPT at ReusedName{#1} width\GPT at AttrShort\endcsname{%
-      \the\wd\@tempboxa
-    }%
-    \expandafter\xdef\csname\GPT at ReusedName{#1} height\GPT at AttrShort\endcsname{%
-      \the\ht\@tempboxa
-    }%
-    \ifnum\driver at release>5 %
-      \expandafter\xdef\csname #1 image\GPT at AttrShort
-        \ifx\GPT at print\ltx at empty\else!\fi\endcsname{%
-        \pdfrefximage\the\pdflastximage
-      }%
-    \else
-      \pdfform\@tempboxa
-      \Gread at gobject=\pdflastform
-      \expandafter\xdef\csname#1 image\endcsname{%
-        \pdfrefform\the\Gread at gobject
-      }%
-    \fi
-    \Gin at log{%
-       <#1, id=%
-       \ifnum\driver at release>5 %
-         \the\pdflastximage
-         \ifx\GPT at page\ltx at empty\else , page=\GPT at page\fi
-         \ifx\GPT at pagebox\ltx at empty\else, pagebox=\GPT at pagebox\fi
-         \ifx\GPT at interpolate\ltx at empty\else, interpolate=true\fi
-         \ifx\GPT at print\ltx at empty
-         \else
-            , print=\GPT at print, id=\GPT at PrintObj
-         \fi
-       \else
-         \the\Gread at gobject
-       \fi
-       , \the\wd\@tempboxa\ltx at space x \the\ht\@tempboxa
-       >%
-     }%
-  }{%
-    \def\Gin at llx{0}\let\Gin at lly\Gin at llx
-    \Gin at defaultbp\Gin at urx{\csname#1 width\GPT at AttrShort\endcsname}%
-    \Gin at defaultbp\Gin at ury{\csname#1 height\GPT at AttrShort\endcsname}%
-  }%
 }
-\def\Ginclude at pdftex#1{%
-  % basic faking of viewport settings so graphic-s- interface
-  % does something sensible
-  \ifx\GPT at AttrShort\@undefined
-    \GPT at info{Interpreting graphics options as viewport}%
-    \let\GPT at AttrShort\@empty
-    \let\Gin at vllx\Gin at llx
-    \let\Gin at vlly\Gin at lly
-    \let\Gin at vurx\Gin at urx
-    \let\Gin at vury\Gin at ury
-  \fi
+\def\Gread at png#1{%
+  \let\Gin at page\@empty
+  \let\Gin at pagebox\@empty
+  \Gread at pdftex{#1}%
+}
+\let\Gread at jpg\Gread at png
+\expandafter\let\csname Gread at jbig2\endcsname\Gread at png
+\def\Gread at pdf#1{%
+  \Gin at interpolatefalse
+  \Gread at pdftex{#1}%
+}
+\let\Gread at mps\Gread at eps
+\def\GPT at setup@scale{%
   \def\@tempa{!}%
   \ifx\Gin at scaley\@tempa
     \let\Gin at scaley\Gin at scalex
@@ -1331,21 +236,31 @@
   \else
     \ifx\Gin at scalex\@tempa\let\Gin at scalex\Gin at scaley\fi
   \fi
+}
+\def\Ginclude at pdftex#1{%
+  \GPT at setup@scale
   \Gin at log{%
     <use #1%
-    \ifx\GPT at page\ltx at empty\else, page \GPT at page\fi
+    \ifx\Gin at page\@empty\else, page \Gin at page\fi
     >%
   }%
-  \GPT at info{%
-    #1\ifx\GPT at page\ltx at empty\else, page\GPT at page\fi
-    \ltx at space used\on at line.\MessageBreak
+  \PackageInfo{pdftex.def}{%
+    #1 \ifx\Gin at page\@empty\else, page\Gin at page\fi
+    \space used\ifx\on at line\@undefined\else\on at line\fi.}%
+  \PackageInfo{pdftex.def}{%
     Requested size: %
-    \the\Gin at req@width\ltx at space x \the\Gin at req@height
+    \the\Gin at req@width\space x \the\Gin at req@height
   }%
+  \Ginclude@@pdftex{\@nameuse{#1 image\Gin at attr@hash}}%
+}
+\def\Ginclude at mps#1{%
+  \GPT at setup@scale
+  \Ginclude@@pdftex{\convertMPtoPDF{#1}{1}{1}}%
+}
+\def\Ginclude@@pdftex#1{%
   \hbox{%
-    \GPT at ResetColorBegin
     \Gscale at box{\Gin at scalex}[\Gin at scaley]{%
-      \ltx at IfUndefined{Gin at vllx}{%
+      \@ifundefined{Gin at vllx}{%
         \GPT at viewportfalse
         % without viewport/trim clipping does not make sense
         % for pdfTeX
@@ -1352,14 +267,10 @@
         \Gin at clipfalse
       }{}%
       \ifGin at clip
-        \ifnum\driver at release<6 %
-          \GPT at warn{No clipping support in pdfTeX < 0.14}%
+        \if!\Gin at vllx\Gin at vlly\Gin at vurx\Gin at vury!%
         \else
-          \if!\Gin at vllx\Gin at vlly\Gin at vurx\Gin at vury!%
-          \else
-            \let\GPT at clipend\GPT at DoClipEnd
-            \setbox\@tempboxa\hbox\bgroup
-          \fi
+          \let\GPT at clipend\GPT at DoClipEnd
+          \setbox\@tempboxa\hbox\bgroup
         \fi
       \fi
       \ifGPT at viewport
@@ -1372,9 +283,7 @@
           \hskip-\Gin at vllx bp\relax
         \fi
       \fi
-      \csname#1 image\GPT at AttrShort
-        \ifx\GPT at print\ltx at empty\else!\fi
-      \endcsname
+      #1%
       \ifGPT at viewport
         \ifdim\Gin at vlly\p@=\z@
         \else
@@ -1383,10 +292,9 @@
         \GPT at clipend
       \fi
     }%
-    \GPT at ResetColorEnd
   }%
 }
-\ltx at newif\ifGPT at viewport
+\newif\ifGPT at viewport
 \GPT at viewporttrue
 \let\GPT at clipend\relax
 \def\GPT at DoClipEnd{%
@@ -1395,238 +303,36 @@
   % \Gin at urx and \Gin at ury already contain the correct values,
   % so both cases viewport and trim can be handled together:
   \dimen@\Gin at urx\p@
-  % v0.03k \Gin at vllx replaced by \Gin at llx
   \advance\dimen@ -\Gin at llx\p@
   \wd\@tempboxa\strip at pt\dimen@ bp\relax
   \dimen@\Gin at ury\p@
-  % v0.03k \Gin at vlly replaced by \Gin at lly
   \advance\dimen@ -\Gin at lly\p@
   \ht\@tempboxa\strip at pt\dimen@ bp\relax
-  \let\GPT at temp\ltx at empty
-  \ifnum\driver at release>7 %
-    \ifx\GPT at ocobjnum\ltx at empty
-    \else
-      \edef\GPT at temp{attr{/OC \GPT at ocobjnum\GPT at objref}}%
-    \fi
-  \fi
-  \expandafter\pdfxform\GPT at temp\@tempboxa
+  \pdfxform\@tempboxa
   \pdfrefxform\pdflastxform
 }
-\ltx at newif\ifGPT at IsBitmap
-\def\Gread at pdfbitmap#1{%
-  \GPT at IsBitmaptrue
-  \Gread at pdftex{#1}%
-  \GPT at IsBitmapfalse
-}
-
-\edef\Gread at MBox{/MediaBox}
-\def\Gread at pdf{%
-  \GPT at read\Gread@@pdf
-}
-\def\Gread@@pdf#1{%
-  \begingroup
-    \@tempcnta\z@
-    \loop
-    \ifnum\@tempcnta<\@xxxii
-      \catcode\@tempcnta14 %
-      \advance\@tempcnta\@ne
-    \repeat
-    \catcode127=14 %
-    \let\do\@makeother\dospecials\catcode`\ 10 %
-    \catcode\endlinechar5 %
-    \immediate\openin\@inputcheck#1 %
-    \ifeof\@inputcheck
-      \@latex at error{File `#1' not found}\@ehc
-    \else
-      \Gread at true
-      \let\@tempb\Gread at false
-      \loop
-% v0.02e: use \. not \@tempa so the space is preserved before [
-        \read\@inputcheck to\.%
-        \ifeof\@inputcheck
-          \Gread at false
-        \else
-          \expandafter\Gread at find@mbox\. []\\%
-        \fi
-      \ifGread@
-      \repeat
-      \immediate\closein\@inputcheck
-    \fi
-    \ifGin at bbox
-    \else
-      \@latex at error
-      {Cannot determine size of graphic in #1 (no BoundingBox)}%
-      \@ehc
-      \gdef\@gtempa{0 0 72 72 }%
-    \fi
-  \endgroup
-  \expandafter\Gread at parse@bb\@gtempa\\%
-}
-\long\def\Gread at find@mbox#1 [#2]#3\\{% hash-ok
-  \def\@tempa{#1}%
-  \ifx\@tempa\Gread at MBox
-    \gdef\@gtempa{#2 }%
-    \@tempb
-    \Gin at bboxtrue
-  \fi
-}
-\def\Ginclude at png#1{%
-  \hbox{%
-% v0.02f add \@depth\z@ (from Sebastian)
-    \pdfimage
-      \@height\Gin at req@height \@width\Gin at req@width \@depth\z@
-      \noexpand\noexpand\noexpand\ltx at empty#1\relax
-  }%
-}
-
-\def\Ginclude at mps#1{%
-  \def\@tempa{!}%
-  \ifx\Gin at scaley\@tempa
-    \let\Gin at scaley\Gin at scalex
-  \else
-    \ifx\Gin at scalex\@tempa\let\Gin at scalex\Gin at scaley\fi
-  \fi
-  \hbox{%
-    \GPT at ResetColorBegin
-    \Gscale at box{\Gin at scalex}[\Gin at scaley]{%
-      \ltx at IfUndefined{Gin at vllx}{%
-        \GPT at viewportfalse
-        % without viewport/trim clipping does not make sense
-        % for pdfTeX
-        \Gin at clipfalse
-      }{}%
-      \ifGin at clip
-        \ifnum\driver at release<6 %
-          \GPT at warn{No clipping support in pdfTeX < 0.14}%
-        \else
-          \if!\Gin at vllx\Gin at vlly\Gin at vurx\Gin at vury!%
-          \else
-            \let\GPT at clipend\GPT at DoClipEnd
-            \setbox\@tempboxa\hbox\bgroup
-          \fi
-        \fi
-      \fi
-      \ifGPT at viewport
-        \ifdim\Gin at vlly\p@=\z@
-        \else
-          \lower\Gin at vlly bp\hbox\bgroup
-        \fi
-        \ifdim\Gin at vllx\p@=\z@
-        \else
-          \hskip-\Gin at vllx bp\relax
-        \fi
-      \fi
-      \GPT at catcodes{mps}%
-      \convertMPtoPDF{#1}{1}{1}%
-      \GPT at restore@mps
-      \ifGPT at viewport
-        \ifdim\Gin at vlly\p@=\z@
-        \else
-          \egroup
-        \fi
-        \GPT at clipend
-      \fi
-    }%
-    \GPT at ResetColorEnd
-  }%
-}
-\def\Gread at mps{%
-  \GPT at read\Gread at eps
-}
-\ifnum\driver at release>3 %
-  \let\Ginclude at png\Ginclude at pdftex
-  \let\Ginclude at jpg\Ginclude at pdftex
-  \let\Ginclude at pdf\Ginclude at pdftex
-  \let\Gread at pdf\Gread at pdftex
-  \let\Gread at png\Gread at pdfbitmap
-  \let\Gread at jpg\Gread at pdfbitmap
-  \ifnum\driver at release>5 %
-    \ifnum\driver at release<8 %
-      \let\Gread at tif\Gread at pdfbitmap
-      \let\Ginclude at tif\Ginclude at pdftex
-    \else
-      \ifnum\driver at release>9 %
-        \expandafter\let\csname Gread at jbig2\endcsname\Gread at pdfbitmap
-        \expandafter\let\csname Ginclude at jbig2\endcsname\Ginclude at pdftex
-      \fi
-    \fi
-  \fi
-\else
-  \def\Ginclude at pdf#1{%
-    \def\@tempa{!}%
-    \ifx\Gin at scaley\@tempa
-      \let\Gin at scaley\Gin at scalex
-    \else
-      \ifx\Gin at scalex\@tempa\let\Gin at scalex\Gin at scaley\fi
-    \fi
-    \hbox{%
-      \GPT at catcodes{pdf}%
-      \convertPDFtoPDF{#1}{\Gin at scalex}{\Gin at scaley} {0bp} {0bp}%
-      {\Gin at req@width}{\Gin at req@height}%
-      \GPT at restore@pdf
-    }%
-  }%
-\fi
-
-% v0.02e: restrict the rules to just the types that pdftex can currently
-% deal with.
-\ifnum\driver at release>3 %
-  \def\Gin at extensions{.png,.pdf,.jpg,.mps,.jpeg,.PNG,.PDF,.JPG,.JPEG}%
-  \@namedef{Gin at rule@.jpg}#1{{jpg}{.jpg}{#1}}%
-  \@namedef{Gin at rule@.jpeg}#1{{jpg}{.jpeg}{#1}}%
-  \@namedef{Gin at rule@.JPG}#1{{jpg}{.JPG}{#1}}%
-  \@namedef{Gin at rule@.JPEG}#1{{jpg}{.JPEG}{#1}}%
-  \ifnum\driver at release>5 %
-    \ifnum\driver at release<8 %
-      \def\Gin at extensions{%
-        .png,.pdf,.jpg,.mps,.tif,.jpeg,%
-        .PNG,.PDF,.JPG,.JPEG%
-      }%
-      \@namedef{Gin at rule@.tif}#1{{tif}{.tif}{#1}}%
-    \else
-      \ifnum\driver at release>9 %
-        \ifnum\pdfminorversion>3 %
-          \def\Gin at extensions{%
-          .png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,%
-          .PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2}%
-        \fi
-        \@namedef{Gin at rule@.jb2}#1{{jbig2}{.jb2}{#1}}%
-        \@namedef{Gin at rule@.jbig2}#1{{jbig2}{.jbig2}{#1}}%
-      \fi
-    \fi
-  \fi
-\else
-  \def\Gin at extensions{.png,.pdf,.mps,.PNG,.PDF}%
-\fi
-\@namedef{Gin at rule@.png}#1{{png}{.png}{#1}}
-\@namedef{Gin at rule@.PNG}#1{{png}{.PNG}{#1}}
-\@namedef{Gin at rule@.mps}#1{{mps}{.mps}{#1}}
-\@namedef{Gin at rule@.pdf}#1{{pdf}{.pdf}{#1}}
-\@namedef{Gin at rule@.PDF}#1{{pdf}{.PDF}{#1}}
-\@namedef{Gin at rule@.eps}#1{{eps}{.eps}{#1}}
-
-% Rotation
-% slightly hacky, but set width of box 0 to 0pt otherwise
-% the CTM gets restored in the wrong place.
-
+\let\Ginclude at png\Ginclude at pdftex
+\let\Ginclude at jpg\Ginclude at pdftex
+\let\Ginclude at pdf\Ginclude at pdftex
+\expandafter\let\csname Ginclude at jbig2\endcsname\Ginclude at pdftex
 \def\GPT at MatrixIdentity{1 0 0 1}
 \def\GPT at Zero{0}
 \def\GPT at Minus{-}
 \def\GPT at NormalizeNumber#1{%
   \edef#1{#1}%
-  \edef#1{\expandafter\ltx at zapspace\expandafter{#1}}%
+  \edef#1{\expandafter\zap at space#1 \@empty}%
   \edef#1{\expandafter\GPT at ZapPlus#1+\@nil}%
   \edef#1{\expandafter\GPT at ZapMinusMinus#1--\@nil}%
   \expandafter\GPT at Split#1..\@nil
-  \ifx\GPT at frac\ltx at empty
+  \ifx\GPT at frac\@empty
   \else
     \edef\GPT at frac{%
       \expandafter\GPT at Reverse\expandafter{\expandafter}\GPT at frac\@nil
     }%
     \edef\GPT at frac{%
-      \expandafter\GPT at ZapLeadingZeros\GPT at frac\ltx at empty
+      \expandafter\GPT at ZapLeadingZeros\GPT at frac\@empty
     }%
-    \ifx\GPT at frac\ltx at empty
+    \ifx\GPT at frac\@empty
     \else
       \edef\GPT at frac{%
         \expandafter\GPT at Reverse\expandafter{\expandafter}\GPT at frac\@nil
@@ -1633,23 +339,23 @@
       }%
     \fi
   \fi
-  \edef\GPT at sign{\expandafter\ltx at car\GPT at int\ltx at empty\@nil}%
+  \edef\GPT at sign{\expandafter\@car\GPT at int\@empty\@nil}%
   \ifx\GPT at sign\GPT at Minus
-    \edef\GPT at int{\expandafter\ltx at cdr\GPT at int\@nil}%
+    \edef\GPT at int{\expandafter\@cdr\GPT at int\@nil}%
   \else
     \def\GPT at sign{}%
   \fi
   \edef\GPT at int{%
-    \expandafter\GPT at ZapLeadingZeros\GPT at int\ltx at empty
+    \expandafter\GPT at ZapLeadingZeros\GPT at int\@empty
   }%
   \edef\GPT at temp{\GPT at int\GPT at frac}%
-  \ifx\GPT at temp\ltx at empty
+  \ifx\GPT at temp\@empty
     \def#1{0}%
   \else
     \edef#1{%
       \GPT at sign
       \GPT at int
-      \ifx\GPT at frac\ltx at empty
+      \ifx\GPT at frac\@empty
       \else
         .\GPT at frac
       \fi
@@ -1658,8 +364,8 @@
 }
 \def\GPT at ZapPlus#1+#2\@nil{%
   #1%
-  \ifx\ltx at empty#2\ltx at empty
-    \expandafter\ltx at gobble
+  \ifx\@empty#2\@empty
+    \expandafter\@gobble
   \else
     \expandafter\@firstofone
   \fi
@@ -1669,8 +375,8 @@
 }
 \def\GPT at ZapMinusMinus#1--#2\@nil{%
   #1%
-  \ifx\ltx at empty#2\ltx at empty
-    \expandafter\ltx at gobble
+  \ifx\@empty#2\@empty
+    \expandafter\@gobble
   \else
     \expandafter\@firstofone
   \fi
@@ -1680,18 +386,18 @@
 }
 \def\GPT at Split#1.#2.#3\@nil{%
   \def\GPT at int{#1}%
-  \ifx\ltx at empty#2\ltx at empty
-    \let\GPT at frac\ltx at empty
+  \ifx\@empty#2\@empty
+    \let\GPT at frac\@empty
   \else
     \def\GPT at frac{#2}%
   \fi
 }
 \def\GPT at Reverse#1#2#3\@nil{%
-  \ifx\ltx at empty#3\ltx at empty
+  \ifx\@empty#3\@empty
     #2#1%
-    \expandafter\ltx at gobble
+    \expandafter\@gobble
   \else
-    \expandafter\ltx at firstofone
+    \expandafter\@firstofone
   \fi
   {%
     \GPT at Reverse{#2#1}#3\@nil
@@ -1704,144 +410,104 @@
     #1%
   \fi
 }
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname pdfsetmatrix\endcsname\relax
-  % Patrick Daly found an error here with doubled minus signs when
-  % \Grot at sin is negative. Fixed.
-  \def\Grot at start{%
-    \GPT at NormalizeNumber\Grot at sin
-    \GPT at NormalizeNumber\Grot at cos
-    \edef\GPT at temp{%
-      \Grot at cos\ltx at space\Grot at sin\ltx at space
-      \if-\GPT at sin
+\def\Grot at start{%
+  \GPT at NormalizeNumber\Grot at sin
+  \GPT at NormalizeNumber\Grot at cos
+  \edef\GPT at temp{%
+    \Grot at cos\space\Grot at sin\space
+    \if-\Grot at sin
+    \else
+      \ifx\Grot at sin\GPT at Zero
+        \GPT at Zero
       \else
-        % avoid negative zero
-        \ifx\Grot at sin\GPT at Zero
-          \GPT at Zero
-        \else
-          -\Grot at sin
-        \fi
+        -\Grot at sin
       \fi
-      \ltx at space\Grot at cos
-    }%
-    \ifx\GPT at temp\GPT at MatrixIdentity
-      \def\Grot at end{}%
-    \else
-      \pdfliteral{ q \GPT at temp\ltx at space 0 0 cm}%
-      \wd\z@\z@
     \fi
+    \space\Grot at cos
+  }%
+  \ifx\GPT at temp\GPT at MatrixIdentity
+    \def\Grot at end{}%
+  \else
+    \pdfsave
+    \pdfsetmatrix{\GPT at temp}%
+    % Slightly hacky, but set width of box 0 to 0pt otherwise
+    % the CTM gets restored in the wrong place
     \wd\z@\z@
+  \fi
+}
+\def\Grot at end{\pdfrestore}
+\def\Gscale at start{%
+  \GPT at NormalizeNumber\Gscale at x
+  \GPT at NormalizeNumber\Gscale at y
+  \edef\GPT at temp{%
+    \Gscale at x\space0 0 \Gscale at y
   }%
-  \def\Grot at end{%
-    \pdfliteral{ Q}%
-  }%
-  % Scaling is OK, as graphics package does it right here.
-  \def\Gscale at start{%
-    \GPT at NormalizeNumber\Gscale at x
-    \GPT at NormalizeNumber\Gscale at y
-    \edef\GPT at temp{%
-      \Gscale at x\ltx at space0 0 \Gscale at y
-    }%
-    \ifx\GPT at temp\GPT at MatrixIdentity
-      \def\Gscale at end{}%
-    \else
-      \pdfliteral{ q \GPT at temp\ltx at space 0 0 cm}%
-    \fi
-  }%
-\else
-  \def\Grot at start{%
-    \GPT at NormalizeNumber\Grot at sin
-    \GPT at NormalizeNumber\Grot at cos
-    \edef\GPT at temp{%
-      \Grot at cos\ltx at space\Grot at sin\ltx at space
-      \if-\Grot at sin
-      \else
-        \ifx\Grot at sin\GPT at Zero
-          \GPT at Zero
-        \else
-          -\Grot at sin
-        \fi
+  \ifx\GPT at temp\GPT at MatrixIdentity
+    \def\Gscale at end{}%
+  \else
+    \pdfsave
+    \pdfsetmatrix{\GPT at temp}%
+  \fi
+}
+\def\Gscale at end{\pdfrestore}
+\@ifundefined{ifGin at setpagesize}
+  {\expandafter\let\csname ifGin at setpagesize\expandafter\endcsname
+                    \csname iftrue\endcsname}
+  {}
+\ifGin at setpagesize
+\ifx\paperwidth\@undefined\else
+  \AtBeginDocument{%
+% If a package has changed \mag, assume it knows what it is doing
+% and leave page size alone
+\ifnum\mag=\@m
+  \@ifundefined{stockwidth}{%
+  \@ifundefined{paperwidth}{%
+  }{%
+    \ifdim\paperwidth>0pt\relax
+      \ifdim\paperheight>0pt\relax
+        \pdfpagewidth=\paperwidth
+        \pdfpageheight=\paperheight
       \fi
-      \ltx at space\Grot at cos
-    }%
-    \ifx\GPT at temp\GPT at MatrixIdentity
-      \def\Grot at end{}%
-    \else
-      \pdfsave
-      \pdfsetmatrix{\GPT at temp}%
-      \wd\z@\z@
     \fi
   }%
-  \def\Grot at end{\pdfrestore}%
-  \def\Gscale at start{%
-    \GPT at NormalizeNumber\Gscale at x
-    \GPT at NormalizeNumber\Gscale at y
-    \edef\GPT at temp{%
-      \Gscale at x\ltx at space0 0 \Gscale at y
-    }%
-    \ifx\GPT at temp\GPT at MatrixIdentity
-      \def\Gscale at end{}%
-    \else
-      \pdfsave
-      \pdfsetmatrix{\GPT at temp}%
+}{%
+  \ifdim\stockwidth>0pt\relax
+    \ifdim\stockheight>0pt\relax
+      \pdfpagewidth=\stockwidth
+      \pdfpageheight=\stockheight
     \fi
-  }%
+  \fi
+}%
 \fi
-\let\Gscale at end\Grot at end
-
-% undo the trig.sty `optimization' so that these 0 1 and -1 values
-% get written out as digits, not unexpandable TeX primitives.
-% 0.04q: space added to remain consistent with trig.sty.
-\def\GPT at PatchTrig{%
-  \def\GPT at temp##1(##2)=##3 {%
-    \expandafter\def\csname ##1(##2)\endcsname{##3 }%
-  }%
-  \GPT at temp sin(0)=0 %
-  \GPT at temp cos(0)=1 %
-  \GPT at temp sin(90)=1 %
-  \GPT at temp cos(90)=0 %
-  \GPT at temp sin(-90)=-1 %
-  \GPT at temp cos(-90)=0 %
-  \GPT at temp sin(180)=0 %
-  \GPT at temp cos(180)=-1 %
-  % added in 0.04q
-  \GPT at temp sin(270)=-1 %
-  \GPT at temp cos(270)=0 %
-  \GPT at temp sin(360)=0 %
-  \GPT at temp cos(360)=1 %
-  \GPT at temp sin(-180)=0 %
-  \GPT at temp cos(-180)=-1 %
-  \GPT at temp sin(-270)=1 %
-  \GPT at temp cos(-270)=0 %
-  \GPT at temp sin(-360)=0 %
-  \GPT at temp cos(-360)=1 %
-  \ltx at ifpackageloaded{trig}{%
-    \let\GPT at PatchTrig\relax
-  }{}%
 }
-\AtBeginDocument{\GPT at PatchTrig}
-\ltx at ifpackageloaded{trig}{\GPT at PatchTrig}{}
-\ltx at IfUndefined{AfterPackage}{}{% scrlfile.sty
-  \AfterPackage{trig}{\GPT at PatchTrig}%
+\fi
+\fi
+\def\Gin at extensions{%
+  .pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,%
+  .PDF,.PNG,.JPG,.JPEG,.JBIG2,.JB2
 }
-\ltx at IfUndefined{AtEndOfPackageFile}{}{% filehook.sty
-  \AtEndOfPackageFile{trig}{\GPT at PatchTrig}%
-}
-\ltx at IfUndefined{AtEndPackage}{}{% memoir.cls
-  \AtEndPackage{trig}{\GPT at PatchTrig}%
-}
-
-% v0.02e: Restore catcodes of context letters.
-% Not needed with current version of supp-pdf
-% but protects against older versions.
-% v0.03o: Catcode protection of '=' because of turkish.ldf.
+\@namedef{Gin at rule@.jpg}#1{{jpg}{.jpg}{#1}}
+\@namedef{Gin at rule@.jpeg}#1{{jpg}{.jpeg}{#1}}
+\@namedef{Gin at rule@.JPG}#1{{jpg}{.JPG}{#1}}
+\@namedef{Gin at rule@.JPEG}#1{{jpg}{.JPEG}{#1}}
+\@namedef{Gin at rule@.jb2}#1{{jbig2}{.jb2}{#1}}%
+\@namedef{Gin at rule@.jbig2}#1{{jbig2}{.jbig2}{#1}}%
+\@namedef{Gin at rule@.png}#1{{png}{.png}{#1}}
+\@namedef{Gin at rule@.PNG}#1{{png}{.PNG}{#1}}
+\@namedef{Gin at rule@.mps}#1{{mps}{.mps}{#1}}
+\@namedef{Gin at rule@.pdf}#1{{pdf}{.pdf}{#1}}
+\@namedef{Gin at rule@.PDF}#1{{pdf}{.PDF}{#1}}
+\@namedef{Gin at rule@.eps}#1{{eps}{.eps}{#1}}
+% MPS conversion
 \def\GPT at LoadSuppPdf{%
-  \ltx at IfUndefined{convertMPtoPDF}{%
-    \GPT at catcodes{supp}%
-    \InputIfFileExists{supp-pdf.mkii}{}{%
-      \InputIfFileExists{supp-pdf}{}{}%
-    }%
-    \GPT at restore@supp
+  \@ifundefined{convertMPtoPDF}{%
+    \edef\@tempa{%
+      \catcode`\noexpand\<\the\catcode`\<\relax
+      \catcode`\noexpand\>\the\catcode`\>\relax
+      }%
+    \@makeother\<\@makeother\<%
+    \InputIfFileExists{supp-pdf.mkii}{}{}%
+    \@tempa
   }{%
     % supp-pdf is probably already loaded.
   }%
@@ -1850,18 +516,18 @@
   % of \InputIfFileExists will not work:
   % * \InputIfFileExists has problems with parameters (#1).
   % * Implementation of \providecommand is insufficient in miniltx.tex
-  \ltx at ifundefined{convertMPtoPDF}{%
-    \newcommand{\convertMPtoPDF}[3]{%
-      \GPT at error{%
-        Cannot convert ##1 from MPS to PDF.\MessageBreak
+  \@ifundefined{convertMPtoPDF}{%
+% 2016/05/21 v0.01c use \newcommand here not \newcommand*  graphics/4472
+\newcommand{\convertMPtoPDF}[3]{%
+      \PackageError{pdftex.def}{%
+        Cannot convert ##1 from MPS to PDF.
         The support file `supp-pdf.mkii' (supp-pdf.tex) is missing%
       }{%
-        The graphics driver for pdfTeX needs `supp-pdf.mkii'\MessageBreak
-        (or `supp-pdf.tex' and/or `supp-mis.tex')\MessageBreak
-        to convert MetaPost output files to PDF.\MessageBreak
+        The graphics driver for pdfTeX needs `supp-pdf.mkii'
+        (or `supp-pdf.tex' and/or `supp-mis.tex')
+        to convert MetaPost output files to PDF.
         These files are part of ConTeXt and can also be found here:%
-        \MessageBreak
-        \ltx at space\ltx at space CTAN:macros/pdftex/graphics/\MessageBreak
+        \space\space CTAN:macros/pdftex/graphics/.
         You'll get more errors if you'll continue now.%
       }%
     }%
@@ -1871,59 +537,6 @@
 \AtBeginDocument{%
   \GPT at LoadSuppPdf
 }
-
-% Adds support for extended MetaPost features (transparency)
-\def\LoadMetaPostSpecialExtensions{%
-  \AtBeginDocument{%
-    \ltx at IfUndefined{assignMPStransparency}{%
-      \GPT at catcodes{mpe}%
-      \let\GPT at found=N%
-      \IfFileExists{supp-pdf.mkii}{\let\GPT at found=Y}{%
-        \IfFileExists{supp-pdf}{\let\GPT at found=Y}{}%
-      }%
-      \ifx Y\GPT at found
-        \InputIfFileExists{supp-mis.mkii}{}{%
-          \InputIfFileExists{supp-mis}{}{\let\GPT at found=N}%
-        }%
-        \ifx Y\GPT at found
-          \InputIfFileExists{supp-mpe.mkii}{}{%
-            \InputIfFileExists{supp-mpe}{}{\let\GPT at found=N}%
-          }%
-          \ifx Y\GPT at found
-            \MPcmykcolorstrue
-            \MPspotcolorstrue
-            \chardef\makeMPintoPDFobject=1 %
-          \else
-            \GPT at warn{%
-              Cannot enable MetaPost Special Extensions,\MessageBreak
-              because `supp-mpe.mkii' (or `supp-mpe.tex')\MessageBreak
-              is missing%
-            }%
-          \fi
-        \else
-          \GPT at warn{%
-            Cannot enable MetaPost Special Extensions,\MessageBreak
-            because `supp-mis.mkii' (or `supp-mis.tex')\MessageBreak
-            is missing%
-          }%
-        \fi
-      \else
-        \GPT at warn{%
-          Cannot enable support for MetaPost images,\MessageBreak
-          because `supp-pdf.mkii' (or `supp-pdf.tex')\MessageBreak
-          is missing%
-        }%
-      \fi
-      \GPT at restore@mpe
-    }{}%
-  }%
-  \let\LoadMetaPostSpecialExtensions\relax
-}
-\ltx at IfUndefined{@onlypreamble}{%
-}{%
-  \@onlypreamble\LoadMetaPostSpecialExtensions
-}
-
 % Load package epstopdf if
 % a) LaTeX is running (plain TeX users are on their own),
 % b) and shell escape (\write18) is enabled (possibly restricted),
@@ -1954,21 +567,17 @@
         \ifx\includegraphics\@undefined\else
         \@ifpackageloaded{pst-pdf}{}{%
           \@ifpackageloaded{pdftricks}{}{%
-            \RequirePackage{pdftexcmds}[2007/11/11]%
-            \expandafter\ifx\csname pdf at shellescape\endcsname\relax
-            \else
-	      \@ifpackageloaded{graphics}{
-              \ifnum\pdf at shellescape>0 %
-	      % only add .eps to file extension list if epstopdf is loaded
-	        \edef\Gin at extensions{\Gin at extensions,.eps}%
+            \@ifpackageloaded{graphics}{%
+              \ifnum\pdfshellescape>0 %
+          % only add .eps to file extension list if epstopdf is loaded
+                \edef\Gin at extensions{\Gin at extensions,.eps}%
                 \RequirePackage{epstopdf-base}[2009/07/12]%
               \fi}{}
-            \fi
           }% pdftricks not loaded
         }% pst-pdf not loaded
-	\fi
+        \fi
       }% AtBeginDocument block
     }% AtEndofPackage block
   \fi % AtEndofPackage not defined
 \fi % DoNotLoadEpstopdf not defined
-\GPT at AtEnd
+\endinput

Modified: trunk/Master/texmf-dist/tex/latex/graphics-def/xetex.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/graphics-def/xetex.def	2017-06-12 21:42:28 UTC (rev 44575)
+++ trunk/Master/texmf-dist/tex/latex/graphics-def/xetex.def	2017-06-12 21:42:50 UTC (rev 44576)
@@ -1,17 +1,14 @@
-%% This is file `xetex.def' for XeTeX,
-%% based upon other drivers for LaTeX color and graphics support.
+%% xetex.def Copyright (C) 2005-2017 LaTeX3 Project, Jin-Hwan Cho, Shunsaku Hirata
+%%                                      (with contributions from many others)
 %%
-%%  Copyright 2004-2007, 2009, 2013-2016
-%%  Ross Moore <ross at maths.mq.edu.au>
-%%  modified by Jonathan Kew et al.
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%%   http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
 %%
-%%  Copyright 2016 LaTeX3 project and above named authors.
-%%
-%% This file is not part of the Standard LaTeX `Graphics Bundle'.
-%% It may be distributed under the terms of the LaTeX Project Public
-%% License, as described in lppl.txt in the base LaTeX distribution.
-%% Either version 1.0 or, at your option, any later version.
-%%
 %% This work has the LPPL maintenance status `maintained'.
 %%
 %% The Current Maintainer of this work is the LaTeX3 Project.
@@ -18,154 +15,8 @@
 %%
 %% https://github.com/latex3/graphics-def/issues
 %%
-%% 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%  Version History
-%%
-%%  2016/07/11  [DPC] [v4.10] \mag test added to all the files
-%%              Remove spurious dependency on external packages.
-%%              Avoid \@ehd help text (not defined by miniltx)
-%%
-%%  2016/07/02  [DPC] [v4.09] support new (no)setpagesize options of
-%%              color and graphics packages.
-%%              revert pagecolor code to match dvips
-%%
-%%  2016/04/06  [AK] [v4.08] Support new suffix .mps (or .MPS) for eps files
-%%              created by MetaPost. In TeX Live 2016, the option --mvorigin
-%%              for [x]dvipdfmx is necessary to include MetaPost-created eps
-%%              files by the usual \Ginclude at eps. This may a bit be inconvenient.
-%%              Thus we introduce a new command \Ginclude at mps for the suffix
-%%              .mps (or .MPS). In \Ginclude at mps, llx, lly, urx, and ury are
-%%              natural compared with those in \Ginclude at eps. Thus the origin
-%%              should not be translated, that is the option --mvorigin should
-%%              not be given.
-%%
-%%  2015/09/11  [AK, NA, TY] [v4.06] Support pagebox=artbox, etc. in xelatex,
-%%              like in pdflatex. It requires new xetex and xdvipdfmx, which
-%%              will be available in TeX Live 2016. Interested users may build
-%%              new binaries by using new sources in the TeX Live repository.
-%%
-%%  2015/03/26  [SH] [v4.04] JPEG 2000 (.jp2, .jpf) support, written for
-%%                           dvipdfmx.
-%%
-%%  2014/04/28  [KB] [v4.03] \newif outside \def.  Skipped 4.02.
-%%
-%%  2014/04/28  [HO] [v4.01] .CAPS extensions.
-%%              [KB]  ordering: find .jpeg just after .jpg,
-%%                      more like dvipdfmx.def.  Also remove .sga/.sgi,
-%%                      which were mismatched and never noticed.
-%%                      Change version number to match dvipdfmx.def.
-%%
-%%  2014/04/07  [AK] [v0.99] remove spurious spaces.
-%%
-%%  2014/03/24  [AK] [v0.98] non-origin viewport, avoid double bp conversion.
-%%
-%%  2014/03/21  [KB] doc tweaks for project home at puszcza.gnu.org.ua.
-%%  
-%%  2013/05/27  [KB] Version v0.97  non-commutative operations.
-%%              (code provided by Bruno Voisin)
-%%
-%%  2013/04/29  [KB] Version v0.96  handle non-origin ll corner.
-%%              (code provided by Bruno Voisin)
-%%
-%%  2013/02/04  [RRM] Version v0.95  added clipping support.
-%%              (code provided by Joseph Wright and Martin Scharrer)
-%%
-%%  2009/11/21  [KB] Version v0.94  merge the two 0.93's.
-%%
-%%  2009/10/28  [RRM] Version v0.93  fix big-point incompatibility;
-%%
-%%  2007/10/25  [JK] Version v0.93  added EPS support from dvipdfmx.def
-%%              (for use with xdvipdfmx, default driver in xetex 0.997)
-%%
-%%  2006/08/10  [JK] Version v0.92  correct type-check in \G at measure@QTm;
-%%              remove \G at PDF@ext, apply \lowercase instead;
-%%              make \XeTeXquote have catcode 12 rather than 11;
-%%              explicit space after "filename.ext" (reqd by xetex 0.995)
-%%
-%%  2006/07/19  [JK] Version v0.91  use \special{color ...} rather than
-%%              \special{x:textcolor ...} etc, for compatibility with
-%%              both xdv2pdf and xdvipdfmx drivers;
-%%              added .bmp to list of recognized graphics extensions
-%%
-%%  2006/01/09  [JK] Version v0.9  removed support for XeTeX versions
-%%              prior to 0.6 (when the \XeTeXpicfile parameters were
-%%              modified), to avoid problem when \XeTeXrevision inc. letters
-%%
-%%  2005/10/12  Version v0.8  removed spurious space in \convertHEX@
-%%               -- found by Morten Hogholm
-%%
-%%  2004/05/09  Version v0.7 changed support for \pagecolor, adapted
-%%              from pdftex.def, to put a \special in the \shipout ;
-%%              this driver should now work with  miniltx.tex ;
-%%              changed some control-sequence names;
-%%              implemented HSB to RGB color conversion
-%%              identified the redundant (v0.5) coding more clearly.
-%%
-%%  2004/05/08  Version v0.6 properly implements scaling and rotations
-%%              following the coding used with  pdftex.def ;
-%%              implemented `viewport' and prepared for `clip';
-%%              don't rely on " to have correct catcode;
-%%              altered the suffix order for graphics, to be:
-%%                .pdf .png .jpg .pict .tif ....
-%%
-%%  2004/04/29  Version v0.5 adapts to the changed names for the
-%%              graphics inclusion primitives, and version strings.
-%%
-%%  2004/04/23  Version v0.41 works with graphics.sty as well as
-%%              graphicx.sty ; \G at pdf@ext is '.pdf';
-%%              similarly define and use \G at PDF@ext for '.PDF';
-%%              removed some log-messages.
-%%
-%%  2004/04/22  Version v0.4 designed to work with XeTeX v0.4
-%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% emacs-page
 \ProvidesFile{xetex.def}
-  [2016/07/11 v4.10 LaTeX color/graphics driver for XeTeX (L3/RRM/JK)]
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-% make sure we can use " with correct catcode
-{\catcode`\"=12
- \gdef\XeTeXquote{"}%
-}
-
-% miniltx.tex does not define \PackageWarning
-\@ifundefined{PackageWarning}{%
-  \def\PackageWarning#1#2{%
-    \begingroup
-      \def\@spaces{\space\space\space\space}%
-      \ifx\on at line\@undefined\def\on at line{}\fi
-      \newlinechar=10 %
-      \def\MessageBreak{%
-        ^^J(#1)\@spaces\@spaces\@spaces\@spaces
-      }%
-      \immediate\write16{^^JPackage #1 Warning: #2\on at line.^^J}%
-    \endgroup
-  }%
-}{}
-
-\def\GPT at warn{\PackageWarning{xetex.def}}%
-
-\@ifundefined{on at line}{%
- \def\on at line{ on input line \the\inputlineno}%
-}{}
-\@ifundefined{@spaces}{%
- \def\@spaces{\space\space\space\space}%
-}{}
-\def\GXT at warn{\PackageWarning{xetex.def}}%
-\ifx\Gin at log\@undefined
-  \def\Gin at log{\message}
-\fi
-
-% Colour Support. The following models may be used.
-%   * rgb  \
-%   * cmyk  \
-%   * gray  /-- all passed directly to the driver
-%   * hsb  /
-%   * RGB  ---- converted to rgb here
-%   * named
-%
+  [2017/06/01 v5.0a Graphics/color driver for xetex]
 \def\c at lor@arg#1{%
   \dimen@#1\p@
   \ifdim\dimen@<\z@\dimen@\maxdimen\fi
@@ -174,7 +25,7 @@
   \fi}
 \def\color at gray#1#2{%
   \c at lor@arg{#2}%
-  \edef#1{gray #2}%
+  \edef#1{[#2]}%
   }
 \def\color at cmyk#1#2{\c at lor@@cmyk#2\@@#1}
 \def\c at lor@@cmyk#1,#2,#3,#4\@@#5{%
@@ -182,7 +33,7 @@
   \c at lor@arg{#1}%
   \c at lor@arg{#2}%
   \c at lor@arg{#3}%
-  \edef#5{cmyk #1 #2 #3 #4}%
+  \edef#5{[#1 #2 #3 #4]}%
   }
 \def\color at rgb#1#2{\c at lor@@rgb#2\@@#1}
 \def\c at lor@@rgb#1,#2,#3\@@#4{%
@@ -189,7 +40,7 @@
   \c at lor@arg{#1}%
   \c at lor@arg{#2}%
   \c at lor@arg{#3}%
-  \edef#4{rgb #1 #2 #3}%
+  \edef#4{[#1 #2 #3]}%
   }
 \def\color at RGB#1#2{\c at lor@@RGB#2\@@#1}
 \def\c at lor@@RGB#1,#2,#3\@@#4{%
@@ -202,13 +53,6 @@
   \dimen@#1\p@
   \divide\dimen@\@cclv
   \edef#2{\strip at pt\dimen@}}
-\def\color at hsb#1#2{\c at lor@@hsb#2\@@#1}
-\def\c at lor@@hsb#1,#2,#3\@@#4{%
-  \c at lor@arg{#1}%
-  \c at lor@arg{#2}%
-  \c at lor@arg{#3}%
-  \edef#4{hsb #1 #2 #3}%
-  }
 \def\color at named#1#2{\c at lor@@named#2,,\@@#1}
 \def\c at lor@@named#1,#2,#3\@@#4{%
   \@ifundefined{col@#1}%
@@ -215,391 +59,182 @@
     {\PackageError{color}{Undefined color `#1'}{}}%
   {\edef#4{ #1}}%
   }
-
-\def\current at color{gray 0}
-
-%
-% v0.02t: support for \pagecolor
-% not used by default but may be re-activated 
-% with \oldxetexpagecolorcode
-% see http://tug.org/pipermail/xetex/2016-June/026696.html
-%
-\def\oldxetexpagecolorcode{%
-\def\set at page@color{%
-  \global\let\current at page@color\current at color
-  \@ifundefined{GXTorg at shipout}{%
-    \global\let\GXTorg at shipout\shipout
-    \gdef\shipout{%
-      \afterassignment\GXT at shipout
-      \global\setbox\@cclv=%
-    }%
-    \gdef\GXT at shipout{%
-      \ifvoid\@cclv\relax
-        \aftergroup\GXT@@shipout
-        \GXT at setpagecolor
-      \else
-        \GXTorg at shipout\vbox{%
-          \GXT at setpagecolor
-          \box\@cclv
-        }%
-      \fi
-    }%
-    \gdef\GXT@@shipout{%
-      \GXTorg at shipout\box\@cclv\relax
-    }%
-    \gdef\GXT at setpagecolor{%
-      \special{background \current at page@color}%
-    }%
-  }{}%
-}%
+\def\c at lor@to at ps#1 #2\@@{\csname c at lor@ps@#1\endcsname#2 \@@}
+\def\c at lor@ps@#1 #2\@@{TeXDict begin #1 end}
+\def\c at lor@ps at rgb#1\@@{#1 setrgbcolor}
+\def\c at lor@ps at hsb#1\@@{#1 sethsbcolor}
+\def\c at lor@ps at cmyk#1\@@{#1 setcmykcolor}
+\def\c at lor@ps at gray#1\@@{#1 setgray}
+\def\current at color{[0]}
+\def\set at color{%
+            \special{pdf:bcolor \current at color
+                          }\aftergroup\reset at color}
+\def\reset at color{\special{%
+         pdf:ecolor}}
+\def\set at page@color{\special{%
+         pdf:bgcolor \current at color}}
+\def\define at color@named#1#2{%
+  \expandafter\let\csname col@#1\endcsname\@nnil}
+\@ifundefined{Gin at page}
+  {\let\Gin at page\@empty}
+  {}
+\@ifundefined{Gin at pagebox}
+  {\def\Gin at pagebox{cropbox}}
+  {}
+\@ifundefined{Gin at interpolate}
+  {\csname newif\endcsname\ifGin at interpolate}
+  {}
+\def\Gread at pdf#1{%
+  \Gin at interpolatefalse
+  \Gread@@xetex\XeTeXpdffile
 }
-\def\set at page@color{\special{background \current at color}}
-
-\def\set at color@stack{%
-  \special{color push \current at color}%
-  \aftergroup\reset at color
+\def\Gread at bmp#1{%
+  \let\Gin at page\@empty
+  \let\Gin at pagebox\@empty
+  \Gread@@xetex\XeTeXpicfile
 }
-\def\set at color@nostack{%
-  \special{color \current at color}%
-  \aftergroup\reset at color
+\def\Gread@@xetex#1{%
+  \IfFileExists{\Gin at base.bb}%
+    {\Gread at eps{\Gin at base.bb}}%
+    {\Gread@@xetex at aux#1}%
 }
-\def\reset at color@nostack{%
-  \special{color \current at color}%
-  \expandafter\checkfor at moreresets
+\def\Gread@@xetex at aux#1{%
+  \edef\Gin at attr@hash{%
+    \ifx\Gin at pagebox\@empty
+    \else
+      :\Gin at pagebox
+    \fi
+    \ifx\Gin at page\@empty
+    \else
+      :P\Gin at page
+    \fi
+  }%
+  \edef\Gin@@name{\Gin at base\Gin at ext}%
+  \@ifundefined{\Gin@@name\space height\Gin at attr@hash}%
+    {%
+      \setbox\@tempboxa=\hbox{%
+        #1"\Gin@@name"\space
+        \ifx\Gin at page\@empty\else page \Gin at page\fi
+        \ifx\Gin at pagebox\@empty\else\expandafter\Gread@@xetex at box\Gin at pagebox\fi
+      }%
+      \def\Gin at llx{0}\let\Gin at lly\Gin at llx
+      \Gin at defaultbp\Gin at urx{\wd\@tempboxa}%
+      \Gin at defaultbp\Gin at ury{\ht\@tempboxa}%
+      \expandafter\xdef\csname \Gin@@name\space height\Gin at attr@hash\endcsname
+        {\the\ht\@tempboxa}%
+      \expandafter\xdef\csname \Gin@@name\space width\Gin at attr@hash\endcsname
+        {\the\wd\@tempboxa}%
+    }{%
+      \def\Gin at llx{0}\let\Gin at lly\Gin at llx
+      \Gin at defaultbp\Gin at urx
+        {\csname \Gin@@name\space width\Gin at attr@hash\endcsname}%
+      \Gin at defaultbp\Gin at ury
+        {\csname \Gin@@name\space height\Gin at attr@hash\endcsname}%
+    }%
 }
-\def\reset at color@stack{%
-  \special{color pop}%
-  \expandafter\checkfor at moreresets
-}
-\def\checkfor at moreresets{\futurelet\tmp\checkfor at moreresets@}
-\def\checkfor at moreresets@{%
-  \ifx\tmp\reset at color\expandafter\gobble at color\fi}
-\def\gobble at color#1{\checkfor at moreresets}
-
-\def\define at color@named#1#2{%
-  \expandafter\edef\csname col@#1\endcsname{#2}}
-%
-\def\check at for@XeTeX at colorstack{%
-  \expandafter\ifx\csname use at XeTeX@colorstack\endcsname\relax
-   \let\set at color\set at color@stack
-   \let\reset at color\reset at color@stack
-   \let\checkfor at moreresets\relax
+\def\Gread@@xetex at box#1box{#1}
+\def\GPT at setup@scale{%
+  \def\@tempa{!}%
+  \ifx\Gin at scaley\@tempa
+    \let\Gin at scaley\Gin at scalex
   \else
-   \let\set at color\set at color@nostack
-   \let\reset at color\reset at color@nostack
+    \ifx\Gin at scalex\@tempa\let\Gin at scalex\Gin at scaley\fi
   \fi
 }
-% 
-% use \noXeTeXcolorstack to turn off the color-stack
-% mechanism; use it within the preamble only.
-% This may be useful with some packages
-% e.g. TeXpower which makes partial page-builds.
-%
-\def\noXeTeXcolorstack{\def\use at XeTeX@colorstack{}}
-\AtBeginDocument{\check at for@XeTeX at colorstack}
-%
-% < end of color support for XeTeX >
-
-% < graphics inclusion for XeTeX >
-%
-% PDF is a special case which has extra features
-\def\G at pdf@ext{.pdf}
-%
-% import from pdftex.def to support pagebox=artbox etc. in XeLaTeX
-%
-% \Gin at XeTeX@page: page number of pdf image or \@empty otherwise.
-% This code adapted from  pdftex.def
-\let\Gin at XeTeX@page\@empty
-\let\GPT at pagebox\@empty
-\begingroup
-  \toks@{\define at key{Gin}{page}{\def\Gin at XeTeX@page{#1}}
-\define at key{Gin}{pagebox}{%
-  \expandafter\let\expandafter\GPT at pagebox%
-      \csname GPT at pagebox@#1\endcsname
-  \ifx\GPT at pagebox\relax
-    \let\GPT at pagebox\@empty
-    \GPT at warn{%
-      Unknown value `#1' for `pagebox'.\MessageBreak
-      Supported values:\MessageBreak
-      mediabox, cropbox, bleedbox, trimbox, artbox%
-    }%
-  \fi%
-}%
-}%
-  \@ifundefined{define at key}{%
-   \edef\x{\endgroup\noexpand\AtBeginDocument{%
-     \noexpand\@ifundefined{define at key}{}{\the\toks@}}%
-    }\x
-  }{\expandafter\endgroup\the\toks@}
-
-\def\GPT at pagebox@cropbox{crop}%
-\def\GPT at pagebox@mediabox{media}%
-\def\GPT at pagebox@artbox{art}%
-\def\GPT at pagebox@trimbox{trim}%
-\def\GPT at pagebox@bleedbox{bleed}%
-%
-% rotating graphics is supported, but 
-% rotation of arbitrary material is not supported yet
-%
-\def\GXT at erotate#1#2{\Grot at setangle{#1}\hbox{#2}}%
-\def\set at GXT@erotate{\let\Gin at erotate\GXT at erotate}
-%\AtBeginDocument{\set at GXT@erotate}
-
-\expandafter\ifx\csname XeTeXpicfile\endcsname\relax
- \let\picfile at cmd\picfile
- \let\pdffile at cmd\pdffile
-\else 
- \let\picfile at cmd\XeTeXpicfile
- \let\pdffile at cmd\XeTeXpdffile
-\fi 
-
-% all graphics are handled by Apple's QuickTime
-%
-\def\XeTeX at include@QTm#1{%
-  \def\picpage{}%
-  \def\picpagebox{}%
-  \edef\type at ext{%
-    \noexpand\lowercase{%
-      \noexpand\def\noexpand\type at ext{\Gin at ext}%
-    }%
-  }\type at ext
-  \ifx\type at ext\G at pdf@ext
-   \ifx\GPT at pagebox\@empty\else
-     \edef\picpagebox{ \GPT at pagebox}\fi
-   \ifx\Gin at XeTeX@page\@empty\else
-     \edef\picpage{ page\Gin at XeTeX@page}\fi
-   \def\picfilecommand{\pdffile at cmd}%
-  \else
-   \def\picfilecommand{\picfile at cmd}%
-  \fi
-  \edef\picfileargs{ \XeTeXquote#1\XeTeXquote\space\picpage\picpagebox}%
+\def\Ginclude at pdf#1{%
+  \GPT at setup@scale
   \Gin at log{%
-    <use \picfileargs>%
+    <use #1%
+    \ifx\Gin at page\@empty\else, page \Gin at page\fi
+    >%
   }%
-  \ifx\Gscale at start\relax
-    \setbox\z@=\hbox{\expandafter\picfilecommand\picfileargs}%
-    \edef\next{\box\z@\egroup
-      \def\noexpand\width{\the\wd\z@}\relax
-      \def\noexpand\height{\the\ht\z@}\bgroup}%
-    \expandafter\next
-  \else
-    \XeTeX at scaleinclude{#1}%
-  \fi
-}
-\def\XeTeX at scaleinclude#1{%
-  \def\@tempa{!}%
-  \ifx\Gin at scaley\@tempa
-   \let\Gin at scaley\Gin at scalex
-  \else
-   \ifx\Gin at scalex\@tempa\let\Gin at scalex\Gin at scaley\fi
-  \fi
   \hbox{%
     \Gscale at box{\Gin at scalex}[\Gin at scaley]{%
       \@ifundefined{Gin at vllx}{%
-        \GXT at viewportfalse
+        \GPT at viewportfalse
         % without viewport/trim clipping does not make sense
-        % for XeTeX
+        % for pdfTeX
         \Gin at clipfalse
       }{}%
-    \ifGin at clip
-      \if!\Gin at vllx\Gin at vlly\Gin at vurx\Gin at vury!%
-      \else
-        \let\GXT at clipend\GXT at DoClipEnd
-        \setbox\@tempboxa\hbox\bgroup
+      \ifGin at clip
+        \if!\Gin at vllx\Gin at vlly\Gin at vurx\Gin at vury!%
+        \else
+          \let\GPT at clipend\GPT at DoClipEnd
+          \setbox\@tempboxa\hbox\bgroup
+        \fi
       \fi
-    \fi
-    \ifGXT at viewport
-      \ifdim\Gin at vlly\p@=\z@
-      \else
-        \lower\Gin at vlly bp\hbox\bgroup
+      \ifGPT at viewport
+        \ifdim\Gin at vlly\p@=\z@
+        \else
+          \lower\Gin at vlly bp\hbox\bgroup
+        \fi
+        \ifdim\Gin at vllx\p@=\z@
+        \else
+          \hskip-\Gin at vllx bp\relax
+        \fi
       \fi
-      \ifdim\Gin at vllx\p@=\z@
-      \else
-        \hskip-\Gin at vllx bp\relax
+      \XeTeXpdffile"#1" %
+        \ifx\Gin at page\@empty\else page \Gin at page\fi
+        \ifx\Gin at pagebox\@empty\else\expandafter\Gread@@xetex at box\Gin at pagebox\fi
+      \ifGPT at viewport
+        \ifdim\Gin at vlly\p@=\z@
+        \else
+          \egroup
+        \fi
+        \GPT at clipend
       \fi
-    \fi
-%
-    \expandafter\picfilecommand\picfileargs
-%
-    \ifGXT at viewport
-      \ifdim\Gin at vlly\p@=\z@
-      \else
-        \egroup
-      \fi
-      \GXT at clipend
-    \fi
     }%
   }%
 }
-\newif\ifGXT at viewport
-\GXT at viewporttrue
-\let\GXT at clipend\relax
-\def\GXT at DoClipEnd{%
+\newif\ifGPT at viewport
+\GPT at viewporttrue
+\let\GPT at clipend\relax
+\def\GPT at DoClipEnd{%
   \egroup
   \dp\@tempboxa\z@
   % \Gin at urx and \Gin at ury already contain the correct values,
   % so both cases viewport and trim can be handled together:
   \dimen@\Gin at urx\p@
-  \advance\dimen@ -\Gin at vllx\p@
+  \advance\dimen@ -\Gin at llx\p@
   \wd\@tempboxa\strip at pt\dimen@ bp\relax
-%  \wd\@tempboxa\dimen@ \relax
   \dimen@\Gin at ury\p@
-  \advance\dimen@ -\Gin at vlly\p@
+  \advance\dimen@ -\Gin at lly\p@
   \ht\@tempboxa\strip at pt\dimen@ bp\relax
-%  \ht\@tempboxa\dimen@ \relax
-  % Clip box to its official size
-  \GXT at clipbox\@tempboxa
+  \GPT at clipbox\@tempboxa
   \box\@tempboxa
 }
-% Clipping support added by Martin Scharrer and Joseph Wright, Nov 2011 
-% under the LPPL v1.0 or later. 
-\def\GXT at clipbox#1{% 
-  \setbox#1=\hbox{% 
-    \Gin at defaultbp\WIDTH{\wd#1}% 
-    \Gin at defaultbp\DEPTH{\dp#1}% 
-    \@tempdima\ht#1% 
-    \advance\@tempdima\dp#1% 
-    \Gin at defaultbp\TOTALHEIGHT{\@tempdima}% 
-    \special{pdf:content q }% 
-      \special{% 
-        pdf:literal direct 
-            0 -\DEPTH\space \WIDTH\space \TOTALHEIGHT\space re 
-      }% 
-      \special{pdf:literal direct W }% 
-      \special{pdf:literal direct n }% 
-        \special{pdf:literal direct -1 0 0 -1 0 0 cm }% 
-          \special{pdf:content q }% 
-            \special{pdf:literal direct -1 0 0 -1 0 0 cm }% 
-              \box#1% 
-          \special{pdf:literal direct Q }% 
-    \special{pdf:literal direct Q }% 
-  }% 
-} 
-% End of clipping code 
-  
-% 
-\def\Gread at QTm#1{\IfFileExists{\Gin at base.bb}%
-   {\Gread at eps{\Gin at base.bb}}%
-   {\G at measure@QTm{\Gin at base}{\Gin at ext}}%
+\def\GPT at clipbox#1{%
+  \setbox#1=\hbox{%
+    \Gin at defaultbp\WIDTH{\wd#1}%
+    \Gin at defaultbp\DEPTH{\dp#1}%
+    \@tempdima\ht#1%
+    \advance\@tempdima\dp#1%
+    \Gin at defaultbp\TOTALHEIGHT{\@tempdima}%
+    \special{x:gsave}%
+    \special{%
+      pdf:literal
+      0 -\DEPTH\space \WIDTH\space \TOTALHEIGHT\space re  W n
+    }%
+    \rlap{\box#1}%
+    \special{x:grestore}%
+    \hskip\wd#1%
+  }%
 }
-\def\G at measure@QTm#1#2{%
- % \@warning{measuring size of QuickTime graphic #1#2}%
+\def\Ginclude at bmp#1{%
+  \Gin at log{<#1>}%
   \bgroup
-   \edef\type at ext{%
-     \noexpand\lowercase{%
-       \noexpand\def\noexpand\type at ext{#2}%
-     }%
-   }\type at ext
-   \ifx\type at ext\G at pdf@ext
-    \ifx\Gin at XeTeX@page\@empty \def\picpage{}%
-    \else \edef\picpage{ page\Gin at XeTeX@page}\fi
-    \ifx\GPT at pagebox\@empty \def\picpagebox{}%
-    \else \edef\picpagebox{ \GPT at pagebox}\fi
-   \fi
-   \setbox0=\hbox{%
-     \ifx\type at ext\G at pdf@ext
-      \edef\piccommand{\noexpand\pdffile at cmd
-         \XeTeXquote#1#2\XeTeXquote\space\picpage\picpagebox}%
-     \else
-      \edef\piccommand{\noexpand\picfile at cmd 
-         \XeTeXquote#1#2\XeTeXquote\space}%
-     \fi
-     \piccommand
-    }\dimen0=\wd0 \dimen2=\ht0
-   \edef\next{\egroup
-     \edef\noexpand\Gin at urx{\the\dimen0}%
-     \edef\noexpand\Gin at ury{\the\dimen2}%
-     }%
-  \next
-  \Gin at defaultbp\Gin at llx{0}%
-  \Gin at defaultbp\Gin at lly{0}%
-  \expandafter\Gin at defaultbp\expandafter\Gin at urx\expandafter{\Gin at urx}%
-  \expandafter\Gin at defaultbp\expandafter\Gin at ury\expandafter{\Gin at ury}%
-%  \typeout{XeTeX: HiRes BoundingBox = (0,0)\space x (\Gin at urx,\Gin at ury) }%
-  \Gin at nat@width=\Gin at urx\p@
-  \Gin at nat@height=\Gin at ury\p@
-  % these emulate  \@begin at tempboxa 
-  \edef\width{\the\Gin at nat@width}%
-  \edef\height{\the\Gin at nat@height}%
-  \def\depth{0pt}%
-  \let\totalheight\@ovri
-  \totalheight\height
-}
-
-\let\Ginclude at QTm\XeTeX at include@QTm
-
-% For a new graphics type, you can include a line here ...
-\@namedef{Gin at rule@.pdf}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.PDF}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.eps}#1{{eps}{.eps}{#1}}
-\@namedef{Gin at rule@.EPS}#1{{eps}{.EPS}{#1}}
-%
-\@namedef{Gin at rule@.mps}#1{{mps}{.mps}{#1}}
-\@namedef{Gin at rule@.MPS}#1{{mps}{.MPS}{#1}}
-%
-\@namedef{Gin at rule@.ps}#1{{eps}{.ps}{#1}}
-\@namedef{Gin at rule@.PS}#1{{eps}{.PS}{#1}}
-%
-\@namedef{Gin at rule@.png}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.PNG}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.jpg}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.JPG}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.jpeg}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.JPEG}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.jp2}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.JP2}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.jpf}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.JPF}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.bmp}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.BMP}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.pict}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.PICT}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.psd}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.PSD}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.mac}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.MAC}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.tga}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.TGA}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.gif}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.GIF}#1{{QTm}{QTm}{#1}}
-%
-\@namedef{Gin at rule@.tif}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.TIF}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.tiff}#1{{QTm}{QTm}{#1}}
-\@namedef{Gin at rule@.TIFF}#1{{QTm}{QTm}{#1}}
-
-% movies not supported yet:
-%\@namedef{Gin at rule@.qt}#1{{QTm}{QTm}{#1}}
-%\@namedef{Gin at rule@.mpg}#1{{QTm}{QTm}{#1}}
-%\@namedef{Gin at rule@.mov}#1{{QTm}{QTm}{#1}}
-%\@namedef{Gin at rule@.moov}#1{{QTm}{QTm}{#1}}
-
-
-% ... though this default rule will try QuickTime anyway ...
-\@namedef{Gin at rule@*}#1{{QTm}{QTm}{#1}}
-
-% ... and add its extension here
-\def\Gin at extensions{% order here is like dvipdfmx.def, except for PS
-  .pdf,.PDF,.eps,.EPS,.mps,.MPS,.ps,.PS,%
-  .png,.PNG,.jpg,.JPG,.jpeg,.JPEG,.jp2,.JP2,.jpf,.JPF,.bmp,.BMP,%
-  .pict,.PICT,.psd,.PSD,.mac,.MAC,.TGA,.tga,%
-  .gif,.GIF,.tif,.TIF,.tiff,.TIFF,%
-}
-
-% xdvipdfmx is now the default driver, and can support EPS images,
-% so we borrow code for this from dvipdfmx.def (and add the extensions above)
+  \def\@tempa{!}%
+    \special{pdf:image\space
+      bbox\space\Gin at llx\space\Gin at lly\space\Gin at urx\space\Gin at ury\space
+      clip\space\ifGin at clip 1\else 0\fi\space
+      \ifx\Gin at scalex\@tempa\else width\space\the\Gin at req@width\space\fi
+      \ifx\Gin at scaley\@tempa\else height\space\the\Gin at req@height\space\fi
+      (#1)\space
+      \ifGin at interpolate<</Interpolate\space true>>\fi}%
+  \egroup}
 \newif\if at trim@vport
 \def\Ginclude at eps#1{%
- \message{<#1>}%
+  \Gin at log{<#1>}%
   \bgroup
   \ifx\Undefined\Gin at vllx\else\@trim at vporttrue\fi
   \def\@tempa{!}%
@@ -639,14 +274,14 @@
 % the origin accordingly if we use \Ginclude at eps for eps files created by
 % MetaPost. In TeX Live 2015, the translation of the origin was the default.
 % After TeX Live 2016, however, the translation of the origin is enabled only
-% if the --mvorigin option is given for dvipdfmx or xdvipdfmx.
-% This may be a bit inconvenient, especially in the case of XeTeX where
+% if the --mvorigin option is given for xdvipdfmx
+% This may be a bit inconvenient, especially as
 % xdvipdfmx is usually called as a pipe. Therefore we introduce a new suffix
 % .mps(or .MPS) to support inclusion of eps files created by MetaPost without
 % the option --mvorigin.
 %
 \def\Ginclude at mps#1{%
- \message{<#1>}%
+  \Gin at log{<#1>}%
   \bgroup
   \def\@tempa{!}%
   \dimen@\Gin at req@width
@@ -664,23 +299,92 @@
       \ifGin at clip clip\fi}%
   \egroup}
 %
-% Rotation & Scaling
-%  supported from xetex v0.6 onwards
-%
+\def\Grot at start{%
+\special{pdf:btrans rotate \Grot at angle}}
+\def\Grot at end{\special{pdf:etrans}}
 
-\def\Grot at start{\wd\z@\z@ 
-  \special{x:gsave}\special{x:rotate \Grot at angle}}
-\def\Grot at end{\special{x:grestore}}
-
+% 4.13 add support for ptex vertical writing mode
+% inspired by pxtatescale package (Hironobu Yamashita)
+\ifx\kanjiskip\@undefined
 \def\Gscale at start{%
-  \special{x:gsave}%
-  \special{pdf:literal \Gscale at x\space 0 0 \Gscale at y\space 0 0 cm}}
-\let\Gscale at end\Grot at end
+  \special{pdf:btrans}%
+  \special{x:scale \Gscale at x\space\Gscale at y}%
+}
+\else
+\edef\Gscale at start{%
+  \special{pdf:btrans}%
+  \special{x:scale
+  \expandafter\noexpand\csname iftdir\endcsname
+    \noexpand\Gscale at y\noexpand\space\noexpand\Gscale at x
+  \expandafter\noexpand\csname else\endcsname
+    \noexpand\Gscale at x\noexpand\space\noexpand\Gscale at y
+  \expandafter\noexpand\csname fi\endcsname}}
+\fi
 %
-
+\def\Gscale at end{\special{pdf:etrans}}
+\def\Gin at PS@raw#1{\special{ps: #1}}
+\def\Gin at PS@restored#1{\special{" #1}}
+\def\Gin at PS@literal at header#1{\AtBeginDvi{\special{! #1}}}
+\def\Gin at PS@file at header#1{\AtBeginDvi{\special{header=#1}}}
+\def\Gin at extensions{% order here is like pdftex.def, except for PS
+  .pdf,.PDF,.ai,.AI,%
+  .png,.PNG,.jpg,.JPG,.jpeg,.JPEG,.jp2,.JP2,.jpf,.JPF,.bmp,.BMP,%
+  .ps,.PS,.eps,.EPS,.mps,.MPS,%
+  .pz,.eps.Z,.ps.Z,.ps.gz,.eps.gz}
 %
-% (no)setpagesize option
+\@namedef{Gin at rule@.pdf}#1{{pdf}{.xbb}{#1}}
+\@namedef{Gin at rule@.PDF}#1{{pdf}{.xbb}{#1}}
 %
+\@namedef{Gin at rule@.ai}#1{{pdf}{.xbb}{#1}}
+\@namedef{Gin at rule@.AI}#1{{pdf}{.xbb}{#1}}
+%
+\@namedef{Gin at rule@.jp2}#1{{bmp}{.xbb}{#1}}
+\@namedef{Gin at rule@.JP2}#1{{bmp}{.xbb}{#1}}
+%
+\@namedef{Gin at rule@.jpf}#1{{bmp}{.xbb}{#1}}
+\@namedef{Gin at rule@.JPF}#1{{bmp}{.xbb}{#1}}
+%
+\@namedef{Gin at rule@.png}#1{{bmp}{.xbb}{#1}}
+\@namedef{Gin at rule@.PNG}#1{{bmp}{.xbb}{#1}}
+%
+\@namedef{Gin at rule@.jpg}#1{{bmp}{.xbb}{#1}}
+\@namedef{Gin at rule@.JPG}#1{{bmp}{.xbb}{#1}}
+%
+\@namedef{Gin at rule@.jpeg}#1{{bmp}{.xbb}{#1}}
+\@namedef{Gin at rule@.JPEG}#1{{bmp}{.xbb}{#1}}
+%
+\@namedef{Gin at rule@.jp2}#1{{bmp}{.xbb}{#1}}
+\@namedef{Gin at rule@.JP2}#1{{bmp}{.xbb}{#1}}
+%
+\@namedef{Gin at rule@.jpf}#1{{bmp}{.xbb}{#1}}
+\@namedef{Gin at rule@.JPF}#1{{bmp}{.xbb}{#1}}
+%
+\@namedef{Gin at rule@.bmp}#1{{bmp}{.xbb}{#1}}
+\@namedef{Gin at rule@.BMP}#1{{bmp}{.xbb}{#1}}
+%
+\@namedef{Gin at rule@.ps}#1{{eps}{.ps}{#1}}
+\@namedef{Gin at rule@.PS}#1{{eps}{.ps}{#1}}
+%
+\@namedef{Gin at rule@.eps}#1{{eps}{.eps}{#1}}
+\@namedef{Gin at rule@.EPS}#1{{eps}{.eps}{#1}}
+%
+\@namedef{Gin at rule@.mps}#1{{mps}{.mps}{#1}}
+\@namedef{Gin at rule@.MPS}#1{{mps}{.mps}{#1}}
+% (don't bother with uppercase versions for these Unixish extensions)
+\@namedef{Gin at rule@.pz}#1{{eps}{.xbb}{`gunzip -c #1}}
+\@namedef{Gin at rule@.eps.Z}#1{{eps}{.eps.xbb}{`gunzip -c #1}}
+\@namedef{Gin at rule@.ps.Z}#1{{eps}{.ps.xbb}{`gunzip -c #1}}
+\@namedef{Gin at rule@.ps.gz}#1{{eps}{.ps.xbb}{`gunzip -c #1}}
+\@namedef{Gin at rule@.eps.gz}#1{{eps}{.eps.xbb}{`gunzip -c #1}}
+%
+\@namedef{Gin at rule@*}#1{{eps}{\Gin at ext}{#1}}
+
+
+% v4.10
+% Support new (no)setpagesize option of graphics and color.
+% v4.11
+% Use \special{pdf:pagesize ...} instead of \special{papersize=...}
+% to support \mag (xetex only)
 \@ifundefined{ifGin at setpagesize}
 {\expandafter\let\csname ifGin at setpagesize\expandafter\endcsname
 \csname iftrue\endcsname}
@@ -691,29 +395,19 @@
 % If a package has changed \mag, assume it knows what it is doing
 % and leave page size alone
 \ifnum\mag=\@m
-\@ifundefined{stockwidth}{%
-\@ifundefined{paperwidth}{%
-}{%
-\ifdim\paperwidth>0pt\relax
-\ifdim\paperheight>0pt\relax
-\pdfpagewidth=\paperwidth
-\pdfpageheight=\paperheight
+\AtBeginDvi{%
+\begingroup
+\ifx\stockwidth\@undefined\else
+\paperwidth\stockwidth
+\paperheight\stockheight
 \fi
+\ifdim\paperwidth>\z@
+\ifdim\paperheight>\z@
+\special{pdf:pagesize width \the\paperwidth\space height \the\paperheight}%
 \fi
-}%
-}{%
-\ifdim\stockwidth>0pt\relax
-\ifdim\stockheight>0pt\relax
-\pdfpagewidth=\stockwidth
-\pdfpageheight=\stockheight
 \fi
+\endgroup}%
 \fi
-}%
-\fi
 }
 \fi
-\fi 
-
-\endinput
-%%
-%% End of file `xetex.def'.
+\fi



More information about the tex-live-commits mailing list