\newcount\embedcount\embedcount=0
\newwrite\checkexists
\newwrite\embedfile
\def\inputifexists#1{%
        \openin\checkexists #1
        \ifeof\checkexists
                 \closein\checkexists
        \else
                \closein\checkexists
                \input #1
        \fi
}

\def\embedcountid{feta-embed}
\inputifexists{\embedcountid.aux}
%
% let's not overwrite -- and be sure to create new
\def\embedclose{%
        \immediate\openout\embedfile=\embedcountid.aux
        \immediate\write\embedfile{\embedcount=\the\embedcount}
        \immediate\closeout\embedfile
}


% let's keep embedcount to see how many embedded mf's clutter your system
\def\embeddedmf#1#2{%
        \edef\embedid{#1}%
        \immediate\openout\embedfile=\embedid.mf%
        \global\advance\embedcount by 1%
       \immediate\write\embedfile{\%Automatically generated by TeX (fetdefs.tex
)}%
       \immediate\write\embedfile{\%Do not edit}%
        \immediate\write\embedfile{#2}%
        \immediate\closeout\embedfile%
        \font\expandafter\embedid\expandafter=\embedid%
        \embedid\char0%
}
 

