\ProvidesPackage{stretch}
	[1998/04/18 experimental interface to experimental TeX^^J 
	extensions -- DO NOT USE!!!!]
\DeclareOption{T1}{%

% All fd files for ec fonts use \EC@family, thus we have a convenient
% hook to add a sixth argument to the \DeclareFontShape call.
\newcommand{\EC@family}[5]{%
  \DeclareFontShape{#1}{#2}{#3}{#4}%
  {<5><6><7><8><9><10><10.95><12><14.4>%
   <17.28><20.74><24.88><29.86><35.83>genb*#5}%
  {\addvariants{\fontname\font}{970,980,990,1010,1020,1030}}}

% Make sure that LaTeX rereads the preloaded `t1cmr.fd'.  
\begingroup
\nfss@catcodes
\input{t1cmr.fd}
\endgroup

}% \DeclareOption{T1}

\ProcessOptions

%% #1 is an external font name (including an `at' or `scaled' suffix)
%%    like `cmr10' or `ecrm1000 at 8.9999pt'
%% #2 is a comma-separated list of extension factors multiplied by 1000
\def\enablestretch{\message{enabling\space font stretching...^^J}\hzstate=\@ne}
\def\disablestretch{\message{disabling\space font stretching...^^J}\hzstate=\z@}

%
% This should be used in the sixth argument of \DeclareFontShape, eg
%\DeclareFontFamily{OT1}{test}{}
%\DeclareFontShape{OT1}{test}{m}{n}
%          {<10> [0.9]ecrm1000}
%          {\addvariants{\fontname\font}{970,980,990,1010,1020,1030}}
\def\addvariants#1#2{\begingroup
 \hzstate=\@ne% otherwise \fontvariant would be illegal 
 \expandafter\split@ext#1 \@@nil
 \message{adding\space variants\space for\space <\f@stem><\f@ext>...^^J}%
 \let\@tempb\@empty
 \@tfor\@tempa:=#2,\do{%
  \if,\@tempa
    \font\x=\f@stem\ifnum\@tempb<1000 w0\@tempb\else w\@tempb\fi\f@ext
    \fontvariant\font=\x
    \message{\fontname\x^^J}%
    \let\@tempb\@empty
  \else
    \edef\@tempc{\@tempb}% 
    \edef\@tempb{\@tempc\@tempa}%
  \fi}%
\endgroup}

% Use like \split@ext<external fontname>\@@nil
% This splits <external fontname> into a filename part and an `at' 
% or `scaled' part. The results are returned in \f@stem and \f@ext.
\begingroup
 \catcode`\ =10
 \gdef\split@ext#1 #2\@@nil{\def\f@stem{#1}\def\f@ext{ #2}}
\endgroup