% \iffalse meta-comment
%<*internal>
\begingroup
\input docstrip
\preamble

Copyright 2020 Ivan Valbusa

This program is provided under the terms of the
LaTeX Project Public License distributed from CTAN
archives in directory macros/latex/base/lppl.txt.

Author: Ivan Valbusa
Ivan dot Valbusa at gmail dot com

This work has the LPPL maintenance status "author-maintained".

\endpreamble

\keepsilent
\askforoverwritefalse

\Msg{*** Generating the package files ***}
\generate{\file{fontsize.sty}{\from{fontsize.dtx}{package}}%
}

\Msg{***********************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* files into a directory searched by TeX:}
\Msg{*}
\Msg{* \space\space fontsize.sty}
\Msg{*}
\Msg{*}
\Msg{* To produce the documentation on fontsize's code run}
\Msg{* the file ending with `.dtx' through (pdf)LaTeX. See the}
\Msg{* README file for more details.}
\Msg{*}
\Msg{* Happy TeXing}
\Msg{***********************************************************}
\endgroup
%</internal>
%
% Copyright (C) 2020 by Ivan Valbusa 
% <Ivan dot Valbusa at gmail dot com>
% -------------------------------------------------------
% 
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% 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.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work consists of all files listed in README
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{fontsize.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%<package>\ProvidesPackage{fontsize}
%<*package>
  [2020/02/20 v0.1 'fontsize' package. Set main font sizes (Ivan Valbusa)]
%</package>
%<*driver>
\PassOptionsToClass{a4paper}{article}
\documentclass{ltxdoc}
\let\cmd\relax
\let\cs\relax
\usepackage[T1]{fontenc}
\usepackage{ltxdockit}
\usepackage[fontsize=10.5]{fontsize}

\makeatletter
\newcommand{\mysize}[1]{%
	\bgroup\noindent\csname#1\endcsname The \cmd{#1} size is: \textbf{\csname#1\endcsname\f@size\,pt}.\\The  \cmd{baselineskip} is \the\baselineskip\par\vskip2mm\egroup}
\makeatother

\EnableCrossrefs         
\CodelineIndex
\RecordChanges

\begin{document}
  \DocInput{fontsize.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{787}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \changes{v0.1}{2020/02/20}{First public release}
% \GetFileInfo{fontsize.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment,\def,\begin,\vskip,\ }
% \DoNotIndex{\DeclareOption,\ExecuteOptions,\RequirePackage}
% \DoNotIndex{\@@end,\@empty,\@ifclassloaded,\@nameuse,\@nil}
% \DoNotIndex{\@undefined,\\,\`,\addtocounter,\advance,\bfseries}
% \DoNotIndex{\centering,\closeout,\define@key,\documentclass}
% \DoNotIndex{\edef,\else,\end,\endinput,\endtitlepage,\expandafter}
% \DoNotIndex{\extracolsep,\fi,\fill,\fontsize,\g@addto@macro,\toks}
% \DoNotIndex{\hrule,\hspace,\if,\if@twoside,\ifcase,\ifdefined}
% \DoNotIndex{\iffalse,\IfFileExists,\ifnum,\ifx,\immediate,\setcounter}
% \DoNotIndex{\jobname,\let,\long,\MakeUppercase,\MessageBreak}
% \DoNotIndex{\newcount,\newif,\newpage,\newtoks,\newwrite,\next}
% \DoNotIndex{\noexpand,\nofiles,\normalfont,\normalsize,\null}
% \DoNotIndex{\openout,\or,\Package,\PackageError,\PackageWarning}
% \DoNotIndex{\PackageWarningNoLine,\paperheight,\paperwidth,\par}
% \DoNotIndex{\parbox,\parindent,\relax,\scshape,\selectfont,\setkeys}
% \DoNotIndex{\sffamily,\space,\stretch,\string,\textheight,\textwidth}
% \DoNotIndex{\the,\thispagestyle,\unexpanded,\unless,\unskip,\upshape}
% \DoNotIndex{\usepackage,\vbox,\vfill,\vspace,\write,\z@}
% \DoNotIndex{\CurrentOption,\AtEndDocument,\@ne,\c@page,\m@ne}
% \DoNotIndex{\@firstofone,\@gobble,\@makeother,\begingroup,\endgroup}
% \DoNotIndex{\eTeXversion,\hbox,\hsize,\includegraphics,\newlinechar}
% \DoNotIndex{\titlepage,\vss,\vtop,\xdef,\@gobbletwo,\color,\dimexpr}
% \DoNotIndex{\huge,\large,\makebox,\ProcessOptions,\renewcommand}
% 

% 
% 
% \title{The \textsf{fontsize} package\\ \normalsize \textit{A small package to change the font size}}
% \author{Ivan Valbusa \\
%   \texttt{Ivan dot Valbusa at gmail dot com}}
% \date{\fileversion{} -- \filedate}
%
% \maketitle
%
%\noindent The \sty{fontsize} package allows you to set arbitrary sizes for the main font of the document, through the \opt{fontsize=\meta{size}} option. The value for the  \meta{size} can be given in any unit recognized by TeX (for example: \opt{6mm}, \opt{1ex}, \opt{11.5pt}). If the unit is not declared it defaults to \texttt{pt}. So \opt{fontsize=11} is the same as \opt{fontsize=11pt}. See the example below.
%
% \section*{Caveat}
%
% Although effective with any value for the \meta{size} (as long as the font is scalable!), the package is meant for small font size changes. For truly optimal results you should not use this package at all. Rather, a \file{.clo} file should be defined for each main size, even if this is pretty hard work. Particularly, you should define \cmd{parindent} accordingly to the used size.
%
% \section*{Credits}
%
% The code is a a minimal part of the \sty{scrextend}, with few minor changes to make it completely independent of the Koma bundle (see \cite{koma}).
%
% \section*{An example}
%
% \verb!\usepackage[fontsize=10.5]{fontsize}!\bigskip
%
%
%\mysize{tiny}
%\mysize{scriptsize}
%\mysize{footnotesize}
%\mysize{small}
%\mysize{normalsize}	
%\mysize{large}
%\mysize{Large}
%\mysize{LARGE}
%\mysize{huge}
%\mysize{Huge}
%
% \begin{thebibliography}{label}
%	\bibitem{koma} Frank Neukam, Markus Kohm, Axel Kielhorn, \textit{KOMA -- Script. A versatile \LaTeXe{} bundle}. \url{https://www.ctan.org/pkg/koma-script}
% \bibitem{xkeyval} Hendri Adriaens, \textit{The \sty{xkeyval} package}, \url{https://www.ctan.org/pkg/xkeyval}.
% \bibitem{etoolbox} Philipp Lehman, Joseph Wright, \textit{The \sty{etoolbox} Package. An e-\TeX{} Toolbox for Class and Package Authors}, \url{https://www.ctan.org/pkg/etoolbox}.

% \end{thebibliography}
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \section{The Code}
%
% \iffalse
%<*package>
% \fi
%    \begin{macrocode}
\@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}}
\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
%    \end{macrocode}
% Here begins the \sty{scrextend} code. Only a few names have changed. 
% The value for \cmd{@fontsizefilebase} is set to \texttt{custom} instead of \texttt{scrsize}.
%    \begin{macrocode}
\providecommand*{\@fontsizefilebase}{custom}
\DeclareOptionX{fontsize}[10]{%
  \expandafter\@defaultunits\expandafter\@tempdima#1 pt\relax\@nnil
  \edef\@tempa{#1}%
  \setlength{\@tempdimb}{\@tempdima}%
  \edef\@tempb{\strip@pt\@tempdimb}%
  \addtolength{\@tempdimb}{-10\p@}%
  \edef\@ptsize{\strip@pt\@tempdimb}%
  \edef\@tempa{%
    \noexpand\makeatletter
    \noexpand\InputIfFileExists{\@fontsizefilebase\@tempa.clo}{%
      \noexpand\PackageInfo{fontsize}{%
        File `\@fontsizefilebase\@tempa.clo' used to setup font sizes}%
    }{%
        \noexpand\changefontsize{#1}%
    }%
    \noexpand\catcode`\noexpand\@=\the\catcode`\@
  }%
  \expandafter\AtEndOfPackage\expandafter{\@tempa}%
}
%    \end{macrocode}
%    \begin{macrocode}
\ProcessOptionsX*\relax
%    \end{macrocode}
% The comamnd \cmd{ctm@setlength} has the same definition as \cmd{scr@setlength} of \file{scrextend.sty}.
%    \begin{macrocode}
\newcommand*\ctm@setlength[4]{%
  \ifdim #2<\ifdim #2=\z@ \z@ \else \p@\fi
  \ifdim #3<\ifdim #3=\z@ \z@ \else \p@\fi
  \ifdim #4<\ifdim #4=\z@ \z@ \else \p@\fi
  \setlength{#1}{\p@ \@plus\p@ \@minus\p@}%
  \else
  \setlength{#1}{\p@ \@plus\p@ \@minus#4}%
  \fi
  \else
  \ifdim #4<\ifdim #4=\z@ \z@ \else \p@\fi
  \setlength{#1}{\p@ \@plus#3 \@minus\p@}%
  \else
  \setlength{#1}{\p@ \@plus#3 \@minus#4}%
  \fi
  \fi
  \else
  \ifdim #3<\ifdim #3=\z@ \z@ \else \p@\fi
  \ifdim #4<\ifdim #4=\z@ \z@ \else \p@\fi
  \setlength{#1}{#2 \@plus\p@ \@minus\p@}%
  \else
  \setlength{#1}{#2 \@plus\p@ \@minus#4}%
  \fi
  \else
  \ifdim #4<\ifdim #4=\z@ \z@ \else \p@\fi
  \setlength{#1}{#2 \@plus#3 \@minus\p@}%
  \else
  \setlength{#1}{#2 \@plus#3 \@minus#4}%
  \fi
  \fi
  \fi
}
%    \end{macrocode}
% The comamnd \cmd{changefontsize} has the same definition as \cmd{changefontsizes} of \file{scrextend.sty}.
%    \begin{macrocode}
\providecommand*{\changefontsize}[2][1.2\@tempdima]{%
  \@defaultunits\@tempdima#2pt\relax\@nnil
  \setlength{\@tempdimc}{\@tempdima}%
  \addtolength{\@tempdimc}{-10\p@}%
  \edef\@ptsize{\strip@pt\@tempdimc}%
  \@defaultunits\@tempdimb#1pt\relax\@nnil
  \setlength{\@tempdimc}{\dimexpr (100\@tempdimb / \@tempdima * \p@)}%
  \edef\@tempb{\the\@tempdimc}%
  \setlength{\@tempdimc}{\@tempdima}%
  \def\@tempa##1##2##3##4##5\@nnil{\def##1{##2.##3##4}}%
  \expandafter\@tempa\expandafter\@tempb\@tempb\@nnil%
  \ctm@setlength{\abovedisplayskip}%
  {.8333\@tempdimb}{.1667\@tempdimb}{.5\@tempdimb}%
  \ctm@setlength{\abovedisplayshortskip}{\z@}{.25\@tempdimb}{\z@}%
  \ctm@setlength{\belowdisplayshortskip}%
  {.5\@tempdimb}{.25\@tempdimb}{.25\@tempdimb}%
  \setlength{\belowdisplayskip}{\abovedisplayskip}%
  \edef\normalsize{%
    \noexpand\@setfontsize\noexpand\normalsize
    {\the\@tempdima}{\the\@tempdimb}%
    \abovedisplayskip \the\abovedisplayskip
    \abovedisplayshortskip \the\abovedisplayshortskip
    \belowdisplayskip \the\belowdisplayskip
    \belowdisplayshortskip \the\belowdisplayshortskip
    \let\noexpand\@listi\noexpand\@listI
  }%
  \setlength{\@tempdima}{0.9125\@tempdimc}%
  \setlength{\@tempdimb}{\@tempb\@tempdima}%
  \ctm@setlength{\abovedisplayskip}%
  {.8333\@tempdimb}{.1667\@tempdimb}{.5\@tempdimb}%
  \ctm@setlength{\abovedisplayshortskip}{\z@}{.25\@tempdimb}{\z@}%
  \ctm@setlength{\belowdisplayshortskip}%
  {.5\@tempdimb}{.25\@tempdimb}{.25\@tempdimb}%
  \setlength{\belowdisplayskip}{\abovedisplayskip}%
  \edef\small{%
    \noexpand\@setfontsize\noexpand\small
    {\the\@tempdima}{\the\@tempdimb}%
    \abovedisplayskip \the\abovedisplayskip
    \abovedisplayshortskip \the\abovedisplayshortskip
    \belowdisplayskip \the\belowdisplayskip
    \belowdisplayshortskip \the\belowdisplayshortskip
    \let\noexpand\@listi\noexpand\@listi@small
  }%
  \setlength{\@tempdima}{.83334\@tempdimc}%
  \setlength{\@tempdimb}{\@tempb\@tempdima}%
  \ctm@setlength{\abovedisplayskip}%
  {.8333\@tempdimb}{.1667\@tempdimb}{.5\@tempdimb}%
  \ctm@setlength{\abovedisplayshortskip}{\z@}{.25\@tempdimb}{\z@}%
  \ctm@setlength{\belowdisplayshortskip}%
  {.5\@tempdimb}{.25\@tempdimb}{.25\@tempdimb}%
  \setlength{\belowdisplayskip}{\abovedisplayskip}%
  \edef\footnotesize{%
    \noexpand\@setfontsize\noexpand\footnotesize
    {\the\@tempdima}{\the\@tempdimb}%
    \abovedisplayskip \the\abovedisplayskip
    \abovedisplayshortskip \the\abovedisplayshortskip
    \belowdisplayskip \the\belowdisplayskip
    \belowdisplayshortskip \the\belowdisplayshortskip
    \let\noexpand\@listi\noexpand\@listi@footnotesize
  }%
  \setlength{\@tempdima}{.66667\@tempdimc}%
  \setlength{\@tempdimb}{\@tempb\@tempdima}%
  \edef\scriptsize{%
    \noexpand\@setfontsize\noexpand\scriptsize
    {\the\@tempdima}{\the\@tempdimb}%
  }%
  \setlength{\@tempdima}{.5\@tempdimc}%
  \setlength{\@tempdimb}{\@tempb\@tempdima}%
  \edef\tiny{%
    \noexpand\@setfontsize\noexpand\tiny
    {\the\@tempdima}{\the\@tempdimb}%
  }%
  \setlength{\@tempdima}{1.2\@tempdimc}%
  \setlength{\@tempdimb}{\@tempb\@tempdima}%
  \edef\large{%
    \noexpand\@setfontsize\noexpand\large
    {\the\@tempdima}{\the\@tempdimb}%
  }%
  \setlength{\@tempdima}{1.44\@tempdimc}%
  \setlength{\@tempdimb}{\@tempb\@tempdima}%
  \edef\Large{%
    \noexpand\@setfontsize\noexpand\Large
    {\the\@tempdima}{\the\@tempdimb}%
  }%
  \setlength{\@tempdima}{1.728\@tempdimc}%
  \setlength{\@tempdimb}{\@tempb\@tempdima}%
  \edef\LARGE{%
    \noexpand\@setfontsize\noexpand\LARGE
    {\the\@tempdima}{\the\@tempdimb}%
  }%
  \setlength{\@tempdima}{2.074\@tempdimc}%
  \setlength{\@tempdimb}{\@tempb\@tempdima}%
  \edef\huge{%
    \noexpand\@setfontsize\noexpand\huge
    {\the\@tempdima}{\the\@tempdimb}%
  }%
  \setlength{\@tempdima}{2.488\@tempdimc}%
  \setlength{\@tempdimb}{\@tempb\@tempdima}%
  \edef\Huge{%
    \noexpand\@setfontsize\noexpand\Huge
    {\the\@tempdima}{\the\@tempdimb}%
  }%
  \normalsize
  \setlength{\@tempdimb}{\f@baselineskip}%
  \ctm@setlength{\parsep}%
  {.3333\@tempdimb}{.1667\@tempdimb}{.0833\@tempdimb}%
  \ctm@setlength{\topsep}%
  {.6667\@tempdimb}{.1667\@tempdimb}{.3333\@tempdimb}%
  \@tempswafalse
  \begingroup
  \def\@list@extra{\aftergroup\@tempswatrue}%
  \csname @listi\endcsname
  \endgroup
  \edef\@listi{\leftmargin\leftmargini
    \topsep \the\topsep
    \parsep \the\parsep
    \itemsep \parsep
    \if@tempswa\noexpand\@list@extra\fi
  }%
  \let\@listI\@listi
  \ctm@setlength{\parsep}%
  {.1667\@tempdimb}{.0833\@tempdimb}{.0833\@tempdimb}%
  \ctm@setlength{\topsep}%
  {.3333\@tempdimb}{.1667\@tempdimb}{.1667\@tempdimb}%
  \@tempswafalse
  \begingroup
  \def\@list@extra{\aftergroup\@tempswatrue}%
  \csname @listi\endcsname
  \endgroup
  \edef\@listi@small{\leftmargin\leftmargini
    \topsep \the\topsep
    \parsep \the\parsep
    \itemsep \parsep
    \if@tempswa\noexpand\@list@extra\fi
  }%
  \ctm@setlength{\parsep}%
  {.125\@tempdimb}{.0625\@tempdimb}{.0625\@tempdimb}%
  \ctm@setlength{\topsep}%
  {.25\@tempdimb}{.125\@tempdimb}{.125\@tempdimb}%
  \@tempswafalse
  \begingroup
  \def\@list@extra{\aftergroup\@tempswatrue}%
  \csname @listi\endcsname
  \endgroup
  \edef\@listi@footnotesize{\leftmargin\leftmargini
    \topsep \the\topsep
    \parsep \the\parsep
    \itemsep \parsep
    \if@tempswa\noexpand\@list@extra\fi
  }%
  \ctm@setlength{\parsep}%
  {.1667\@tempdimb}{.0833\@tempdimb}{.0833\@tempdimb}%
  \ctm@setlength{\topsep}%
  {.3333\@tempdimb}{.1667\@tempdimb}{.0833\@tempdimb}%
  \@tempswafalse
  \begingroup
  \def\@list@extra{\aftergroup\@tempswatrue}%
  \csname @listii\endcsname
  \endgroup
  \edef\@listii{\leftmargin\leftmarginii
    \labelwidth=\dimexpr \leftmargin-\labelsep
    \topsep \the\topsep
    \parsep \the\parsep
    \itemsep \parsep
    \if@tempswa\noexpand\@list@extra\fi
  }%
  \ctm@setlength{\topsep}%
  {.1667\@tempdimb}{.0833\@tempdimb}{.0833\@tempdimb}%
  \setlength{\partopsep}{\z@ \@plus\z@ \@minus\p@}%
  \@tempswafalse
  \begingroup
  \def\@list@extra{\aftergroup\@tempswatrue}%
  \csname @listiii\endcsname
  \endgroup
  \edef\@listiii{\leftmargin\leftmarginiii
    \labelwidth=\dimexpr \leftmargin-\labelsep
    \topsep \the\topsep
    \parsep \z@
    \partopsep \the\partopsep
    \itemsep \topsep
    \if@tempswa\noexpand\@list@extra\fi
  }%
  \@tempswafalse
  \begingroup
  \def\@list@extra{\aftergroup\@tempswatrue}%
  \csname @listiv\endcsname
  \endgroup
  \edef\@listiv{\leftmargin\leftmarginiv
    \labelwidth=\dimexpr \leftmargin-\labelsep\relax
    \if@tempswa\noexpand\@list@extra\fi
  }%
  \@tempswafalse
  \begingroup
  \def\@list@extra{\aftergroup\@tempswatrue}%
  \csname @listv\endcsname
  \endgroup
  \edef\@listv{\leftmargin\leftmarginv
    \labelwidth=\dimexpr \leftmargin-\labelsep\relax
    \if@tempswa\noexpand\@list@extra\fi
  }%
  \@tempswafalse
  \begingroup
  \def\@list@extra{\aftergroup\@tempswatrue}%
  \csname @listvi\endcsname
  \endgroup
  \edef\@listvi{\leftmargin\leftmarginvi
    \labelwidth=\dimexpr \leftmargin-\labelsep\relax
    \if@tempswa\noexpand\@list@extra\fi
  }%
  \@listi
  \setlength{\@tempdimb}{\f@baselineskip}%
  \setlength{\footnotesep}{.555\@tempdimb}%
  \ctm@setlength{\skip\footins}%
  {.75\@tempdimb}{.3333\@tempdimb}{.1667\@tempdimb}%
  \ctm@setlength{\floatsep}%
  {\@tempdimb}{.1667\@tempdimb}{.1667\@tempdimb}%
  \ctm@setlength{\textfloatsep}%
  {1.6667\@tempdimb}{.1667\@tempdimb}{.3333\@tempdimb}%
  \setlength{\intextsep}{\floatsep}%
  \setlength{\dblfloatsep}{\floatsep}%
  \setlength{\dbltextfloatsep}{\textfloatsep}%
  \setlength{\@fptop}{\z@ \@plus 1fil}%
  \setlength{\@fpsep}{.6667\@tempdimb \@plus 2fil}%
  \setlength{\@fpbot}{\@fptop}%
  \setlength{\@dblfptop}{\@fptop}%
  \setlength{\@dblfpsep}{\@fpsep}%
  \setlength{\@dblfpbot}{\@fptop}%
  \ctm@setlength{\partopsep}{.2\@tempdimb}{.1\@tempdimb}{.1\@tempdimb}%
}
\endinput
%    \end{macrocode}
% \iffalse
%</package>
% \fi
% \Finale
