%
% anyfontsize.sty -- allow font size substitutions
% by Péter Szabó <pts@fazekas.hu> at Sat Feb  3 13:56:49 CET 2007
%
% anyfontsize.sty is a LaTeX2e package that lets the user select any font
% size (via e.g. \fontsize{...}{...}\selectfont), even those sizes that are
% not listed in the .fd file. If such a size is requested, LaTeX will search
% the nearest listed size, and anyfontsize.sty will scale that font to the
% requested size. For a similar functionality that works only for the CM
% fonts, try the type1cm.sty package, or, even better, use the new Latin
% Modern (LM) fonts, which are available at any size.
%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% 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.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%
%
% For PostScript Type1 fonts (such as Times (with times.sty) or Latin Modern
% (with lmodern.sty)), you usually don't need anyfontsize.sty, because these
% fonts are available at all sizes.
%
% anyfontsize.sty doesn't work well with pdfLaTeX + the EC fonts (because
% pdfTeX won't regenarate missing PK fonts for you). Compile the document
% with latex(1) first (which will regenarte the missing PK fonts), and after
% that you can use pdflatex(1).
%
% Test with this document:
%
%   \documentclass{article}
%   \usepackage{anyfontsize}
%   \usepackage{t1enc}
%   %\input t1cmr.fd
%   %\DeclareFontFamily{T1}{cmr}{}
%   %\DeclareFontShape{T1}{cmr}{m}{n}{<10>ecrm1000}{}
%   \begin{document}
%   \fontsize{23}{28}\selectfont foo
%   \end{document}
%
% History:
%
% -- 2007/02/04: original release
% -- 2007/11/22: added space bugfix, as suggested by Christian Schroeppel
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{anyfontsize}[2007/11/22 anyfontsize.sty by pts]

%** Don't warn on font substitutions made.
\def\fontsubfuzz{9999pt}

% vvv Dat: only for testing
%\input t1cmr.fd
%\DeclareFontFamily{T1}{cmr}{}
%\DeclareFontShape{T1}{cmr}{m}{n}{<10>ecrm1000}{}

%** Overrides \externalfont by specifying the ` at <requested-fontsize>pt'
%** clause. The requested font size is in \f@user@size.
\def\anyfontsize@set#1 #2\hfuzz{%
  \@tempdimb=\f@user@size\p@%
  \edef\external@font{#1 at\the\@tempdimb}%
}%

%** Overrides definition in latex.ltx
%** See %%%% pts %%%% for the overridden part.
\gdef\tryif@simple#1-#2\tryif@simple{%
  \let \reserved@f \try@simples
  \if>#2%
    \dimen@ #1\p@
    \ifdim \dimen@<\@M\p@
      \ifdim \f@size\p@<\dimen@
        \@tempdimc \dimen@     
        \advance\@tempdimc -\f@size\p@
      \else                           
        \@tempdimc \f@size\p@
        \advance\@tempdimc -\dimen@
      \fi                          
      \ifdim \@tempdimc<\@tempdimb
        \@tempdimb \@tempdimc     
        \def \best@size{#1}% 
      \fi                   
    \else
  \ifx \external@font\@empty
    \ifx \best@size\@empty  
    \else                 
      \ifdim \@tempdimb>\font@submax \relax
        \xdef \font@submax {\the\@tempdimb}%
      \fi                                   
      \let \f@user@size \f@size
      \let \f@size \best@size  
      \ifdim \@tempdimb>\fontsubfuzz\relax
        \@font@warning{Font\space shape\space
            `\curr@fontshape'\space in\space size\space
             <\f@user@size>\space not\space available\MessageBreak
             size\space <\f@size>\space substituted}%             
      \fi                                            
      \try@simple@size
      %
      %%%% pts %%%%
      \expandafter\anyfontsize@set\external@font\hfuzz
      %      
      \do@subst@correction
    \fi                   
 \fi
      \let \reserved@f \remove@to@nnil
    \fi                               
  \fi
  \reserved@f}

\endinput
