texlive[72479] Master/texmf-dist: fontscale (6oct24)
commits+karl at tug.org
commits+karl at tug.org
Sun Oct 6 21:51:00 CEST 2024
Revision: 72479
https://tug.org/svn/texlive?view=revision&revision=72479
Author: karl
Date: 2024-10-06 21:51:00 +0200 (Sun, 06 Oct 2024)
Log Message:
-----------
fontscale (6oct24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/fontscale/CHANGELOG.md
trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls
trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex
trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-font-steps.tex
trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-musical.tex
trunk/Master/texmf-dist/doc/latex/fontscale/fontscale.pdf
trunk/Master/texmf-dist/doc/latex/fontscale/fontscale.tex
trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/CHANGELOG.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/CHANGELOG.md 2024-10-06 13:20:37 UTC (rev 72478)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/CHANGELOG.md 2024-10-06 19:51:00 UTC (rev 72479)
@@ -7,6 +7,47 @@
## [Unreleased]
+## [v3.0.0] - 2024-10-05
+
+### Added
+- Added new `expl3` public variables that store the current font step, font
+ scale, font size, and font baselineskip. They are set in the `selectfont`
+ hook.
+ - `\l_fontscale_step_fp`
+ - `\l_fontscale_scale_fp`
+ - `\l_fontscale_size_dim`
+ - `\l_fontscale_baselineskip_skip`
+
+### Changed
+- This update includes some changes that are backwards incompatible.
+- The package commands now use the above variables instead of `\f at size` and
+ `\f at baselineskip`. This changes the behavior of `\CurrentFontStep`,
+ `\CurrentFontScale`, and `\CurrentFontSize` within the second argument of
+ `\fontsize` because `\fontsize` sets `\f at size` to the new font size before
+ expanding its second argument.
+- `\PrintFontSizeCommand` no longer tests if the current font baselineskip
+ equals the font baselineskip of any font size command from `\tiny` to
+ `\Huge`.
+- `\SetFontStep` now rounds the new font step to 5 decimal places. This is
+ important when checking if it equals the font step of any font size command
+ from `\tiny` to `\Huge`.
+- A default `pt` is now appended only in user-level commands, not in internal
+ `expl3` functions.
+- `\fontscalesetup` now processes the keys slightly faster when the key
+ `<font size command>/baselineskip` is not set.
+- Documentation improvements.
+
+### Removed
+- `\CurrentFontSizeCommand` (redundant with `\CurrentFontSize` and
+ `\CurrentFontBaselineskip`)
+
+### Fixed
+- The error message for `\SetFontStep*` when the current font step is undefined
+ no longer writes `\SetFontStep*`. This would be incorrect if its
+ corresponding internal function was used instead of `\SetFontStep*`.
+- The internal functions of `\PrintSampleText` now correctly enclose their
+ contents within a group.
+
## [v2.4.0] - 2024-09-10
### Changed
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls 2024-10-06 13:20:37 UTC (rev 72478)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls 2024-10-06 19:51:00 UTC (rev 72479)
@@ -4,7 +4,7 @@
\NeedsTeXFormat{LaTeX2e}[2023-11-01]
\ProvidesExplClass
{beery}
- {2024-09-10}
+ {2024-10-05}
{}
{}
@@ -93,7 +93,7 @@
\skip_set_eq:NN \medskipamount \c_beery_medium_skip
\skip_set_eq:NN \smallskipamount \c_beery_small_skip
-\flushbottom
+\raggedbottom
\int_set:Nn \vbadness { 100 }
\skip_set:Nn \topskip { \l_fontscale_normalsize_size_dim }
@@ -239,7 +239,7 @@
\RequirePackage [ bottom ] { footmisc }
\renewcommand \footnoterule { }
-\setlength { \skip \footins } { \c_beery_big_skip }
+% \setlength { \skip \footins } { \c_beery_big_skip }
\dim_set:Nn \footnotesep { \f at linespread \footnotesep }
\coffin_new:N \l__beery_footnote_coffin
% 1.2 = baselineskip-size-ratio
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex 2024-10-06 13:20:37 UTC (rev 72478)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex 2024-10-06 19:51:00 UTC (rev 72479)
@@ -1,6 +1,4 @@
-\ProvidesFile
- {fontscale-table-classic.tex}
- [2024-09-10]
+\ProvidesFile{fontscale-table-classic.tex}[2024-10-05]
\begin{table}
\centering
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-font-steps.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-font-steps.tex 2024-10-06 13:20:37 UTC (rev 72478)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-font-steps.tex 2024-10-06 19:51:00 UTC (rev 72479)
@@ -1,6 +1,4 @@
-\ProvidesFile
- {fontscale-table-font-steps.tex}
- [2024-09-10]
+\ProvidesFile{fontscale-table-font-steps.tex}[2024-10-05]
\begin{table}
\centering
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-musical.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-musical.tex 2024-10-06 13:20:37 UTC (rev 72478)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-musical.tex 2024-10-06 19:51:00 UTC (rev 72479)
@@ -1,6 +1,4 @@
-\ProvidesFile
- {fontscale-table-musical.tex}
- [2024-09-10]
+\ProvidesFile{fontscale-table-musical.tex}[2024-10-05]
\begin{table}
\centering
@@ -7,7 +5,7 @@
\caption
{%
The font size of each font size command from \cs{tiny} to \cs{Huge} when using a musical typographic scale with the initial values.
- The font sizes are in units of \unit{pt} and rounded to two decimal places.%
+ The font sizes are in units of \unit{pt} and rounded to \num{2} decimal places.%
\label{table:musical}%
}
\bigskip
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/fontscale.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/fontscale.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/fontscale.tex 2024-10-06 13:20:37 UTC (rev 72478)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale.tex 2024-10-06 19:51:00 UTC (rev 72479)
@@ -14,7 +14,7 @@
Oliver Beery
-Version 2.4.0\quad{}10 September 2024
+Version 3.0.0\quad{}5 October 2024
\section{Introduction}
@@ -32,11 +32,11 @@
\item
Set the font sizes and font baselineskips of the standard \LaTeX{} font size commands mid\-/document or within a local group (\S\ref{subsec:fontscalesetup}).
\item
- Provides expandable commands that expand to the current font step, font scale, font size, font baselineskip, or font size command (\S\ref{subsec:expandable}).
+ Provides expandable commands that expand to the current font step, font scale, font size, or font baselineskip (\S\ref{subsec:expandable}).
\item
Provides additional font size commands, including setting the font size by setting the font step or font scale and setting the font size relative to the current font size using more powerful tools than the \pkg{scalefnt} and \pkg{relsize} packages (\S\ref{subsec:fontsize}).
\item
- For \LaTeX3 programmers, this package defines public \pkg{expl3} variables that store the font step, font scale, font size, and font baselineskip of each font size command from \cs{tiny} to \cs{Huge} (\S\ref{sec:programming}).
+ For \LaTeX3 programmers, this package defines public \pkg{expl3} variables that store the font step, font scale, font size, and font baselineskip of each font size command from \cs{tiny} to \cs{Huge} and the current font step, font scale, font size, and font baselineskip (\S\ref{sec:programming}).
\end{itemize}
\subsection{Loading the package}
@@ -60,7 +60,7 @@
When loaded, this package uses \cs{normalsize} after defining and initializing the font size commands from \cs{tiny} to \cs{Huge}.
-Many \LaTeX{} document classes have a font size option (e.g.\@ \Key{10pt}, \Key{11pt}, \Key{12pt}) which not only changes the set of document font sizes, but also modifies additional settings such as the page layout and vertical spacing which were specifically designed to work with those font sizes.
+Many \LaTeX{} document classes have a font size option (e.g.\ \Key{10pt}, \Key{11pt}, \Key{12pt}) which not only changes the set of document font sizes, but also modifies additional settings such as the page layout and vertical spacing which were specifically designed to work with those font sizes.
For this reason, you may want to set the document class font size option close to the font size of \cs{normalsize} set by this package.
\listheading{Internally, this package defines each font size command from \cs{tiny} to \cs{Huge} using the low\-/level font commands \cs{fontsize} and \cs{selectfont}\---they have no additional functionality beyond that of \cs{fontsize} and \cs{selectfont}, except that they:}
@@ -106,7 +106,7 @@
\subsection{The typographic scale}
\label{subsec:typographicscale}
-The font sizes of the font size commands from \cs{tiny} to \cs{Huge} are initially set by the key \Key{typographic\-/scale}.
+The font sizes of the font size commands from \cs{tiny} to \cs{Huge} are initially set by the key \Key{typographic-scale}.
\Key{typographic-scale}
[%
@@ -125,17 +125,17 @@
\nopagebreak\newline
\Key{musical}
-The value of the key \Key{typographic\-/scale} must be \Value{classic\-/10pt}, \Value{classic\-/11pt}, \Value{classic\-/12pt}, or \Value{musical}.
-The initial value is \Value{classic\-/10pt}.
+The value of the key \Key{typographic-scale} must be \Value{classic-10pt}, \Value{classic-11pt}, \Value{classic-12pt}, or \Value{musical}.
+The initial value is \Value{classic-10pt}.
Sets the font size of each font size command from \cs{tiny} to \cs{Huge} using a classic or musical typographic scale.
These are common methods of choosing a set of document font sizes.
-The keys \Key{classic\-/10pt}, \Key{classic\-/11pt}, \Key{classic\-/12pt}, and \Key{musical} set the key \Key{typographic\-/scale} to the corresponding value.
+The keys \Key{classic-10pt}, \Key{classic-11pt}, \Key{classic-12pt}, and \Key{musical} set the key \Key{typographic-scale} to the corresponding value.
The classic typographic scale consists of the traditional font sizes
\numlist{6;7;8;9;10;11;12;14;16;18;21;24;36;48;60;72}.%
\footnote{See \S3.1 of \textit{The Elements of Typographic Style} by Robert Bringhurst.}
They have been used since the sixteenth century and are the default font sizes on most computer software.
-Setting the value of the key \Key{typographic\-/scale} to \Key{classic\-/10pt}, \Key{classic\-/11pt}, or \Key{classic\-/12pt} sets the font size of each font size command from \cs{tiny} to \cs{Huge} to values based on their position in the classic typographic scale.
+Setting the value of the key \Key{typographic-scale} to \Key{classic-10pt}, \Key{classic-11pt}, or \Key{classic-12pt} sets the font size of each font size command from \cs{tiny} to \cs{Huge} to values based on their position in the classic typographic scale.
The named point size\---\qtylist[list-final-separator={, or }]{10;11;12}{pt}\---is the font size of \cs{normalsize}.
The font sizes of the other font size commands are the adjacent font sizes in the classic typographic scale.
Table~\ref{table:classic} displays the font size of each font size command when using a classic typographic scale.
@@ -148,7 +148,7 @@
\nopagebreak\newline
\Key{musical/notes}[\meta{integer expression}][5]
-The key \Key{typographic\-/scale}[musical] sets the font size of each font size command from \cs{tiny} to \cs{Huge} using a musical typographic scale.
+The key \Key{typographic-scale}[musical] sets the font size of each font size command from \cs{tiny} to \cs{Huge} using a musical typographic scale.
The font sizes are calculated using the formula:%
\footnote
{%
@@ -175,7 +175,7 @@
\subsection{The baselineskip-size-ratio}
\label{subsec:baselineskipsizeratio}
-The font baselineskips of the font size commands from \cs{tiny} to \cs{Huge} are initially set by the key \Key{baselineskip\-/size\-/ratio}.
+The font baselineskips of the font size commands from \cs{tiny} to \cs{Huge} are initially set by the key \Key{baselineskip-size-ratio}.
\Key{baselineskip-size-ratio}[\meta{floating point expression}][1.2]
\KeepNextPar*
@@ -197,7 +197,7 @@
\KeepNextPar*
Sets the font size of \meta{font size command} by setting its font scale to the result of computing the \meta{floating point expression}.
-Overwrites the font size set by the key \Key{typographic\-/scale}.
+Overwrites the font size set by the key \Key{typographic-scale}.
The key \Key{normalsize\slash{}scale} is not defined.
\Key{\meta{font size command}/size}[\meta{dimen expression}][\meta{not set}]
@@ -204,13 +204,13 @@
\KeepNextPar*
Sets the font size of \meta{font size command} to the value of \meta{dimen expression}, appending a default unit of \unit{pt}.
-Overwrites the font size set by the keys \Key{typographic\-/scale} and \Key{\meta{font size command}\slash{}scale}.
+Overwrites the font size set by the keys \Key{typographic-scale} and \Key{\meta{font size command}\slash{}scale}.
\Key{\meta{font size command}/baselineskip}[\meta{skip expression}][\meta{not set}]
\KeepNextPar*
Sets the font baselineskip of \meta{font size command} to the value of \meta{skip expression}, appending a default unit of \unit{pt}.
-Overwrites the font baselineskip set by the key \Key{baselineskip\-/size\-/ratio}.
+Overwrites the font baselineskip set by the key \Key{baselineskip-size-ratio}.
\Key{\meta{font size command}}[\meta{dimen expression}]
\nopagebreak\newline
@@ -222,6 +222,7 @@
The latter format resembles traditional typographic notation where the size and leading of a text can be expressed as, for example, \num{10}/\num{12} or \num{11}/\num{13}.
The number before\slash{}after the slash is the size\slash{}leading in units of \unit{pt}.%
}
+A \enquote{\texttt{/}} contained within a brace group will not be treated as the delimiter.
\section{Commands}
@@ -257,26 +258,10 @@
They can be used for printing or within calculations.
For clarity, \cs{CurrentFontStep} will be explained in detail.
-\cs{CurrentFontStep} initially tests if the current font size equals the font size of any font size command from \cs{tiny} to \cs{Huge}.
-If so, it expands to the font step of that font size command (Table~\ref{table:fontsteps}).
-If not and if the value of the key \Key{typographic\-/scale} is \Value{musical}, \cs{CurrentFontStep} expands to the current font step calculated from the musical typographic scale (Equation~\ref{eq:musical}).
+If the current font size equals the font size of any font size command from \cs{tiny} to \cs{Huge}, then \cs{CurrentFontStep} expands to the font step of that font size command (Table~\ref{table:fontsteps}).
+If not and if the value of the key \Key{typographic-scale} is \Value{musical}, \cs{CurrentFontStep} expands to the font step calculated from the musical typographic scale (Equation~\ref{eq:musical}).
Otherwise, the current font step is undefined and \cs{CurrentFontStep} expands to nothing.
-Internally, \cs{CurrentFontStep}, \cs{CurrentFontScale}, and \cs{CurrentFontSize} rely on the kernel command \cs{f at size}.
-(\cs{f at size} stores the current font size in units of \unit{pt}, omitting the unit.)
-The low\-/level font command \cs{fontsize}\marg{dimen}\marg{skip} sets \cs{f at size} to the new font size before expanding its second argument.
-This means that, if used in \meta{skip}, \cs{CurrentFontStep}, \cs{CurrentFontScale}, and \cs{CurrentFontSize} will expand to the new value\---unless they are first expanded.
-This package provides \cs{SetFontSizeBaselineskip} as an alternative to \cs{fontsize} + \cs{selectfont} that avoids this issue (\S\ref{subsec:fontsize}).
-
-\cs{CurrentFontSizeCommand}
-\KeepNextPar*
-
-Tests if the current font size and current font baselineskip equal the font size and font baselineskip, respectively, of any font size command from \cs{tiny} to \cs{Huge}.
-If so, expands to the name of that font size command.
-This omits the backslash character and leaves only letters with catcode \num{11}.
-If not, expands to nothing.
-This package also provides a similar command \cs{PrintFontSizeCommand}, which is not expandable and includes the backslash character (\S\ref{subsec:debug}).
-
\subsection{More font size commands}
\label{subsec:fontsize}
@@ -287,17 +272,19 @@
\KeepNextPar*
Sets the font size by setting the font step to the result of computing the \meta{floating point expression}.
-Adding the optional star instead increases the current font step by the result of computing the \meta{floating point expression} or issues an error if the current font step is undefined (as explained for \cs{CurrentFontStep} in \S\ref{subsec:expandable}).
-Sets the font baselineskip equal to the new font size \texttimes{} the value of the key \Key{baselineskip\-/size\-/ratio}.
+Adding the optional star instead sets the font step equal to the current font step + the result of computing the \meta{floating point expression}.
+The font step is rounded to \num{5} decimal places.
+Sets the font baselineskip equal to the new font size \texttimes{} the value of the key \Key{baselineskip-size-ratio}.
\listheading{Three exceptions:}
\begin{itemize}
\item
- The font step must equal the font step of any font size command from \cs{tiny} to \cs{Huge} (Table~\ref{table:fontsteps}) unless the value of the key \Key{typographic\-/scale} is \Value{musical}.
+ If the font step equals the font step of any font size command from \cs{tiny} to \cs{Huge} (Table~\ref{table:fontsteps}), then that font size command will be used directly.
+ \item
\cs{SetFontStep} will issue an error if the font step is undefined (as explained for \cs{CurrentFontStep} in \S\ref{subsec:expandable}).
+ The font step must equal the font step of any font size command from \cs{tiny} to \cs{Huge} unless the value of the key \Key{typographic-scale} is \Value{musical}.
+ \cs{SetFontStep*} will always issue an error if the current font step is undefined.
\item
- If the font step equals the font step of any font size command from \cs{tiny} to \cs{Huge}, then that font size command will be used directly.
- \item
Does nothing, except issue a warning, if used in math mode.
\end{itemize}
@@ -305,8 +292,8 @@
\KeepNextPar*
Sets the font size by setting the font scale to the result of computing the \meta{floating point expression}.
-Adding the optional star instead increases the current font scale by the result of computing the \meta{floating point expression}.
-Sets the font baselineskip equal to the new font size \texttimes{} the value of the key \Key{baselineskip\-/size\-/ratio}.
+Adding the optional star instead sets the font scale equal to the current font scale + the result of computing the \meta{floating point expression}.
+Sets the font baselineskip equal to the new font size \texttimes{} the value of the key \Key{baselineskip-size-ratio}.
Does nothing, except issue a warning, if used in math mode.
\cs{SetFontSize} \sarg{} \marg{dimen expression}
@@ -313,8 +300,8 @@
\KeepNextPar*
Sets the font size to the value of \meta{dimen expression}, appending a default unit of \unit{pt}.
-Adding the optional star instead increases the current font size by the result of \meta{dimen expression}, appending a default unit of \unit{pt}.
-Sets the font baselineskip equal to the new font size \texttimes{} the value of the key \Key{baselineskip\-/size\-/ratio}.
+Adding the optional star instead sets the font size equal to the current font size + the result of \meta{dimen expression}, appending a default unit of \unit{pt}.
+Sets the font baselineskip equal to the new font size \texttimes{} the value of the key \Key{baselineskip-size-ratio}.
Does nothing, except issue a warning, if used in math mode.
\cs{ScaleFont} \marg{floating point expression}
@@ -330,7 +317,6 @@
Sets the font size to the value of \meta{dimen expression}, appending a default unit of \unit{pt}.
Sets the font baselineskip to the value of \meta{skip expression}, appending a default unit of \unit{pt}.
Does nothing, except issue a warning, if used in math mode.
-Can be used as an alternative to \cs{fontsize} + \cs{selectfont} as discussed in \S\ref{subsec:expandable}.
\subsection{Setting only the font baselineskip}
\label{subsec:setfontbaselineskip}
@@ -339,7 +325,7 @@
\KeepNextPar*
Sets the font baselineskip to the value of \meta{skip expression}, appending a default unit of \unit{pt}.
-Adding the optional star instead increases the current font baselineskip by the result of \meta{skip expression}, appending a default unit of \unit{pt}.
+Adding the optional star instead sets the font baselineskip equal to the current font baselineskip + the result of \meta{skip expression}, appending a default unit of \unit{pt}.
Does not change the font size.
Does nothing, except issue a warning, if used in math mode.
@@ -371,10 +357,9 @@
\cs{PrintFontSizeCommand}
\KeepNextPar*
-Tests if the current font size and current font baselineskip equal the font size and font baselineskip, respectively, of any font size command from \cs{tiny} to \cs{Huge}.
+Tests if the current font size equals the font size of any font size command from \cs{tiny} to \cs{Huge}.
If so, prints the name of that font size command, including the backslash character.
If not, prints \enquote{\string\undefined}.
-This package also provides a similar command \cs{CurrentFontSizeCommand}, which is expandable and omits the backslash character (\S\ref{subsec:expandable}).
\section{Programming}
@@ -399,8 +384,8 @@
This package does not define any public \pkg{expl3} functions.
This package defines public \pkg{expl3} variables that store the font step, font scale, font size, and font baselineskip of each font size command from \cs{tiny} to \cs{Huge}.
-These variables should never be modified directly.
-Their values should be changed only by \cs{fontscalesetup}.
+These variables, excluding the constants, are set by \cs{fontscalesetup}.
+They should never be modified directly.
Each takes the form:
@@ -416,5 +401,19 @@
\cs{l_fontscale_normalsize_scale_fp} is not defined.
The font scale of \cs{normalsize} is stored in \cs{c_fontscale_normalsize_scale_fp}.
+This package also defines public \pkg{expl3} variables that store the current font step, font scale, font size, and font baselineskip.
+These variables are set in the \texttt{selectfont} hook.
+They should never be modified directly.
+\cs{l_fontscale_step_fp}
+\nopagebreak\newline
+\cs{l_fontscale_scale_fp}
+\newline
+\cs{l_fontscale_size_dim}
+\nopagebreak\newline
+\cs{l_fontscale_baselineskip_skip}
+
+\cs{l_fontscale_step_fp} equals \texttt{nan} (not a number) if the current font step is undefined (as explained for \cs{CurrentFontStep} in \S\ref{subsec:expandable}).
+
+
\end{document}
\ No newline at end of file
Modified: trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty 2024-10-06 13:20:37 UTC (rev 72478)
+++ trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty 2024-10-06 19:51:00 UTC (rev 72479)
@@ -8,8 +8,8 @@
\NeedsTeXFormat{LaTeX2e}[2023-11-01]
\ProvidesExplPackage
{fontscale}
- {2024-09-10}
- {2.4.0}
+ {2024-10-05}
+ {3.0.0}
{A flexible interface for setting font sizes}
% l3kernel version 2023-10-10 added many 'e'-variants.
@@ -26,8 +26,11 @@
% This package does not require any other packages!
-% DECLARE FONT SIZE PARAMETER VARIABLES
+% SOME VARIABLES
+% Declares and initializes the font step, font scale, font size, and font
+% baselineskip of each font size command from \tiny to \Huge.
+
\fp_const:Nn \c_fontscale_tiny_step_fp { -4 }
\fp_const:Nn \c_fontscale_scriptsize_step_fp { -3 }
\fp_const:Nn \c_fontscale_footnotesize_step_fp { -2 }
@@ -73,8 +76,6 @@
\skip_new:N \l_fontscale_huge_baselineskip_skip
\skip_new:N \l_fontscale_Huge_baselineskip_skip
-% INITIALIZE FONT SIZE PARAMETER VARIABLES
-
\fp_set:Nn \l_fontscale_tiny_scale_fp { 0.6 }
\fp_set:Nn \l_fontscale_scriptsize_scale_fp { 0.7 }
\fp_set:Nn \l_fontscale_footnotesize_scale_fp { 0.8 }
@@ -107,17 +108,121 @@
\skip_set:Nn \l_fontscale_huge_baselineskip_skip { 19.2pt }
\skip_set:Nn \l_fontscale_Huge_baselineskip_skip { 21.6pt }
-% SOME VARIABLES
+% Stores the current font step, font scale, font size, and font baselineskip.
+% They are set in the selectfont hook.
+\fp_new:N \l_fontscale_step_fp
+\fp_new:N \l_fontscale_scale_fp
+\dim_new:N \l_fontscale_size_dim
+\skip_new:N \l_fontscale_baselineskip_skip
-% Used to speed up floating point calculations.
+% For speed, \__fontscale_hook_selectfont: tries to avoid computing a floating
+% point expression by using \fp_set_eq:NN when the font size equals the font
+% size of any font size command from \tiny to \Huge. The case when the font
+% size equals that of \normalsize is optimized further because it is by far
+% the most common case.
+\hook_gput_code:nnn { selectfont } { fontscale }
+ { \__fontscale_hook_selectfont: }
+\cs_new_protected:Npn \__fontscale_hook_selectfont:
+ {
+ \dim_set:Nn \l_fontscale_size_dim { \f at size pt }
+ \skip_set:Nn \l_fontscale_baselineskip_skip { \f at baselineskip }
+ \dim_compare:nNnTF \l_fontscale_size_dim = \l_fontscale_normalsize_size_dim
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_normalsize_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp \c_fontscale_normalsize_scale_fp
+ }
+ { \__fontscale_hook_selectfont_auxi: }
+ }
+\cs_new_protected:Npn \__fontscale_hook_selectfont_auxi:
+ {
+ \dim_case:nnF { \l_fontscale_size_dim }
+ {
+ { \l_fontscale_small_size_dim }
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_small_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp \l_fontscale_small_scale_fp
+ }
+ { \l_fontscale_large_size_dim }
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_large_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp \l_fontscale_large_scale_fp
+ }
+ { \l_fontscale_footnotesize_size_dim }
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_footnotesize_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp
+ \l_fontscale_footnotesize_scale_fp
+ }
+ { \l_fontscale_Large_size_dim }
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_Large_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp \l_fontscale_Large_scale_fp
+ }
+ { \l_fontscale_scriptsize_size_dim }
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_scriptsize_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp \l_fontscale_scriptsize_scale_fp
+ }
+ { \l_fontscale_LARGE_size_dim }
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_LARGE_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp \l_fontscale_LARGE_scale_fp
+ }
+ { \l_fontscale_tiny_size_dim }
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_tiny_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp \l_fontscale_tiny_scale_fp
+ }
+ { \l_fontscale_huge_size_dim }
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_huge_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp \l_fontscale_huge_scale_fp
+ }
+ { \l_fontscale_Huge_size_dim }
+ {
+ \fp_set_eq:NN \l_fontscale_step_fp \c_fontscale_Huge_step_fp
+ \fp_set_eq:NN \l_fontscale_scale_fp \l_fontscale_Huge_scale_fp
+ }
+ }
+ { \__fontscale_hook_selectfont_auxii: }
+ }
+% For speed, \f at size is used here instead of \l_fontscale_size_dim. The case
+% where the base font size of the musical typographic scale equals the font
+% size of \normalsize is optimized further.
+\cs_new_protected:Npn \__fontscale_hook_selectfont_auxii:
+ {
+ \fp_set:Nn \l_fontscale_scale_fp
+ { \f at size / \l__fontscale_normalsize_size_fp }
+ \str_if_eq:VnTF \l__fontscale_typographic_scale_str { musical }
+ {
+ \dim_compare:nNnTF \l__fontscale_musical_base_dim =
+ \l_fontscale_normalsize_size_dim
+ {
+ \fp_set:Nn \l_fontscale_step_fp
+ {
+ \l__fontscale_musical_selectfont_fp
+ * ln ( \l_fontscale_scale_fp )
+ }
+ }
+ {
+ \fp_set:Nn \l_fontscale_step_fp
+ {
+ \l__fontscale_musical_selectfont_fp
+ * ln ( \f at size / \l__fontscale_musical_base_fp )
+ }
+ }
+ }
+ { \fp_set_eq:NN \l_fontscale_step_fp \c_nan_fp }
+ }
+
+% Used only to speed up floating point calculations.
\fp_new:N \l__fontscale_normalsize_size_fp
\fp_set:Nn \l__fontscale_normalsize_size_fp { 10 }
\fp_new:N \l__fontscale_musical_base_fp
\fp_new:N \l__fontscale_musical_notes_fp
+\fp_new:N \l__fontscale_musical_selectfont_fp
% Scratch variables
-\tl_new:N \l__fontscale_tmp_tl
-\str_new:N \l__fontscale_tmp_str
\dim_new:N \l__fontscale_tmp_dim
\skip_new:N \l__fontscale_tmp_skip
\fp_new:N \l__fontscale_tmp_fp
@@ -127,7 +232,7 @@
% Variants of l3kernel functions
\cs_generate_variant:Nn \msg_error:nnnn { nnv , nne }
% Sets a dimen/skip variable from a dimen/skip expression, appending a default
-% unit of pt. This also removes extra tokens.
+% unit of pt. This also removes any extra tokens.
\cs_new_protected:Npn \__fontscale_dim_set_default_pt:Nn #1#2
{
\afterassignment \use_none_delimit_by_q_stop:w
@@ -142,56 +247,59 @@
\q_stop
}
\cs_generate_variant:Nn \__fontscale_skip_set_default_pt:Nn { c }
+% Argument processors. A default 'pt' is appended only in user-level commands,
+% not in internal programming functions.
+\cs_new_protected:Npn \__fontscale_arg_to_dim_default_pt:n #1
+ {
+ \__fontscale_dim_set_default_pt:Nn \l__fontscale_tmp_dim {#1}
+ \tl_set:NV \ProcessedArgument \l__fontscale_tmp_dim
+ }
+\cs_new_protected:Npn \__fontscale_arg_to_skip_default_pt:n #1
+ {
+ \__fontscale_skip_set_default_pt:Nn \l__fontscale_tmp_skip {#1}
+ \tl_set:NV \ProcessedArgument \l__fontscale_tmp_skip
+ }
% Used to define \tiny to \Huge. Sets \@currsize only for compatibility. Need
% \dim_use:N only for compatibility with the microtype package.
-\cs_new_protected:Npn \__fontscale_fontsize:NNN #1#2#3
+\cs_new_protected:Npn \__fontscale_name:NNN #1#2#3
{
\cs_set_eq:NN \@currsize #1
\fontsize { \dim_use:N #2 } #3 \selectfont
}
% Similar to \fontsize + \selectfont, except that it:
-% (1) Takes dimen and skip expressions as arguments.
+% (1) Takes dimen and skip expressions as arguments without appending a default
+% unit of pt.
% (2) Avoids the issue where \f at size is set to the new font size before the
% second argument is expanded.
% (3) Issues a user-friendly error message if the font size is not a positive
% length.
-\dim_new:N \l__fontscale_fontsize_dim
-\skip_new:N \l__fontscale_fontsize_skip
-\cs_new_protected:Npn \__fontscale_fontsize:nn #1#2
+\cs_new_protected:Npn \__fontscale_set_font_size:nn #1#2
{
- \__fontscale_dim_set_default_pt:Nn \l__fontscale_fontsize_dim {#1}
- \__fontscale_skip_set_default_pt:Nn \l__fontscale_fontsize_skip {#2}
- \dim_compare:nNnTF \l__fontscale_fontsize_dim > \c_zero_dim
+ \use:e
{
- \fontsize \l__fontscale_fontsize_dim \l__fontscale_fontsize_skip
- \selectfont
+ \__fontscale_set_font_size_aux:nn { \dim_eval:n {#1} }
+ { \skip_eval:n {#2} }
}
- {
- \msg_error:nnV { fontscale } { font-size-out-of-bounds }
- \l__fontscale_fontsize_dim
- }
}
-% Similar to the above function, except that it sets the font baselineskip
-% equal to the new font size times the baselineskip-size-ratio.
-\cs_new_protected:Npn \__fontscale_fontsize:n #1
+\cs_new_protected:Npn \__fontscale_set_font_size_aux:nn #1#2
{
- \__fontscale_dim_set_default_pt:Nn \l__fontscale_fontsize_dim {#1}
- \dim_compare:nNnTF \l__fontscale_fontsize_dim > \c_zero_dim
+ \dim_compare:nNnTF {#1} > \c_zero_dim
+ { \fontsize {#1} {#2} \selectfont }
+ { \msg_error:nnn { fontscale } { font-size-out-of-bounds } {#1} }
+ }
+% Similar to \__fontscale_set_font_size:nn, except that it sets the font
+% baselineskip equal to the new font size times the baselineskip-size-ratio.
+\cs_new_protected:Npn \__fontscale_set_font_size:n #1
+ { \use:e { \__fontscale_set_font_size_aux:n { \dim_to_decimal:n {#1} } } }
+\cs_new_protected:Npn \__fontscale_set_font_size_aux:n #1
+ {
+ \dim_compare:nNnTF { #1 pt } > \c_zero_dim
{
- \fontsize \l__fontscale_fontsize_dim
- {
- \fp_to_dim:n
- {
- \l__fontscale_fontsize_dim
- * \l__fontscale_baselineskip_size_ratio_fp
- }
- }
+ \fontsize { #1 pt }
+ { \fp_to_dim:n { #1 * \l__fontscale_baselineskip_size_ratio_fp } }
\selectfont
}
- {
- \msg_error:nnV { fontscale } { font-size-out-of-bounds }
- \l__fontscale_fontsize_dim
- }
+ { \msg_error:nnn { fontscale } { font-size-out-of-bounds } { #1 pt } }
}
% MESSAGES
@@ -247,12 +355,13 @@
\msg_new:nnn { fontscale } { font-step-out-of-bounds }
{
Invalid~ font~ step~ '#1'~ \msg_line_context:. \\
- The~ font~ step~ must~ equal~ an~ integer~ from~ -4~ to~ 5,~
+ The~ font~ step~ must~ equal~ the~ font~ step~ of~
+ any~ font~ size~ command~ from~ \iow_char:N \\tiny~ to~ \iow_char:N \\Huge~
unless~ the~ value~ of~ the~ key~ 'typographic-scale'~ is~ 'musical'.
}
\msg_new:nnn { fontscale } { current-font-step-out-of-bounds }
{
- '\iow_char:N \\SetFontStep*'~ could~ not~ calculate~ the~ new~ font~ step~
+ The~ new~ font~ step~ could~ not~ be~ calculated~
because~ the~ current~ font~ step~ is~ undefined~ \msg_line_context:.
}
@@ -448,8 +557,6 @@
, Huge .value_required:n = true
}
-% INITIALIZE AND PRE-COMPILE KEYS
-
% Pre-compiles the keys with their initial values and then sets the keys to
% their initial values. This is significantly faster than using .initial:n and
% \keys_precompile:nnN.
@@ -514,6 +621,8 @@
{ \__fontscale_keys_set:n {#2} }
}
}
+\cs_new_protected:Npn \__fontscale_keys_reset:n
+ { \__fontscale_keys_set_initial: \__fontscale_keys_set:n }
\cs_new_protected:Npn \__fontscale_keys_set:n #1
{
\keys_set:nn { fontscale } {#1}
@@ -522,8 +631,6 @@
\prg_break:
\prg_break_point:
}
-\cs_new_protected:Npn \__fontscale_keys_reset:n
- { \__fontscale_keys_set_initial: \__fontscale_keys_set:n }
\cs_new_protected:Npn \__fontscale_keys_process:
{
\__fontscale_keys_process_start:
@@ -682,6 +789,11 @@
{ \l__fontscale_musical_base_dim }
\fp_set:Nn \l__fontscale_musical_notes_fp
{ \l__fontscale_musical_notes_int }
+ \fp_set:Nn \l__fontscale_musical_selectfont_fp
+ {
+ \l__fontscale_musical_notes_fp
+ / ln ( \l__fontscale_musical_ratio_fp )
+ }
}
}
\tl_map_function:nN
@@ -737,20 +849,25 @@
{ \__fontscale_keys_process_other_fn_aux:n {#1} }
\prg_break:
\prg_break_point:
- \fp_set:cn { l_fontscale_#1_scale_fp }
- { \use:c { l_fontscale_#1_size_dim } / \l__fontscale_normalsize_size_fp }
\quark_if_no_value:cTF { l__fontscale_#1_baselineskip_tl }
{
+ \fp_set:Nn \l__fontscale_tmp_fp { \use:c { l_fontscale_#1_size_dim } }
+ \fp_set:cn { l_fontscale_#1_scale_fp }
+ { \l__fontscale_tmp_fp / \l__fontscale_normalsize_size_fp }
\skip_set:cn { l_fontscale_#1_baselineskip_skip }
{
\fp_to_dim:n
{
- \use:c { l_fontscale_#1_size_dim }
- * \l__fontscale_baselineskip_size_ratio_fp
+ \l__fontscale_tmp_fp * \l__fontscale_baselineskip_size_ratio_fp
}
}
}
{
+ \fp_set:cn { l_fontscale_#1_scale_fp }
+ {
+ \use:c { l_fontscale_#1_size_dim }
+ / \l__fontscale_normalsize_size_fp
+ }
\__fontscale_skip_set_default_pt:cn
{ l_fontscale_#1_baselineskip_skip }
{ \use:c { l__fontscale_#1_baselineskip_tl } }
@@ -792,7 +909,7 @@
}
\cs_new_protected:Npn \__fontscale_tiny:
{
- \__fontscale_fontsize:NNN \tiny \l_fontscale_tiny_size_dim
+ \__fontscale_name:NNN \tiny \l_fontscale_tiny_size_dim
\l_fontscale_tiny_baselineskip_skip
}
\DeclareDocumentCommand \scriptsize { }
@@ -806,7 +923,7 @@
}
\cs_new_protected:Npn \__fontscale_scriptsize:
{
- \__fontscale_fontsize:NNN \scriptsize \l_fontscale_scriptsize_size_dim
+ \__fontscale_name:NNN \scriptsize \l_fontscale_scriptsize_size_dim
\l_fontscale_scriptsize_baselineskip_skip
}
\DeclareDocumentCommand \footnotesize { }
@@ -820,7 +937,7 @@
}
\cs_new_protected:Npn \__fontscale_footnotesize:
{
- \__fontscale_fontsize:NNN \footnotesize \l_fontscale_footnotesize_size_dim
+ \__fontscale_name:NNN \footnotesize \l_fontscale_footnotesize_size_dim
\l_fontscale_footnotesize_baselineskip_skip
}
\DeclareDocumentCommand \small { }
@@ -834,7 +951,7 @@
}
\cs_new_protected:Npn \__fontscale_small:
{
- \__fontscale_fontsize:NNN \small \l_fontscale_small_size_dim
+ \__fontscale_name:NNN \small \l_fontscale_small_size_dim
\l_fontscale_small_baselineskip_skip
}
\DeclareDocumentCommand \normalsize { }
@@ -848,7 +965,7 @@
}
\cs_new_protected:Npn \__fontscale_normalsize:
{
- \__fontscale_fontsize:NNN \normalsize \l_fontscale_normalsize_size_dim
+ \__fontscale_name:NNN \normalsize \l_fontscale_normalsize_size_dim
\l_fontscale_normalsize_baselineskip_skip
}
\DeclareDocumentCommand \large { }
@@ -862,7 +979,7 @@
}
\cs_new_protected:Npn \__fontscale_large:
{
- \__fontscale_fontsize:NNN \large \l_fontscale_large_size_dim
+ \__fontscale_name:NNN \large \l_fontscale_large_size_dim
\l_fontscale_large_baselineskip_skip
}
\DeclareDocumentCommand \Large { }
@@ -876,7 +993,7 @@
}
\cs_new_protected:Npn \__fontscale_Large:
{
- \__fontscale_fontsize:NNN \Large \l_fontscale_Large_size_dim
+ \__fontscale_name:NNN \Large \l_fontscale_Large_size_dim
\l_fontscale_Large_baselineskip_skip
}
\DeclareDocumentCommand \LARGE { }
@@ -890,7 +1007,7 @@
}
\cs_new_protected:Npn \__fontscale_LARGE:
{
- \__fontscale_fontsize:NNN \LARGE \l_fontscale_LARGE_size_dim
+ \__fontscale_name:NNN \LARGE \l_fontscale_LARGE_size_dim
\l_fontscale_LARGE_baselineskip_skip
}
\DeclareDocumentCommand \huge { }
@@ -904,7 +1021,7 @@
}
\cs_new_protected:Npn \__fontscale_huge:
{
- \__fontscale_fontsize:NNN \huge \l_fontscale_huge_size_dim
+ \__fontscale_name:NNN \huge \l_fontscale_huge_size_dim
\l_fontscale_huge_baselineskip_skip
}
\DeclareDocumentCommand \Huge { }
@@ -918,7 +1035,7 @@
}
\cs_new_protected:Npn \__fontscale_Huge:
{
- \__fontscale_fontsize:NNN \Huge \l_fontscale_Huge_size_dim
+ \__fontscale_name:NNN \Huge \l_fontscale_Huge_size_dim
\l_fontscale_Huge_baselineskip_skip
}
\normalsize
@@ -925,103 +1042,19 @@
\NewExpandableDocumentCommand \CurrentFontStep { } { \__fontscale_step: }
\cs_new:Npn \__fontscale_step:
- {
- \dim_case:nnF { \f at size pt }
- {
- { \l_fontscale_tiny_size_dim } { -4 }
- { \l_fontscale_scriptsize_size_dim } { -3 }
- { \l_fontscale_footnotesize_size_dim } { -2 }
- { \l_fontscale_small_size_dim } { -1 }
- { \l_fontscale_normalsize_size_dim } { 0 }
- { \l_fontscale_large_size_dim } { 1 }
- { \l_fontscale_Large_size_dim } { 2 }
- { \l_fontscale_LARGE_size_dim } { 3 }
- { \l_fontscale_huge_size_dim } { 4 }
- { \l_fontscale_Huge_size_dim } { 5 }
- }
- {
- \str_if_eq:VnT \l__fontscale_typographic_scale_str { musical }
- {
- \fp_eval:n
- {
- \l__fontscale_musical_notes_fp
- * ln ( \f at size / \l__fontscale_musical_base_fp )
- / ln ( \l__fontscale_musical_ratio_fp )
- }
- }
- }
- }
+ { \fp_if_nan:nF { \l_fontscale_step_fp } { \fp_use:N \l_fontscale_step_fp } }
\NewExpandableDocumentCommand \CurrentFontScale { } { \__fontscale_scale: }
-\cs_new:Npn \__fontscale_scale:
- { \fp_eval:n { \f at size / \l__fontscale_normalsize_size_fp } }
+\cs_new:Npn \__fontscale_scale: { \fp_use:N \l_fontscale_scale_fp }
\NewExpandableDocumentCommand \CurrentFontSize { } { \__fontscale_size: }
-\cs_new:Npn \__fontscale_size: { \f at size pt }
+\cs_new:Npn \__fontscale_size: { \dim_use:N \l_fontscale_size_dim }
\NewExpandableDocumentCommand \CurrentFontBaselineskip { }
{ \__fontscale_baselineskip: }
-\cs_new:Npn \__fontscale_baselineskip: { \f at baselineskip }
+\cs_new:Npn \__fontscale_baselineskip:
+ { \skip_use:N \l_fontscale_baselineskip_skip }
-\NewExpandableDocumentCommand \CurrentFontSizeCommand { }
- { \__fontscale_name: }
-\cs_new:Npn \__fontscale_name:
- {
- \dim_case:nn { \f at size pt }
- {
- { \l_fontscale_tiny_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_tiny_baselineskip_skip }
- { \f at baselineskip } { tiny }
- }
- { \l_fontscale_scriptsize_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_scriptsize_baselineskip_skip }
- { \f at baselineskip } { scriptsize }
- }
- { \l_fontscale_footnotesize_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_footnotesize_baselineskip_skip }
- { \f at baselineskip } { footnotesize }
- }
- { \l_fontscale_small_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_small_baselineskip_skip }
- { \f at baselineskip } { small }
- }
- { \l_fontscale_normalsize_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_normalsize_baselineskip_skip }
- { \f at baselineskip } { normalsize }
- }
- { \l_fontscale_large_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_large_baselineskip_skip }
- { \f at baselineskip } { large }
- }
- { \l_fontscale_Large_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_Large_baselineskip_skip }
- { \f at baselineskip } { Large }
- }
- { \l_fontscale_LARGE_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_LARGE_baselineskip_skip }
- { \f at baselineskip } { LARGE }
- }
- { \l_fontscale_huge_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_huge_baselineskip_skip }
- { \f at baselineskip } { huge }
- }
- { \l_fontscale_Huge_size_dim }
- {
- \skip_if_eq:nnT { \l_fontscale_Huge_baselineskip_skip }
- { \f at baselineskip } { Huge }
- }
- }
- }
-
\NewDocumentCommand \SetFontStep { s m }
{
\mode_if_math:TF
@@ -1035,11 +1068,18 @@
{ \__fontscale_set_font_step:n {#2} }
}
}
+\cs_new_protected:Npn \__fontscale_add_font_step:n #1
+ {
+ \fp_if_nan:nTF { \l_fontscale_step_fp }
+ { \msg_error:nn { fontscale } { current-font-step-out-of-bounds } }
+ { \__fontscale_set_font_step:n { (#1) + \l_fontscale_step_fp } }
+ }
% Using \str_case: here is significantly faster (and easier to write) than
% repeatedly testing \fp_compare:.
\cs_new_protected:Npn \__fontscale_set_font_step:n #1
{
- \str_case:enF { \fp_eval:n {#1} }
+ \fp_set:Nn \l__fontscale_tmp_fp { round ( #1 , 5 ) }
+ \str_case:enF { \fp_use:N \l__fontscale_tmp_fp }
{
{ -4 } { \tiny }
{ -3 } { \scriptsize }
@@ -1055,30 +1095,22 @@
{
\str_if_eq:VnTF \l__fontscale_typographic_scale_str { musical }
{
- \__fontscale_fontsize:n
+ \__fontscale_set_font_size:n
{
\fp_to_dim:n
{
\l__fontscale_musical_base_fp
* \l__fontscale_musical_ratio_fp
- ^ ( (#1) / \l__fontscale_musical_notes_fp )
+ ^ ( \l__fontscale_tmp_fp / \l__fontscale_musical_notes_fp )
}
}
}
{
\msg_error:nne { fontscale } { font-step-out-of-bounds }
- { \fp_eval:n {#1} }
+ { \fp_use:N \l__fontscale_tmp_fp }
}
}
}
-\cs_new_protected:Npn \__fontscale_add_font_step:n #1
- {
- \tl_set:Ne \l__fontscale_tmp_tl { \__fontscale_step: }
- \tl_if_empty:NTF \l__fontscale_tmp_tl
- { \msg_error:nn { fontscale } { current-font-step-out-of-bounds } }
- { \__fontscale_add_font_step_aux:n { (#1) + \l__fontscale_tmp_tl } }
- }
-\cs_new_eq:NN \__fontscale_add_font_step_aux:n \__fontscale_set_font_step:n
\NewDocumentCommand \SetFontScale { s m }
{
@@ -1093,18 +1125,16 @@
{ \__fontscale_set_font_scale:n {#2} }
}
}
+\cs_new_protected:Npn \__fontscale_add_font_scale:n #1
+ { \__fontscale_set_font_scale:n { (#1) + \l_fontscale_scale_fp } }
\cs_new_protected:Npn \__fontscale_set_font_scale:n #1
{
- \__fontscale_fontsize:n
- { \fp_to_dim:n { \l__fontscale_normalsize_size_fp * (#1) } }
+ \__fontscale_set_font_size:n
+ { \fp_to_dim:n { (#1) * \l__fontscale_normalsize_size_fp } }
}
-\cs_new_protected:Npn \__fontscale_add_font_scale:n #1
- {
- \__fontscale_fontsize:n
- { \fp_to_dim:n { \l__fontscale_normalsize_size_fp * (#1) + \f at size } }
- }
-\NewDocumentCommand \SetFontSize { s m }
+\NewDocumentCommand \SetFontSize
+ { s >{ \__fontscale_arg_to_dim_default_pt:n } m }
{
\mode_if_math:TF
{
@@ -1117,12 +1147,8 @@
{ \__fontscale_set_font_size:n {#2} }
}
}
-\cs_new_eq:NN \__fontscale_set_font_size:n \__fontscale_fontsize:n
\cs_new_protected:Npn \__fontscale_add_font_size:n #1
- {
- \__fontscale_dim_set_default_pt:Nn \l__fontscale_tmp_dim {#1}
- \__fontscale_fontsize:n { \l__fontscale_tmp_dim + \f at size pt }
- }
+ { \__fontscale_set_font_size:n { (#1) + \l_fontscale_size_dim } }
\NewDocumentCommand \ScaleFont { m }
{
@@ -1136,27 +1162,29 @@
\cs_new_protected:Npn \__fontscale_scale_font:n #1
{
\fp_set:Nn \l__fontscale_tmp_fp {#1}
- \__fontscale_fontsize:nn
- { \fp_to_dim:n { \f at size * \l__fontscale_tmp_fp } }
+ \__fontscale_set_font_size:nn
+ { \fp_to_dim:n { \l__fontscale_tmp_fp * \l_fontscale_size_dim } }
{
- \fp_to_dim:n
- { \dim_to_fp:n { \f at baselineskip } * \l__fontscale_tmp_fp }
+ \fp_to_dim:n { \l__fontscale_tmp_fp * \l_fontscale_baselineskip_skip }
}
}
-\NewDocumentCommand \SetFontSizeBaselineskip { m m }
+\NewDocumentCommand \SetFontSizeBaselineskip
{
+ >{ \__fontscale_arg_to_dim_default_pt:n } m
+ >{ \__fontscale_arg_to_skip_default_pt:n } m
+ }
+ {
\mode_if_math:TF
{
\msg_warning:nne { fontscale } { math-mode-warning }
{ \token_to_str:N \SetFontSizeBaselineskip }
}
- { \__fontscale_set_font_size_baselineskip:nn {#1} {#2} }
+ { \__fontscale_set_font_size:nn {#1} {#2} }
}
-\cs_new_eq:NN \__fontscale_set_font_size_baselineskip:nn
- \__fontscale_fontsize:nn
-\NewDocumentCommand \SetFontBaselineskip { s m }
+\NewDocumentCommand \SetFontBaselineskip
+ { s >{ \__fontscale_arg_to_skip_default_pt:n } m }
{
\mode_if_math:TF
{
@@ -1169,14 +1197,13 @@
{ \__fontscale_set_font_baselineskip:n {#2} }
}
}
-\cs_new_protected:Npn \__fontscale_set_font_baselineskip:n
- { \__fontscale_fontsize:nn { \f at size pt } }
\cs_new_protected:Npn \__fontscale_add_font_baselineskip:n #1
{
- \__fontscale_skip_set_default_pt:Nn \l__fontscale_tmp_skip {#1}
- \__fontscale_fontsize:nn { \f at size pt }
- { \l__fontscale_tmp_skip + \f at baselineskip }
+ \__fontscale_set_font_baselineskip:n
+ { (#1) + \l_fontscale_baselineskip_skip }
}
+\cs_new_protected:Npn \__fontscale_set_font_baselineskip:n
+ { \__fontscale_set_font_size:nn { \l_fontscale_size_dim } }
\NewDocumentCommand \PrintFontSizeParameters { }
{ \__fontscale_print_font_size_parameters: }
@@ -1215,7 +1242,7 @@
}
}
-\NewDocumentCommand \PrintSampleText { s +m }
+\NewDocumentCommand \PrintSampleText { >{ \ReverseBoolean } s +m }
{
\mode_if_math:TF
{
@@ -1223,30 +1250,32 @@
{ \token_to_str:N \PrintSampleText }
}
{
- \group_begin:
- \IfBooleanTF #1
- { \__fontscale_print_sample_text_descending_order:n {#2} }
- { \__fontscale_print_sample_text_ascending_order:n {#2} }
- \group_end:
+ \IfBooleanTF #1
+ { \__fontscale_print_sample_text_ascending_order:n {#2} }
+ { \__fontscale_print_sample_text_descending_order:n {#2} }
}
}
\cs_new_protected:Npn \__fontscale_print_sample_text_ascending_order:n #1
{
- \tl_map_inline:nn
- {
- \tiny \scriptsize \footnotesize \small \normalsize
- \large \Large \LARGE \huge \Huge
- }
- { ##1 #1 \par }
+ \group_begin:
+ \tl_map_inline:nn
+ {
+ \tiny \scriptsize \footnotesize \small \normalsize
+ \large \Large \LARGE \huge \Huge
+ }
+ { ##1 #1 \par }
+ \group_end:
}
\cs_new_protected:Npn \__fontscale_print_sample_text_descending_order:n #1
{
- \tl_map_inline:nn
- {
- \Huge \huge \LARGE \Large \large
- \normalsize \small \footnotesize \scriptsize \tiny
- }
- { ##1 #1 \par }
+ \group_begin:
+ \tl_map_inline:nn
+ {
+ \Huge \huge \LARGE \Large \large
+ \normalsize \small \footnotesize \scriptsize \tiny
+ }
+ { ##1 #1 \par }
+ \group_end:
}
\NewDocumentCommand \PrintFontSizeCommand { }
@@ -1260,10 +1289,24 @@
}
\cs_new_protected:Npn \__fontscale_print_name:
{
- \str_set:Ne \l__fontscale_tmp_str { \__fontscale_name: }
- \str_if_empty:NTF \l__fontscale_tmp_str
- { \token_to_str:N \undefined }
- { \c_backslash_str \l__fontscale_tmp_str \@ }
+ \token_to_str:c
+ {
+ \dim_case:nnF { \l_fontscale_size_dim }
+ {
+ { \l_fontscale_tiny_size_dim } { tiny }
+ { \l_fontscale_scriptsize_size_dim } { scriptsize }
+ { \l_fontscale_footnotesize_size_dim } { footnotesize }
+ { \l_fontscale_small_size_dim } { small }
+ { \l_fontscale_normalsize_size_dim } { normalsize }
+ { \l_fontscale_large_size_dim } { large }
+ { \l_fontscale_Large_size_dim } { Large }
+ { \l_fontscale_LARGE_size_dim } { LARGE }
+ { \l_fontscale_huge_size_dim } { huge }
+ { \l_fontscale_Huge_size_dim } { Huge }
+ }
+ { undefined }
+ }
+ \@
}
% TEXT PURIFY
@@ -1271,7 +1314,10 @@
\NewExpandableDocumentCommand \__fontscale_use_none_sm:w { s m } { }
\tl_map_inline:nn
{
- \fontscalesetup \SetFontStep \SetFontScale \SetFontSize
+ \fontscalesetup
+ \SetFontStep
+ \SetFontScale
+ \SetFontSize
\SetFontBaselineskip
}
{ \text_declare_purify_equivalent:Nn #1 { \__fontscale_use_none_sm:w } }
More information about the tex-live-commits
mailing list.