%D \module
%D   [       file=m-metapo,
%D        version=1999.03.26,
%D          title=\LATEX\ Modules, 
%D       subtitle=\METAPOST\ Inclusion,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ distribution and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for 
%C details. 

%D We quit when \CONTEXT\ is found and use some deep down 
%D macro to trigger this:

\ifx\undefined\dodoplaceexternalfigure \else \expandafter \endinput \fi 

%D \macros 
%D   {includeMPgraphics}
%D
%D This rather small \LATEX\ module is dedicated to David
%D Arnold. It takes care of including the fonts used in
%D \METAPOST\ graphics in the file. This hack is needed when
%D one uses another \DVI\ driver than \DVIPS. This module
%D falls back on the generic \CONTEXT\ support module: 

\ifx\undefined\includeMPfonts \input supp-mps.tex \relax \fi 

%D Instead of using \type {\includegraphics}, one should use its
%D little brother \type {\includeMPgraphics}. This macro takes 
%D the same arguments. 

\def\includeMPgraphics#1#%
  {\leavevmode\vbox\bgroup\hbox\bgroup
     \def\includeMPgraphics##1%
       {\includeMPfonts{##1}%
        \includegraphics#1{##1}% 
        \egroup\egroup}%
     \includeMPgraphics}

%D An example of using this module is given below: 
%D 
%D \starttypen
%D \documentclass[10pt]{article}
%D 
%D \usepackage{graphicx}
%D \usepackage{m-metapo}
%D 
%D \begin{document}
%D   \includeMPgraphics{somefile.1}
%D   \includeMPgraphics[angle=90]{somefile.2}
%D \end{document}
%D \stoptypen
%D
%D This module needs \type {supp-mps} and \type {supp-mis}, 
%D that both are present in the \CONTEXT\ path.
%D
%D Please do not forget to say \type {prologues:=2} at the 
%D top of the metapost file!
%D 
%D For non \LATEX\ (and \CONTEXT) users we provide an 
%D alternative inclusion macro. This one has no optional 
%D arguments. 

\ifx\includegraphics\undefined

  \ifx\undefined\dogetEPSboundingbox \input supp-eps.tex \relax \fi 

  \def\includeMPgraphics#1%
    {\hbox\bgroup
     \includeMPfonts{#1}%
     \dogetEPSboundingbox{#1}{\dimen2}{\dimen4}{\dimen6}{\dimen8}%
     \vbox to \dimen8
       {\forgetall
        \hsize\dimen6
        \vfill
        \hbox to \hsize
          {\special
             {PSfile="#1"\space
              llx=\EPSllx\space
              lly=\EPSlly\space
              urx=\EPSurx\space
              ury=\EPSury\space}}}%
     \egroup}

\fi

\endinput 
