% \iffalse meta-comment
%
% Copyright (C) 2015-2019 by Enrico Gregorio
% <Enrico dot Gregorio (at) univr dot it>
% ---------------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.3c or later is part of all distributions of LaTeX
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{fixcmex.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{fixcmex}
%<*package>
    [2019/08/05 v1.1 Scalable math extensions font (Enrico Gregorio)]
%</package>
%
%<*driver>
\documentclass{ltxdoc}

\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{fixcmex.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{48}
%
% \changes{v1.0}{2015/11/10}{Initial version}
% \changes{v1.1}{2019/08/05}{Fix lmodern}
%
% \GetFileInfo{fixcmex.dtx}
%
% \DoNotIndex{\begingroup,\endgroup,\aftergroup,\@nil,\cmex,\lmex}
% \DoNotIndex{\def,\edef,\else,\escapechar,\expandafter,\fi,\ifx}
% \DoNotIndex{\m@ne,\string,\textfont,\the,\thr@@}
%
%
% \title{The \textsf{fixcmex} package\thanks{This document corresponds
% to \textsf{itnumpar}~\fileversion, dated \filedate.}}
%
% \author{Enrico Gregorio \\ \texttt{Enrico dot Gregorio (at) univr
% dot it}}
%
% \date{\filedate}
%
% \maketitle
%
% \section{Description}
%
% Knuth's Computer Modern fonts only provide the math extensions
% font \texttt{cmex10} at just one size. Together with a release
% of AMS-\TeX{}, the American Mathematical Society also provided
% the font at sizes 7, 8 and 9; these fonts are automatically loaded
% when \verb+\usepackage{amsmath}+ is done for a document. The
% option \texttt{cmex10} is allowed for reverting back to the fixed
% size, but it should only be used when the \TeX{} distribution is
% more than, say twenty years old (at the time of writing).
%
% Where's the difference? With the standard setup, a symbol like
% summation or integral in a footnote or in a \verb+\Large+ context
% will have the same size as in normal text. This size is also
% independent of the main point size of a document.
%
% When \textsf{amsmath} (or \textsf{exscale}) is loaded, the symbols
% will be scaled, but only at the standard sizes, not arbitrarily.
% This is not a limitation any more, because the Type1 version of
% the \texttt{cmex} fonts has been available for several years and
% this package addresses it.
%
% Many people use the Latin Modern fonts that are, in several respects,
% superior to the European Modern fonts when T1 font encoding is
% required. However, when \verb+\usepackage{lmodern}+ is done,
% the situation about the math extensions font goes back to the
% standard state described above, because \texttt{lmex10} is only
% provided at a fixed size.
%
% The present package can be used when the main font of the document
% is Computer Modern (or European Modern, if T1 encoding is selected)
% or Latin Modern. It redefines the math extensions font so that it
% is arbitrarily scalable, using the optical size fonts provided by
% the AMS together with the original \texttt{cmex10} font.
%
% The package should be loaded as late as possible, in any case
% \emph{after} any font package. Its position with respect to
% \textsf{hyperref} or \textsf{cleveref} is irrelevant. It will do
% nothing if the math extensions font turns out to be not from
% Computer Modern or Latin Modern (with a warning).
%
% There are no options and no commands.
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \section{Implementation}
% \begin{macro}{\fixcmex@fix}
% \changes{v1.1}{2019/08/05}{Fix lmodern}
% The main command just resets the math extensions font to
% be \texttt{cmex}, fully scalable.
%    \begin{macrocode}
%<*package>
\def\fixcmex@fix{%
  \DeclareFontShape{OMX}{cmex}{m}{n}{%
    <-7.5> cmex7
    <7.5-8.5> cmex8
    <8.5-9.5> cmex9
    <9.5-> cmex10
  }{}%
  \SetSymbolFont{largesymbols}{normal}{OMX}{cmex}{m}{n}%
  \SetSymbolFont{largesymbols}{bold}{OMX}{cmex}{m}{n}%
  \mathversion{\math@version}%
}
\@onlypreamble\fixcmex@fix
%    \end{macrocode}
% \end{macro}
%
% Next, at begin document, the \verb+\check@mathfonts+ command
% makes sure the font assignments are performed for the normal
% size and the family name corresponding to the OMX encoding
% is extracted. If it is either \texttt{cmex} or \texttt{lmex}
% the command \verb+\fixcmex@fix+ will be executed. Otherwise
% a warning is issued, telling that the package has done nothing.
%    \begin{macrocode}
\AtBeginDocument{%
  \begingroup
    \check@mathfonts
    \expandafter\expandafter\expandafter
      \split@name\expandafter\string\the\textfont\thr@@\@nil
    \escapechar=\m@ne
    \edef\fixcmex@cmex{\string\cmex}\edef\fixcmex@lmex{\string\lmex}%
    \ifx\f@family\fixcmex@cmex
      \aftergroup\fixcmex@fix
    \else
      \ifx\f@family
        \fixcmex@lmex\aftergroup\fixcmex@fix
      \else
        \PackageWarningNoLine{fixcmex}{No change in the math extension font}%
      \fi
    \fi
  \endgroup
}
%</package>
%    \end{macrocode}
% \Finale
\endinput