%%% Direct tt font selection for Tcode, bypassing LaTeX's NFSS bookkeeping.

\count255=\catcode`@
\catcode`@=11

\ifdefined\AtBeginDocument
\ifdefined\SelectCodeFont

%This will activate the tt fonts and call \HookIntoTcodeHook
\AtBeginDocument{
{\ttfamily\upshape\mdseries\DoSelectCodeFontIV \normalsize\small\footnotesize\scriptsize\large}
}

%We hook into the \SelectCodeFont to replace its default (=\ttfamily) by a harcoded font, except for its size
\def\DoSelectCodeFontIV{
  \escapechar=-1 \edef\thettfont{\exP\string\the\font}
  \def\next##1/##2/##3/##4/##5\relax{\toks0={\csname ##1/##2/##3/##4/\f@size\endcsname}}\exP\next\thettfont\relax
  \xdef\SelectCodeFont{\the\toks0}
}

\fi\fi

\catcode`@=\count255