% Adobe Mathpi support removed because
%   the fonts are not worth the money.

\unprotect
\let\cafam\mcfam
\newfam\mdfam     % fam E is upright greek
\let\gbfam\mdfam
\let\gkfam\mdfam
\edef\hexmdfam{\hexnumber\mdfam}
\let\hexcafam\hexmcfam
\let\hexgbfam\hexmdfam
\let\hexgkfam\hexmdfam

\font\tenmd=mtgu at 10pt
\font\sevenmd=mtgu at 7.6pt
\font\fivemd=mtgu at 6pt
\font\tenmc=mtms at 10pt
\font\sevenmc=mtms at 7.6pt
\font\fivemc=mtms at 6pt

\textfont\mdfam\tenmd
\scriptfont\mdfam\sevenmd
\scriptscriptfont\mdfam\fivemd
\textfont\mcfam\tenmc
\scriptfont\mcfam\sevenmc
\scriptscriptfont\mcfam\fivemc

\addtocommalist{ca}\familylist
\addtocommalist{gk}\familylist
\addtocommalist{gb}\familylist

\defineinterfaceconstant {ca} {ca} % boohoo!
\defineinterfaceconstant {gk} {gk} % boohoo!
\defineinterfaceconstant {gb} {gb} % boohoo!
%\def\setmathfamilies{%
%        \setmathfamily\mcfam\textface\scriptface\scriptscriptface
%          {\c!mm\c!ca}{\c!mm\c!ca}%
%        \setskewchar{\textface\c!mm\c!ca}{'55}%
%        \setmathfamily\mdfam\textface\scriptface\scriptscriptface
%          {\c!mm\c!gk}{\c!mm\c!gk}%
%        %\dosetmathfamilies{'55}{'60}%
%        \setskewchar{\textface\c!mm\c!gk}{'55}}

\definealternativestyle[script][\ca][\ca]
\definealternativestyle[greek][\gk][\gk]
\definealternativestyle[boldgreek][\gb][\gb]

\definebodyfont[5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt][rm]
    [ca=mtms sa 1,
     gk=mtgu sa 1,
     gb=mtgub sa 1]
     
%\startcoding[texnansi]
%
% Presumes existence of tio and tibio. \tfa etc and \sc are left as
% they are. 
%
\def\localcorpsdef#1#2{\definebodyfont[#1][mm]
       [mr=ptmr7t at #2,
        mi=mtmi at #2,
        skewcharmi='177,
        ex=mtex at #2,
        sy=mtsyn at #2,
        skewcharsy='60,
        gk=mtgu at #2,
        gb=mtgu at #2,
        ca=mtms at #2,
        skewcharca='55,
        skewchargb='55,
        skewchargk='55,
        it=ptmri7t at #2, 
        sl=ptmro7t at #2,
        bf=ptmb7t at #2, 
        tf=ptmr7t at #2, 
        bs=ptmbo7t at #2, 
        bi=ptmbi7t at #2]}


% CM uses:  5,   6,   7,   8,   9,   10,   11,   12,   14,   18
% MT uses:  6.0, 6.8, 7.6, 8.4, 9.2, 10.0, 10.8, 11.6, 13.2, --

\localcorpsdef{5pt}{6pt}
\localcorpsdef{6pt}{6.8pt}
\localcorpsdef{7pt}{7.6pt}
\localcorpsdef{8pt}{8.4pt}
\localcorpsdef{9pt}{9.2pt}
\localcorpsdef{10pt}{10pt}
\localcorpsdef{11pt}{10.8pt}
\localcorpsdef{12pt}{11.6pt}
\localcorpsdef{14.4pt}{13.2pt}

\let\localcorpsdef\undefined

%The next lines set up  coding dependant versions of 
%math accents (for texnansi of course). These are needed
%in commands like \bf and \it (which use the text font
%encoding) a opposed to _no spec_ and mi that use the math font 
%encoding. This stuff should be made more general!
 
% \daghex and \ddaghex were wrong in my version of mtmacs
\def\daghex{86}
\def\ddaghex{87}
\def\Shex{A7}
\def\Phex{B6}
\def\barhex{16}
\def\gravehex{12}
\def\acutehex{13}
\def\checkhex{14}
\def\brevehex{15}
\def\hathex{5E}
% \dothex was wrong in my version of mtmacs
\def\dothex{05}
\def\tildehex{7E}
\def\ddothex{7F}

%\stopcoding


% MTMI  has skewchar 45 ('55)
% MTSYN has skewchar 48 ('60)


%% this patch inserted in font-ini.tex
%
%\def\setmathfamilies{\dosetmathfamilies{'177}{'60}}
%\def\dosetmathfamilies#1#2%
%  {\setskewchar{\textface\c!mm\c!mi}{#1}%
%   \setskewchar{\textface\c!mm\c!sy}{#2}%
%   \setmathfamily\mrfam\textface\scriptface\scriptscriptface
%     {\c!mm\c!mr}{\c!rm\c!tf}%
%   \setmathfamily\mifam\textface\scriptface\scriptscriptface
%     {\c!mm\c!mi}{}%
%   \setmathfamily\syfam\textface\scriptface\scriptscriptface
%     {\c!mm\c!sy}{}%
%   \setmathfamily\exfam\textface\textface\textface
%     {\c!mm\c!ex}{}%
%   \setmathfamily\mafam\textface\scriptface\scriptscriptface
%     {\c!mm\c!ma}{}%
%   \setmathfamily\mbfam\textface\scriptface\scriptscriptface
%     {\c!mm\c!mb}{}%
%   \setmathfamily\mcfam\textface\scriptface\scriptscriptface
%     {\c!mm\c!mc}{}}
%%

% MTEX  needs recalc of \p@renwd (done automatically)


% MTMACS.TEX  VERSION 1.1.1	(1996 Dec 8)
% COPYRIGHT (C) 1992, 1993, 1996 BY THE TEXPLORATORS CORPORATION
% ALL RIGHTS RESERVED

% Revision notice: Official final release 1993/Aug/18
% Revision notice: Minor correction in \Calligraphic 1996/Dec/8

% removed all sanity checks that deal with amstex and protection.
\mathchardef\Gamma="0130
\mathchardef\Delta="0131
\mathchardef\Theta="0132
\mathchardef\Lambda="0133
\mathchardef\Xi="0134
\mathchardef\Pi="0135
\mathchardef\Sigma="0136
\mathchardef\Upsilon="0137
\mathchardef\Phi="0138
\mathchardef\Psi="0139
\mathchardef\Omega="017F
\mathchardef\varGamma="0100
\mathchardef\varDelta="0101
\mathchardef\varTheta="0102
\mathchardef\varLambda="0103
\mathchardef\varXi="0104
\mathchardef\varPi="0105
\mathchardef\varSigma="0106
\mathchardef\varUpsilon="0107
\mathchardef\varPhi="0108
\mathchardef\varPsi="0109
\mathchardef\varOmega="010A
\mathchardef\varkappa="017E
\mathcode`\(="412E
\mathcode`\)="512F
\delcode`\(="12E300
\delcode`\)="12F301
\mathcode`\.="013A
\mathcode`\,="613B
\mathchardef\ldotp="613A
\let\mit=\undefined
\mathchardef\triangleleft="2247
\mathchardef\triangleright="2246
\def\vec{\mathaccent"0245 }
\def\t#1{{\edef\next{\the\font}\the\textfont2\accent"41\next#1}}
\mathchardef\comp="2242
\mathcode`\+="2243
\mathcode`\=="3244
\mathchardef\Relbar="3248
\mathcode`\;="6249
\mathchardef\dagger="20\daghex
\mathchardef\ddagger="20\ddaghex
\mathchardef\dotacc"0250


% fam equals -1 unless the user has said something
% like \rm (cf. the texbook page 290)

\def\ifdefaultfamelse#1#2%
       {\ifnum\fam=\m@ne 
          \mathaccent #1 
        \else
          \mathaccent #2
        \fi}
\let\noaccents@\relax

\def\grave{\ifdefaultfamelse{"024A}{"70\gravehex}}
\def\acute{\ifdefaultfamelse{"024B}{"70\acutehex}}
\def\check{\ifdefaultfamelse{"024C}{"70\checkhex}}
\def\breve{\ifdefaultfamelse{"024D}{"70\brevehex}}
\def\bar{\ifdefaultfamelse{"024E}{"70\barhex}}
\def\hat{\ifdefaultfamelse{"024F}{"70\hathex}}
\def\dot{\ifdefaultfamelse{"0250}{"70\dothex}}
\def\tilde{\ifdefaultfamelse{"0251}{"70\tildehex}}
\def\ddot{\ifdefaultfamelse{"0252}{"70\ddothex}}
\def\widebar{\mathaccent"0253 }

\def\mathhexbox@#1#2#3%
        {\relax
        \ifmmode
         \mathpalette{}{\m@th\mathchar"#1#2#3}%
        \else
         \leavevmode
         \hbox{$\m@th\mathchar"#1#2#3$}%
        \fi}

\def\dag{\edef\next@{0\daghex}\expandafter\mathhexbox@\next@}
\def\ddag{\edef\next@{0\ddaghex}\expandafter\mathhexbox@\next@}
\def\S{\edef\next@{0\Shex}\expandafter\mathhexbox@\next@}
\def\P{\edef\next@{0\Phex}\expandafter\mathhexbox@\next@}

\def\vdots{\vbox{\baselineskip4\p@\lineskiplimit\z@
 \kern6\p@\hbox{$\m@th.$}\hbox{$\m@th.$}\hbox{$\m@th.$}}}

\def\ddots{\mathinner{\mkern1mu\raise7\p@\vbox{\kern7\p@
 \hbox{$\m@th.$}}\mkern2mu
 \raise4\p@\hbox{$\m@th.$}\mkern2mu\raise\p@\hbox{$\m@th.$}\mkern1mu}}

\def\hbar{{\mathchoice
 {\hbox{\lower.07em\hbox{$\mathchar"\barhex$}}}
 {\hbox{\lower.07em\hbox{$\mathchar"\barhex$}}}
 {\hbox{\lower.049em\hbox{$\scriptstyle\mathchar"\barhex$}}}
 {\hbox{\lower.035em\hbox{$\scriptscriptstyle\mathchar"\barhex$}}}%
  \mkern-6.3muh}}

\def\angle{{\vbox{\ialign{$\m@th\scriptstyle##$\crcr
      \not\mathrel{\mkern14mu}\crcr
      \noalign{\nointerlineskip}
      \mkern2.5mu\leaders\hrule height.48\p@\hfill\mkern2.5mu\crcr}}}}

\newdimen\amstexex
\amstexex = .2326ex
\def\varinjlim{\mathop{\vtop{\ialign{##\crcr
  \hfil\the\textfont\z@ lim\hfil\crcr
  \noalign{\nointerlineskip}\rightarrowfill\crcr
  \noalign{\nointerlineskip\kern-\amstexex}\crcr}}}}
\def\varprojlim{\mathop{\vtop{\ialign{##\crcr
  \hfil\the\textfont\z@ lim\hfil\crcr
  \noalign{\nointerlineskip}\leftarrowfill\crcr
  \noalign{\nointerlineskip\kern-\amstexex}\crcr}}}}
% next two definitions context-ified
\def\varliminf{\mathop{\underbar{lim}}}
\def\varlimsup{\mathop{\overstrike{lim}}}
\def\spdot{^{\hbox{\raise\amstexex\hbox{\the\textfont\z@.}}}}
\def\spddot{^{\hbox{\raise\amstexex\hbox{\the\textfont\z@..}}}}
\def\spdddot{^{\hbox{\raise\amstexex\hbox{\the\textfont\z@...}}}}
\def\spddddot{^{\hbox{\raise\amstexex\hbox{\the\textfont\z@....}}}}

% merged double code to save strings
\def\domultidot#1#2{%
        \setbox0\hbox{$#1#2$}%
        \setbox2\hbox{$#1\infty$}%
        \dimen0\ht2
        \ifdim\ht0<\dimen0
                \dimen0\ht0
        \fi
        \setbox2\hbox{$#1#2\mathchar"012D$}%
        \dimen2\wd2
        \advance\dimen2-\wd0 
        \setbox0\hbox{$#1\rhook$}%
        \advance\dimen2-\wd0
        \vbox{\offinterlineskip\ialign{\hfil$#1##$\hfil\cr
                \kern\dimen2\dotacc\mkern-2.5mu\dotacc
                \mkern-2.5mu\dotacc\thirddot\cr
                \noalign{\vskip-\dimen0}#2\cr}}}

\def\dddot{\def\thirddot{}\mathpalette\domultidot}
\def\ddddot{\def\thirddot{\mkern-2.5mu\dotacc }
            \mathpalette\domultidot}

\newcount\uproot@
\newcount\leftroot@
\def\nonmatherr#1{\errmessage{\noexpand#1allowed only in math mode}}
\def\uproot#1{\relax\ifmmode\uproot@#1\relax\else\nonmatherr\uproot\fi}
\def\leftroot#1{\relax\ifmmode\leftroot@#1\relax\else\nonmatherr\leftroot\fi}
\def\root#1\of#2{\setbox\rootbox\hbox{$\m@th\scriptscriptstyle{#1}$}%
 \mathpalette\r@@t{#2}}
\def\r@@t#1#2{\setbox\z@\hbox{$\uproot@\z@\leftroot\z@\m@th#1\sqrt{#2}$}%
 \dimen@\ht\z@\advance\dimen@-\dp\z@
 \dimen@ii\dimen@
  \ifdim\dimen@>30\p@\advance\dimen@ii-\sixt@@n\p@\else
  \ifdim\dimen@>24\p@\advance\dimen@ii-8\p@\else
  \ifdim\dimen@>18\p@\advance\dimen@ii-6\p@\else
  \ifdim\dimen@>12\p@\advance\dimen@ii-4\p@\else
  \ifdim\dimen@>10\p@\advance\dimen@ii-\tw@\p@\fi\fi\fi\fi\fi
 \setbox\tw@\hbox{$\m@th#1\mskip\uproot@ mu$}\advance\dimen@ii by1.667\wd\tw@
 \mkern-\leftroot@ mu\mkern5mu\raise.6\dimen@ii\copy\rootbox
 \mkern-8mu\mkern\leftroot@ mu\box\z@\leftroot\z@\uproot\z@}
\def\space@.{\futurelet\space@\relax}
\space@. %

% left as is for the moment. 
\newif\ifsubscriptcorrection \subscriptcorrectiontrue
\ifsubscriptcorrection
\expandafter\let\csname subscript character \string_\endcsname_
\catcode`\_=\active
\def_{\ifmmode\expandafter\sb@\else
 \expandafter\csname subscript character \string_\endcsname\fi}
\let\sb_
\ifnum\catcode`\^^A=8 \catcode`\^^A\active\let^^A_\fi
\def\sb@#1{\csname subscript character \string_\endcsname
 {\futurelet\next\sb@@#1}}
\def\sb@@{%
 \ifx\next\space@\def\next@. {\futurelet\next\sb@@}\else
  \def\next@.{%
   \ifx\next j\mkern-\tw@ mu\else
   \ifx\next f\mkern-\tw@ mu\else
   \ifx\next p\mkern-\@ne mu
   \fi\fi\fi}%
 \fi
 \next@.}
\fi
\def\jadjust{\mkern-\tw@ mu}

\protect


