Current File : //usr/share/texlive/texmf-dist/tex/latex/graphics-def/dvipdfmx.def
%% dvipdfmx.def
%% Copyright (C) 2005-2020 LaTeX3 Project, Jin-Hwan Cho, Shunsaku Hirata
%%                         (with contributions from many others)
%%
%% 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'.
%%
%% The Current Maintainer of this work is the LaTeX3 Project.
%%
%% https://github.com/latex3/graphics-def/issues
%%
\ProvidesFile{dvipdfmx.def}
  [2020/08/26 v5.0h Graphics/color driver for dvipdfmx]
\def\GPT@space{ }
\def\c@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}
\def\color@gray#1#2{%
  \c@lor@arg{#2}%
  \edef#1{gray #2}%
  }
\def\color@cmyk#1#2{\c@lor@@cmyk#2\@@#1}
\def\c@lor@@cmyk#1,#2,#3,#4\@@#5{%
  \c@lor@arg{#4}%
  \c@lor@arg{#1}%
  \c@lor@arg{#2}%
  \c@lor@arg{#3}%
  \edef#5{cmyk #1 #2 #3 #4}%
  }
\def\color@rgb#1#2{\c@lor@@rgb#2\@@#1}
\def\c@lor@@rgb#1,#2,#3\@@#4{%
  \c@lor@arg{#1}%
  \c@lor@arg{#2}%
  \c@lor@arg{#3}%
  \edef#4{rgb #1 #2 #3}%
  }
\def\color@RGB#1#2{\c@lor@@RGB#2\@@#1}
\def\c@lor@@RGB#1,#2,#3\@@#4{%
 \c@lor@RGB@rgb{#1}\@tempa
 \c@lor@RGB@rgb{#2}\@tempb
 \c@lor@RGB@rgb{#3}\@tempc
 \c@lor@@rgb\@tempa,\@tempb,\@tempc\@@#4%
  }
\def\c@lor@RGB@rgb#1#2{%
  \dimen@#1\p@
  \divide\dimen@\@cclv
  \edef#2{\strip@pt\dimen@}}
\def\color@hsb#1#2{\c@lor@@hsb#2\@@#1}
\def\c@lor@@hsb#1,#2,#3\@@#4{%
  \c@lor@arg{#1}%
  \c@lor@arg{#2}%
  \c@lor@arg{#3}%
  \edef#4{hsb #1 #2 #3}%
  }
\def\color@named#1#2{\c@lor@@named#2,,\@@#1}
\def\c@lor@@named#1,#2,#3\@@#4{%
  \@ifundefined{col@#1}%
    {\PackageError{color}{Undefined color `#1'}\@ehd}%
  {\edef#4{ #1}}%
  }
\def\c@lor@to@ps#1 #2\@@{\csname c@lor@ps@#1\endcsname#2 \@@}
\def\c@lor@ps@#1 #2\@@{TeXDict begin #1 end}
\def\c@lor@ps@rgb#1\@@{#1 setrgbcolor}
\def\c@lor@ps@hsb#1\@@{#1 sethsbcolor}
\def\c@lor@ps@cmyk#1\@@{#1 setcmykcolor}
\def\c@lor@ps@gray#1\@@{#1 setgray}
\def\current@color{ Black}
\def\set@color{%
 \special{color push  \current@color
                          }\aftergroup\reset@color}
\def\reset@color{\special{%
        color pop}}
\def\set@page@color{\special{%
        background \current@color}}
\def\define@color@named#1#2{%
  \expandafter\let\csname col@#1\endcsname\@nnil}
% white is special cased as "no background color" by dvipdfmx
\def\no@page@color{\special{background gray 1}}
\@ifundefined{Gin@decode}
  {\let\Gin@decode\@empty}
  {}
\@ifundefined{Gin@page}
  {\let\Gin@page\@empty}
  {}
\@ifundefined{Gin@pagebox}
  {\def\Gin@pagebox{cropbox}}
  {}
\@ifundefined{Gin@interpolate}
  {\csname newif\endcsname\ifGin@interpolate}
  {}
\def\Gread@pdf#1{%
  \Gread@generic{#1}\Gread@extractbb@aux
}
\def\Gread@extractbb@aux#1{%
  \ifeof\@inputcheck
    \immediate\openin\@inputcheck=%
      "|extractbb %
      \ifx\Gin@page\@empty\else -p \Gin@page\GPT@space\fi
      \ifx\Gin@pagebox\@empty\else -B \Gin@pagebox\GPT@space\fi
      -O \Gin@base\Gin@ext"%
  \fi
  \Gread@true
  \let\@tempb\Gread@false
  \ifeof\@inputcheck
    \@latex@error
      {Cannot run pipe command. Try --shell-escape^^J%
       (--enable-pipes in MikTeX) option}%
      {}%
  \else
    \loop
      \read\@inputcheck to\@tempa
      \ifeof\@inputcheck
        \Gread@false
      \else
        \expandafter\Gread@find@bb\@tempa:.\\%
      \fi
      \ifGread@
      \repeat
    \immediate\closein\@inputcheck
  \fi
}
\let\Gread@bmp\Gread@pdf
\def\Ginclude@pdf#1{%
  \let\Gin@decode\@empty
  \Gin@interpolatefalse
  \Ginclude@dvipdfmx{#1}{epdf}%
}
\def\Ginclude@bmp#1{%
  \let\Gin@page\@empty
  \let\Gin@pagebox\@empty
  \Ginclude@dvipdfmx{#1}{image}%
}
\def\Ginclude@dvipdfmx#1#2{%
  \Gin@log{<#1>}%
  \bgroup
  \def\@tempa{!}%
    \special{pdf:#2\GPT@space
      \ifx\Gin@page\@empty\else page\GPT@space\Gin@page\GPT@space\fi
      \ifx\Gin@pagebox\@empty\else pagebox\GPT@space\Gin@pagebox\GPT@space\fi
      bbox\GPT@space\Gin@llx\GPT@space\Gin@lly\GPT@space\Gin@urx\GPT@space\Gin@ury\GPT@space
      clip\GPT@space\ifGin@clip 1\else 0\fi\GPT@space
      \ifx\Gin@scalex\@tempa\else width\GPT@space\the\Gin@req@width\GPT@space\fi
      \ifx\Gin@scaley\@tempa\else height\GPT@space\the\Gin@req@height\GPT@space\fi
      (#1)\GPT@space
      \ifnum0%
        \ifx\Gin@decode\@empty\else 1\fi
        \ifGin@interpolate 1\fi
        >0 %
        <<%
          \ifx\Gin@decode\@empty\else /Decode[\Gin@decode]\fi
          \ifGin@interpolate /Interpolate true\fi
        >>%
      \fi
    }%
  \egroup}
\newif\if@trim@vport
\def\Ginclude@eps#1{%
  \Gin@log{<#1>}%
  \bgroup
  \ifx\Undefined\Gin@vllx\else\@trim@vporttrue\fi
  \def\@tempa{!}%
  \dimen@\Gin@urx\p@
  \advance\dimen@ -\Gin@llx\p@
  \if@trim@vport
  \advance\dimen@ \Gin@vllx\p@
  \fi
  \edef\Gin@urx{\strip@pt\dimen@}%
  \dimen@\Gin@ury\p@
  \advance\dimen@ -\Gin@lly\p@
  \if@trim@vport
  \advance\dimen@ \Gin@vlly\p@
  \fi
  \edef\Gin@ury{\strip@pt\dimen@}%
  \dimen@\Gin@req@width
  \dimen@ii.1bp%
  \divide\dimen@\dimen@ii
  \@tempdima\Gin@req@height
  \divide\@tempdima\dimen@ii
    \special{PSfile="#1"\GPT@space
      \if@trim@vport
      llx=\Gin@vllx\GPT@space
      lly=\Gin@vlly\GPT@space
      \fi
      urx=\Gin@urx\GPT@space
      ury=\Gin@ury\GPT@space
      \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\GPT@space\fi
      \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\GPT@space\fi
      \ifGin@clip clip\fi}%
  \egroup}
%
% In the above \Ginclude@eps, llx, lly, urx, and ury are translated to match
% the -dEPSCrop option for Ghostscript to convert eps to pdf.
% In the case of eps files created by MetaPost, the files are included
% directly without the help of Ghostscript. That is, we have to translate
% the origin accordingly if we use \Ginclude@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
% 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@mps#1{%
  \Gin@log{<#1>}%
  \bgroup
  \def\@tempa{!}%
  \dimen@\Gin@req@width
  \dimen@ii.1bp%
  \divide\dimen@\dimen@ii
  \@tempdima\Gin@req@height
  \divide\@tempdima\dimen@ii
    \special{PSfile="#1"\GPT@space
      llx=\Gin@llx\GPT@space
      lly=\Gin@lly\GPT@space
      urx=\Gin@urx\GPT@space
      ury=\Gin@ury\GPT@space
      \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\GPT@space\fi
      \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\GPT@space\fi
      \ifGin@clip clip\fi}%
  \egroup}
%
\def\Grot@start{%
\special{pdf:btrans rotate \Grot@angle}}
\def\Grot@end{\special{pdf:etrans}}

% 4.13 add support for ptex vertical writing mode
% inspired by pxtatescale package (Hironobu Yamashita)
\ifx\kanjiskip\@undefined
\def\Gscale@start{%
  \special{pdf:btrans}%
  \special{x:scale \Gscale@x\GPT@space\Gscale@y}%
}
\else
\edef\Gscale@start{%
  \special{pdf:btrans}%
  \special{x:scale
  \expandafter\noexpand\csname iftdir\endcsname
    \noexpand\Gscale@y\noexpand\GPT@space\noexpand\Gscale@x
  \expandafter\noexpand\csname else\endcsname
    \noexpand\Gscale@x\noexpand\GPT@space\noexpand\Gscale@y
  \expandafter\noexpand\csname fi\endcsname}}
\fi
%
\def\Gscale@end{\special{pdf:etrans}}
\def\Gin@PS@raw#1{\special{ps: #1}}
\def\Gin@PS@restored#1{\special{" #1}}
\def\Gin@PS@literal@header#1{\AtBeginDvi{\special{! #1}}}
\def\Gin@PS@file@header#1{\AtBeginDvi{\special{header=#1}}}
\def\Gin@extensions{% order here is like xetex.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}
%
\@namedef{Gin@rule@.pdf}#1{{pdf}{.xbb}{#1}}
\@namedef{Gin@rule@.PDF}#1{{pdf}{.xbb}{#1}}
%
\@namedef{Gin@rule@.ai}#1{{pdf}{.xbb}{#1}}
\@namedef{Gin@rule@.AI}#1{{pdf}{.xbb}{#1}}
%
\@namedef{Gin@rule@.jp2}#1{{bmp}{.xbb}{#1}}
\@namedef{Gin@rule@.JP2}#1{{bmp}{.xbb}{#1}}
%
\@namedef{Gin@rule@.jpf}#1{{bmp}{.xbb}{#1}}
\@namedef{Gin@rule@.JPF}#1{{bmp}{.xbb}{#1}}
%
\@namedef{Gin@rule@.png}#1{{bmp}{.xbb}{#1}}
\@namedef{Gin@rule@.PNG}#1{{bmp}{.xbb}{#1}}
%
\@namedef{Gin@rule@.jpg}#1{{bmp}{.xbb}{#1}}
\@namedef{Gin@rule@.JPG}#1{{bmp}{.xbb}{#1}}
%
\@namedef{Gin@rule@.jpeg}#1{{bmp}{.xbb}{#1}}
\@namedef{Gin@rule@.JPEG}#1{{bmp}{.xbb}{#1}}
%
\@namedef{Gin@rule@.jp2}#1{{bmp}{.xbb}{#1}}
\@namedef{Gin@rule@.JP2}#1{{bmp}{.xbb}{#1}}
%
\@namedef{Gin@rule@.jpf}#1{{bmp}{.xbb}{#1}}
\@namedef{Gin@rule@.JPF}#1{{bmp}{.xbb}{#1}}
%
\@namedef{Gin@rule@.bmp}#1{{bmp}{.xbb}{#1}}
\@namedef{Gin@rule@.BMP}#1{{bmp}{.xbb}{#1}}
%
\@namedef{Gin@rule@.ps}#1{{eps}{.ps}{#1}}
\@namedef{Gin@rule@.PS}#1{{eps}{.ps}{#1}}
%
\@namedef{Gin@rule@.eps}#1{{eps}{.eps}{#1}}
\@namedef{Gin@rule@.EPS}#1{{eps}{.eps}{#1}}
%
\@namedef{Gin@rule@.mps}#1{{mps}{.mps}{#1}}
\@namedef{Gin@rule@.MPS}#1{{mps}{.mps}{#1}}
% (don't bother with uppercase versions for these Unixish extensions)
\@namedef{Gin@rule@.pz}#1{{eps}{.xbb}{`gunzip -c #1}}
\@namedef{Gin@rule@.eps.Z}#1{{eps}{.eps.xbb}{`gunzip -c #1}}
\@namedef{Gin@rule@.ps.Z}#1{{eps}{.ps.xbb}{`gunzip -c #1}}
\@namedef{Gin@rule@.ps.gz}#1{{eps}{.ps.xbb}{`gunzip -c #1}}
\@namedef{Gin@rule@.eps.gz}#1{{eps}{.eps.xbb}{`gunzip -c #1}}
%
\@namedef{Gin@rule@*}#1{{eps}{\Gin@ext}{#1}}
\@ifundefined{ifGin@setpagesize}
{\expandafter\let\csname ifGin@setpagesize\expandafter\endcsname
\csname iftrue\endcsname}
{}
\ifGin@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
\AtBeginDvi{%
\begingroup
  \@ifundefined{stockwidth}{}
    {%
      \paperwidth\stockwidth
      \paperheight\stockheight
    }%
\ifdim\paperwidth>\z@
\ifdim\paperheight>\z@
\special{pdf:pagesize width \the\paperwidth\GPT@space height \the\paperheight}%
\fi
\fi
\endgroup}%
\fi
}
\fi
\fi