texlive[73289] Master/texmf-dist: fontscale (3jan25)

commits+karl at tug.org commits+karl at tug.org
Fri Jan 3 23:50:15 CET 2025


Revision: 73289
          https://tug.org/svn/texlive?view=revision&revision=73289
Author:   karl
Date:     2025-01-03 23:50:15 +0100 (Fri, 03 Jan 2025)
Log Message:
-----------
fontscale (3jan25)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/fontscale/CHANGELOG.md
    trunk/Master/texmf-dist/doc/latex/fontscale/README.txt
    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	2025-01-03 22:50:06 UTC (rev 73288)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/CHANGELOG.md	2025-01-03 22:50:15 UTC (rev 73289)
@@ -7,6 +7,23 @@
 
 ## [Unreleased]
 
+## [v3.0.5] - 2025-01-03
+
+### Changed
+- Clarified some package functionalities in the documentation:
+  - The new font baselineskip set by `\ScaleFont` has no stretch and shrink
+    components.
+  - `\ScaleFont` is intended as a more robust alternative to `\scalefont` from
+    the `scalefnt` package.
+  - `\SetFontSizeBaselineskip` is intended as a more robust alternative to
+    `\fontsize` + `\selectfont`.
+  - `\PrintAllFontSizeParameters`, `\PrintSampleText`, and
+    `\PrintFontSizeCommand` cannot be used in math mode.
+- Code improvements:
+  - The package messages are now defined first.
+  - The package now regularly uses `\dim_to_fp:n` when handling dimensions
+    within floating point expressions.
+
 ## [v3.0.4] - 2024-12-22
 
 ### Changed

Modified: trunk/Master/texmf-dist/doc/latex/fontscale/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/README.txt	2025-01-03 22:50:06 UTC (rev 73288)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/README.txt	2025-01-03 22:50:15 UTC (rev 73289)
@@ -1,5 +1,5 @@
 Package: fontscale -- A flexible interface for setting font sizes
-Copyright: 2024 (c) Oliver Beery <beeryoliver at gmail.com>
+Copyright: 2024-2025 (c) Oliver Beery <beeryoliver at gmail.com>
 CTAN: https://ctan.org/pkg/fontscale
 Repository: https://github.com/beeryoliver/fontscale
 License: The LaTeX Project Public License 1.3c

Modified: trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls	2025-01-03 22:50:06 UTC (rev 73288)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls	2025-01-03 22:50:15 UTC (rev 73289)
@@ -4,7 +4,7 @@
 \NeedsTeXFormat{LaTeX2e}[2023-11-01]
 \ProvidesExplClass
   {beery}
-  {2024-12-22}
+  {2025-01-03}
   {}
   {}
 
@@ -21,6 +21,8 @@
 \RequirePackage { csquotes }
 \RequirePackage { lmodern }
 
+\RequirePackage { scaletextbullet }
+
 \RequirePackage { tcolorbox }
 \tcbuselibrary { breakable }
 \NewTColorBox { mydisplaycode } { }
@@ -37,7 +39,8 @@
 
 \tl_const:Nn \c_beery_alphabet_tl { abcdefghijklmnopqrstuvwxyz }
 \NewExpandableDocumentCommand \alphabet { } { \c_beery_alphabet_tl }
-\NewDocumentCommand \Key { m o o }
+\NewDocumentCommand \Key
+  { >{ \TrimSpaces } m >{ \TrimSpaces } o >{ \TrimSpaces } o }
   {
     \mode_leave_vertical:
     \group_begin:
@@ -51,10 +54,12 @@
         { #1 $\,=\,$ #2 \hspace* { \fill } \hbox:n { initial $\,=\,$ #3 } }
     \group_end:
   }
-\NewDocumentCommand \Value { m } { \texttt {#1} }
-\NewDocumentCommand \cmd { m } { \texttt { \token_to_str:N #1 } \@ }
-\NewDocumentCommand \cs { m } { \texttt { \token_to_str:c {#1} } \@ }
-\NewDocumentCommand \marg { m }
+\NewDocumentCommand \Value { >{ \TrimSpaces } m } { \texttt {#1} }
+\NewDocumentCommand \cmd { >{ \TrimSpaces } m }
+  { \texttt { \token_to_str:N #1 } \@ }
+\NewDocumentCommand \cs { >{ \TrimSpaces } m }
+  { \texttt { \token_to_str:c {#1} } \@ }
+\NewDocumentCommand \marg { >{ \TrimSpaces } m }
   {
     \allowbreak
     \texttt { \c_left_brace_str }
@@ -63,7 +68,7 @@
     $\rangle$
     \texttt { \c_right_brace_str }
   }
-\NewDocumentCommand \oarg { m }
+\NewDocumentCommand \oarg { >{ \TrimSpaces } m }
   {
     \allowbreak
     \texttt { [ }
@@ -73,16 +78,16 @@
     \texttt { ] }
   }
 \NewDocumentCommand \sarg { } { $\langle$ \texttt {*} $\rangle$ }
-\NewDocumentCommand \meta { m }
+\NewDocumentCommand \meta { >{ \TrimSpaces } m }
   {
     $\langle$
     { \normalfont \itshape #1 }
     $\rangle$
   }
-\NewDocumentCommand \cls { m } { \textsf {#1} }
-\NewDocumentCommand \env { m } { \texttt {#1} }
-\NewDocumentCommand \pkg { m } { \textsf {#1} }
-\NewDocumentCommand \latin { m } { \textit {#1} }
+\NewDocumentCommand \cls { >{ \TrimSpaces } m } { \textsf {#1} }
+\NewDocumentCommand \env { >{ \TrimSpaces } m } { \texttt {#1} }
+\NewDocumentCommand \pkg { >{ \TrimSpaces } m } { \textsf {#1} }
+\NewDocumentCommand \latin { >{ \TrimSpaces } m } { \textit {#1} }
 
 % PAGE STYLE
 
@@ -91,13 +96,19 @@
 \dim_log:N \c_beery_alphabet_dim
 
 \dim_const:Nn \c_beery_big_dim { \l_fontscale_normalsize_baselineskip_skip }
-\dim_const:Nn \c_beery_medium_dim { \c_beery_big_dim / 2 }
-\dim_const:Nn \c_beery_small_dim  { \c_beery_big_dim / 4 }
+\dim_const:Nn \c_beery_medium_dim
+  { \fp_to_dim:n { \dim_to_fp:n { \c_beery_big_dim / 2 } } }
+\dim_const:Nn \c_beery_small_dim
+  { \fp_to_dim:n { \dim_to_fp:n { \c_beery_big_dim / 4 } } }
+\dim_log:N \c_beery_big_dim
+\dim_log:N \c_beery_medium_dim
+\dim_log:N \c_beery_small_dim
+
 \skip_const:Nn \c_beery_big_skip
   {
     \c_beery_big_dim
-    plus  \dim_eval:n { \c_beery_big_dim / 2 }
-    minus \dim_eval:n { \c_beery_big_dim / 3 }
+    plus  \fp_to_dim:n { \dim_to_fp:n { \c_beery_big_dim } / 2 }
+    minus \fp_to_dim:n { \dim_to_fp:n { \c_beery_big_dim } / 3 }
   }
 \skip_const:Nn \c_beery_medium_skip { \c_beery_big_skip / 2 }
 \skip_const:Nn \c_beery_small_skip  { \c_beery_big_skip / 4 }
@@ -104,6 +115,9 @@
 \skip_set_eq:NN \bigskipamount   \c_beery_big_skip
 \skip_set_eq:NN \medskipamount   \c_beery_medium_skip
 \skip_set_eq:NN \smallskipamount \c_beery_small_skip
+\skip_log:N \c_beery_big_skip
+\skip_log:N \c_beery_medium_skip
+\skip_log:N \c_beery_small_skip
 
 \raggedbottom
 \int_set:Nn \vbadness { 100 }
@@ -115,10 +129,10 @@
   {
       a4paper
     , textwidth =
-        \dim_eval:n { \fp_to_dim:n { \c_e_fp * \c_beery_alphabet_dim } }
+        \fp_to_dim:n { \c_e_fp * \dim_to_fp:n { \c_beery_alphabet_dim } }
     , textheight =
-        \dim_eval:n
-          { \fp_to_dim:n { 1.6180 * \c_e_fp * \c_beery_alphabet_dim } }
+        \fp_to_dim:n
+          { 1.6180 * \c_e_fp * \dim_to_fp:n { \c_beery_alphabet_dim } }
     , heightrounded
     , centering
     , headheight = \l_fontscale_footnotesize_baselineskip_skip
@@ -131,7 +145,7 @@
 \RequirePackage { fancyhdr }
 \pagestyle { fancy }
 \fancyhf { }
-\cs_set:Npn \headrulewidth { 0pt }
+\renewcommand \headrulewidth { 0pt }
 \fancyfoot [ C ]
   { \footnotesize \thepage \c_space_tl of~ \pageref { LastPage } }
 
@@ -139,8 +153,7 @@
 
 \nonfrenchspacing
 \linespread { 1 }
-\skip_set_eq:NN \parskip \c_beery_medium_skip
-\dim_zero:N \parindent
+\RequirePackage [ skip = \c_beery_medium_skip ] { parskip }
 \RequirePackage [ raggedrightboxes ] { ragged2e }
 \skip_set:Nn \RaggedRightRightskip { 0pt plus 0.5 \linewidth }
 \dim_zero:N \RaggedRightParindent
@@ -164,21 +177,19 @@
 \titlespacing* \section % section
   { 0pt } % indent
   {
-    - \parskip
-    + \c_beery_big_dim
-    plus  \fp_eval:n { 1 / 2 * 4 } \c_beery_big_dim
-    minus \fp_eval:n { 1 / 3 / 4 } \c_beery_big_dim
+    \c_beery_big_dim
+    plus  \fp_to_dim:n { 1 / 2 * 4 * \dim_to_fp:n { \c_beery_big_dim } }
+    minus \fp_to_dim:n { 1 / 3 / 4 * \dim_to_fp:n { \c_beery_big_dim } }
   } % before
-  { - \parskip + \c_beery_medium_skip } % after
+  { \c_beery_medium_skip } % after
 \titlespacing* \subsection
   { 0pt }
   {
-    - \parskip
-    + \fp_eval:n { 4 / 3 } \c_beery_medium_dim
-    plus  \fp_eval:n { 1 / 2 * 4 } \c_beery_medium_dim
-    minus \fp_eval:n { 1 / 3 / 4 } \c_beery_medium_dim
+    \fp_to_dim:n { 4 / 3 * \dim_to_fp:n { \c_beery_medium_dim } }
+    plus  \fp_to_dim:n { 1 / 2 * 4 * \dim_to_fp:n { \c_beery_medium_dim } }
+    minus \fp_to_dim:n { 1 / 3 / 4 * \dim_to_fp:n { \c_beery_medium_dim } }
   }
-  { - \parskip + \c_beery_medium_skip }
+  { \c_beery_medium_skip }
 
 \titleformat \section % section
   [ block ] % shape
@@ -210,7 +221,11 @@
     , itemsep   = 0pt
   }
 \setlist [ itemize   , 1 ] { label = \textbullet }
+\setlist [ itemize   , 2 ] { label = \ScaleTextBullets { 2 } }
+\setlist [ itemize   , 3 ] { label = \ScaleTextBullets { 3 } }
 \setlist [ enumerate , 1 ] { label = \arabic* . }
+\setlist [ enumerate , 2 ] { label = \theenumi  \arabic* . }
+\setlist [ enumerate , 3 ] { label = \theenumii \arabic* . }
 
 % list headings
 % https://tex.stackexchange.com/questions/2644/how-to-prevent-a-page-break-before-an-itemize-list
@@ -240,8 +255,9 @@
 \renewcommand \topfraction { 1 }
 \skip_set:Nn \textfloatsep
   {
-    \c_beery_big_dim plus \c_beery_big_dim minus
-    \dim_eval:n { \c_beery_big_dim / 3 }
+    \c_beery_big_dim
+    plus \c_beery_big_dim
+    minus \fp_to_dim:n { \dim_to_fp:n { \c_beery_big_dim } / 3 }
   }
 
 \RequirePackage { tabularray }
@@ -255,10 +271,14 @@
 \dim_set:Nn \footnotesep { \f at linespread \footnotesep }
 \coffin_new:N \l__beery_footnote_coffin
 % 1.2 = baselineskip-size-ratio
+% \f at linespread must not be empty here
 \dim_const:Nn \c_beery_footnote_baselineheight_dim
   {
     \fp_to_dim:n
-      { ( 1.2 * \f at linespread - 1 ) * \l_fontscale_footnotesize_size_dim }
+      {
+        ( 1.2 * \f at linespread - 1 )
+        * \dim_to_fp:n { \l_fontscale_footnotesize_size_dim }
+      }
   }
 \RenewDocumentCommand \@makefntext { +m }
   {
@@ -270,7 +290,8 @@
               {
                 \fp_to_dim:n
                   {
-                    ( 1 - \l_fontscale_footnotesize_scale_fp ) / 2 * \textwidth
+                    ( 1 - \l_fontscale_footnotesize_scale_fp ) / 2
+                    * \dim_to_fp:n { \textwidth }
                   }
               }
             \dim_set_eq:NN \rightmargin \leftmargin

Modified: trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex	2025-01-03 22:50:06 UTC (rev 73288)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex	2025-01-03 22:50:15 UTC (rev 73289)
@@ -1,4 +1,4 @@
-\ProvidesFile{fontscale-table-classic.tex}[2024-12-22]
+\ProvidesFile{fontscale-table-classic.tex}[2025-01-03]
 
 \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	2025-01-03 22:50:06 UTC (rev 73288)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-font-steps.tex	2025-01-03 22:50:15 UTC (rev 73289)
@@ -1,4 +1,4 @@
-\ProvidesFile{fontscale-table-font-steps.tex}[2024-12-22]
+\ProvidesFile{fontscale-table-font-steps.tex}[2025-01-03]
 
 \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	2025-01-03 22:50:06 UTC (rev 73288)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-musical.tex	2025-01-03 22:50:15 UTC (rev 73289)
@@ -1,4 +1,4 @@
-\ProvidesFile{fontscale-table-musical.tex}[2024-12-22]
+\ProvidesFile{fontscale-table-musical.tex}[2025-01-03]
 
 \begin{table}
   \centering

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	2025-01-03 22:50:06 UTC (rev 73288)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale.tex	2025-01-03 22:50:15 UTC (rev 73289)
@@ -14,7 +14,7 @@
 
 Oliver Beery
 
-Version 3.0.4\quad{}22 December 2024
+Version 3.0.5\quad{}3 January 2025
 
 
 \section{Introduction}
@@ -34,7 +34,7 @@
   \item
   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}).
+  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 robust 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} and the current font step, font scale, font size, and font baselineskip (\S\ref{subsec:publicexpl3}).
 \end{itemize}
@@ -63,7 +63,11 @@
 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{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:}
+\listheading
+  {
+    This package defines each font size command from \cs{tiny} to \cs{Huge} using \cs{fontsize} and \cs{selectfont}.
+    They have no additional functionality beyond that of \cs{fontsize} and \cs{selectfont}, except that they:
+  }
 \begin{itemize}
   \item
   Set the kernel command \cs{@currsize} equal to the font size command.
@@ -79,7 +83,7 @@
 \label{subsec:fontsizeparameters}
 
 When using the \pkg{fontscale} package, each font size, including the standard \LaTeX{} font size commands from \cs{tiny} to \cs{Huge}, has a font step, font scale, font size, and font baselineskip.
-The latter two parameters are the familiar first and second arguments to the low\-/level font command \cs{fontsize}\marg{dimen}\marg{skip}.
+The latter two parameters are the familiar first and second arguments to \cs{fontsize}\marg{dimen}\marg{skip}.
 (The font baselineskip, stored in the kernel command \cs{f at baselineskip}, should not be confused with the paragraph baselineskip \cs{baselineskip}.)
 The font scale and font step are different ways of describing the font size.
 The font scale is the relative font size; the ratio of the font size to \cs{normalsize}, which has a font scale of \num{1}.
@@ -116,11 +120,11 @@
 
 \begin{mydisplaycode}
   \Key{typographic-scale}
-    [%
+    [
       classic-10pt$\,\vert\,$\allowbreak
       classic-11pt$\,\vert\,$\allowbreak
       classic-12pt$\,\vert\,$\allowbreak\hspace*{1.5em}%
-      musical%
+      musical
     ]
     [classic-10pt]
   \newline
@@ -210,7 +214,6 @@
 The user should take care to ensure that the lengths of the font sizes remain correctly ordered from \cs{tiny} to \cs{Huge}.
 This is important for typographic and syntactic consistency.
 If the font sizes are in the wrong order, \cs{fontscalesetup} will issue a warning and some package features may not work correctly.
-\pagebreak%manual
 
 \begin{mydisplaycode}
   \Key{\meta{font size command}/scale}[\meta{floating point expression}][\meta{not set}]
@@ -219,6 +222,7 @@
 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}.
 The key \Key{normalsize\slash{}scale} is not defined.
+\pagebreak%manual
 
 \begin{mydisplaycode}
   \Key{\meta{font size command}/size}[\meta{dimen expression}][\meta{not set}]
@@ -284,7 +288,6 @@
 
 This package provides expandable commands that expand to the current font step, font scale, font size, or font baselineskip.
 They can be used for printing or within calculations.
-These commands do not rely on the current definition of the kernel commands \cs{f at size} and \cs{f at baselineskip}; instead, they rely on public \pkg{expl3} variables that are set in the \texttt{selectfont} hook (\S\ref{subsec:publicexpl3}).
 
 For clarity, \cs{CurrentFontStep} will be explained in detail.
 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}).
@@ -335,6 +338,7 @@
 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.
+\pagebreak%manual
 
 \begin{mydisplaycode}
   \cs{ScaleFont} \marg{floating point expression}
@@ -342,7 +346,9 @@
 
 Sets the font size equal to the current font size \texttimes{} the result of computing the \meta{floating point expression}.
 Sets the font baselineskip equal to the current font baselineskip \texttimes{} the result of computing the \meta{floating point expression}.
+The new font baselineskip has no stretch and shrink components.
 Does nothing, except issue a warning, if used in math mode.
+This command is intended as a more robust alternative to \cs{scalefont} from the \pkg{scalefnt} package.
 
 \begin{mydisplaycode}
   \cs{SetFontSizeBaselineskip} \marg{dimen expression} \marg{skip expression}
@@ -351,6 +357,7 @@
 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.
+This command is intended as a more robust alternative to \cs{fontsize} + \cs{selectfont}.
 
 \subsection{Setting only the font baselineskip}
 \label{subsec:setfontbaselineskip}
@@ -386,6 +393,7 @@
 Prints the font step, font scale, font size, and font baselineskip of each font size command from \cs{tiny} to \cs{Huge}.
 The printed font scale is rounded to \num{5} decimal places.
 To print with more decimal places, use \cs{CurrentFontScale} (\S\ref{subsec:expandable}).
+Cannot be used in math mode.
 
 \begin{mydisplaycode}
   \cs{PrintSampleText} \sarg{} \marg{text}
@@ -394,6 +402,7 @@
 Prints \meta{text} in each font size ordered from \cs{tiny} to \cs{Huge} each followed by a paragraph break.
 \meta{text} can contain \cs{par} tokens.
 Adding the optional star reverses the order of the font sizes.
+Cannot be used in math mode.
 One useful way of printing sample text is \cs{PrintSampleText}\allowbreak\texttt{\{\cs{PrintFontSizeCommand}:\allowbreak\textvisiblespace\allowbreak\cs{PrintFontSizeParameters}\}}.
 
 \begin{mydisplaycode}
@@ -403,6 +412,7 @@
 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}.
+Cannot be used in math mode.
 
 
 \section{Programming}
@@ -419,7 +429,8 @@
   }
 \label{subsec:textpurify}
 
-\cs{text_purify:n} will correctly remove the formatting commands defined by this package, including the commands documented in \S\ref{subsec:fontscalesetup}, \S\ref{subsec:fontsize}, and \S\ref{subsec:setfontbaselineskip}.
+\cs{text_purify:n} will correctly remove the formatting commands defined by this package.
+This includes the commands documented in \S\ref{subsec:fontscalesetup}, \S\ref{subsec:fontsize}, and \S\ref{subsec:setfontbaselineskip}.
 
 \subsection{Public functions and variables}
 \label{subsec:publicexpl3}
@@ -445,7 +456,7 @@
 Exception:
 \cs{l_fontscale_normalsize_scale_fp} is not defined.
 The font scale of \cs{normalsize} is stored in \cs{c_fontscale_normalsize_scale_fp}.
-These variables, excluding the constants, are set by \cs{fontscalesetup}.
+The local variables are set by \cs{fontscalesetup}.
 
 \begin{mydisplaycode}
   \cs{l_fontscale_step_fp}

Modified: trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty	2025-01-03 22:50:06 UTC (rev 73288)
+++ trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty	2025-01-03 22:50:15 UTC (rev 73289)
@@ -1,5 +1,5 @@
 % Package   : fontscale -- A flexible interface for setting font sizes
-% Copyright : 2024 (c) Oliver Beery <beeryoliver at gmail.com>
+% Copyright : 2024-2025 (c) Oliver Beery <beeryoliver at gmail.com>
 % CTAN      : https://ctan.org/pkg/fontscale
 % Repository: https://github.com/beeryoliver/fontscale
 % License   : The LaTeX Project Public License 1.3c
@@ -8,8 +8,8 @@
 \NeedsTeXFormat{LaTeX2e}[2023-11-01]
 \ProvidesExplPackage
   {fontscale}
-  {2024-12-22}
-  {3.0.4}
+  {2025-01-03}
+  {3.0.5}
   {A flexible interface for setting font sizes}
 
 % l3kernel version 2023-10-10 added many 'e'-variants.
@@ -26,6 +26,77 @@
 
 % This package does not require any other packages!
 
+% MESSAGES
+
+\msg_new:nnn { fontscale } { key-musical-base-out-of-bounds }
+  {
+    Invalid~ value~ '#1'~ \msg_line_context:. \\
+    The~ value~ of~ the~ key~ 'musical / base'~
+    must~ be~ a~ positive~ length.
+  }
+\msg_new:nnn { fontscale } { key-musical-ratio-out-of-bounds }
+  {
+    Invalid~ value~ '#1'~ \msg_line_context:. \\
+    The~ value~ of~ the~ key~ 'musical / ratio'~
+    must~ be~ greater~ than~ 1.
+  }
+\msg_new:nnn { fontscale } { key-musical-notes-out-of-bounds }
+  {
+    Invalid~ value~ '#1'~ \msg_line_context:. \\
+    The~ value~ of~ the~ key~ 'musical / notes'~
+    must~ be~ a~ positive~ integer.
+  }
+\msg_new:nnn { fontscale } { key-font-scale-out-of-bounds }
+  {
+    Invalid~ value~ '#1'~ \msg_line_context:. \\
+    The~ value~ of~ the~ key~ '#2 / scale'~
+    must~ be~ positive.
+  }
+\msg_new:nnn { fontscale } { key-font-size-out-of-bounds }
+  {
+    Invalid~ value~ '#1'~ \msg_line_context:. \\
+    The~ value~ of~ the~ key~ '#2 / size'~
+    must~ be~ a~ positive~ length.
+  }
+\msg_new:nnn { fontscale } { key-font-scale-overwritten }
+  {
+    The~ font~ size~ set~ by~ the~ key~ '#1 / scale'~
+    has~ been~ overwritten~ by~ the~ key~ '#1 / size'~ \msg_line_context:.
+  }
+\msg_new:nnn { fontscale } { font-sizes-out-of-order }
+  {
+    The~ font~ sizes~ are~ not~ in~ the~ correct~ order~ \msg_line_context:. \\
+    The~ lengths~ of~ the~ font~ sizes~ should~ be~ ordered~ from~
+    \iow_char:N \\tiny~ to~ \iow_char:N \\Huge.
+  }
+
+% This package tests for math mode only at the user level because this is not
+% necessary for programmers. To avoid confusion, this package issues a warning
+% when \fontsize + \selectfont would be used in math mode because it would not
+% change the math font size.
+\msg_new:nnn { fontscale } { math-mode-warning }
+  { '#1'~ does~ nothing~ if~ used~ in~ math~ mode~ \msg_line_context:. }
+% \@ and \par cannot be used in math mode.
+\msg_new:nnn { fontscale } { math-mode-error }
+  { '#1'~ cannot~ be~ used~ in~ math~ mode~ \msg_line_context:. }
+\msg_new:nnn { fontscale } { font-size-out-of-bounds }
+  {
+    Invalid~ font~ size~ '#1'~ \msg_line_context:. \\
+    The~ font~ size~ must~ be~ a~ positive~ length.
+  }
+\msg_new:nnn { fontscale } { font-step-out-of-bounds }
+  {
+    Invalid~ font~ step~ '#1'~ \msg_line_context:. \\
+    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 }
+  {
+    The~ new~ font~ step~ could~ not~ be~ calculated~
+    because~ the~ current~ font~ step~ is~ undefined~ \msg_line_context:.
+  }
+
 % SOME VARIABLES
 
 % Declares and initializes the font step, font scale, font size, and font
@@ -119,7 +190,8 @@
 % 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.
+% the most common case. \f at size and \f at baselineskip are not used elsewhere in
+% the code.
 \hook_gput_code:nnn { selectfont } { fontscale }
   { \__fontscale_hook_selectfont: }
 \cs_new_protected:Npn \__fontscale_hook_selectfont:
@@ -186,13 +258,13 @@
       }
       { \__fontscale_hook_selectfont_auxii: }
   }
-% For speed, \__fontscale_hook_selectfont_auxii: uses \f at size 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 }
+      {
+        \dim_to_fp:n { \l_fontscale_size_dim }
+        * \l__fontscale_normalsize_size_reciprocal_fp
+      }
     \str_if_eq:VnTF \l__fontscale_typographic_scale_str { musical }
       {
         \fp_set:Nn \l_fontscale_step_fp
@@ -203,7 +275,10 @@
                 \dim_compare:nNnTF \l__fontscale_musical_base_dim =
                   \l_fontscale_normalsize_size_dim
                   { \l_fontscale_scale_fp }
-                  { \f at size / \l__fontscale_musical_base_fp }
+                  {
+                    \dim_to_fp:n { \l_fontscale_size_dim }
+                    * \l__fontscale_musical_base_reciprocal_fp
+                  }
               )
           }
       }
@@ -212,11 +287,15 @@
 
 % 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_normalsize_size_reciprocal_fp
 \fp_new:N \l__fontscale_musical_base_fp
-\fp_new:N \l__fontscale_musical_notes_fp
+\fp_new:N \l__fontscale_musical_base_reciprocal_fp
+\fp_new:N \l__fontscale_musical_notes_reciprocal_fp
 \fp_new:N \l__fontscale_musical_selectfont_fp
 
+\fp_set:Nn \l__fontscale_normalsize_size_fp { 10 }
+\fp_set:Nn \l__fontscale_normalsize_size_reciprocal_fp { 0.1 }
+
 % Scratch variable
 \fp_new:N \l__fontscale_tmp_fp
 
@@ -248,17 +327,19 @@
   }
 \cs_generate_variant:Nn \__fontscale_skip_set_from_user:Nn { c }
 % Argument processors
-\dim_new:N \l__fontscale_arg_process_dim
 \cs_new_protected:Npn \__fontscale_arg_process_dim:n #1
   {
-    \__fontscale_dim_set_from_user:Nn \l__fontscale_arg_process_dim {#1}
-    \tl_set:NV \ProcessedArgument \l__fontscale_arg_process_dim
+    \group_begin:
+      \__fontscale_dim_set_from_user:Nn \l_tmpa_dim {#1}
+    \exp_args:NNNV \group_end:
+    \tl_set:Nn \ProcessedArgument \l_tmpa_dim
   }
-\skip_new:N \l__fontscale_arg_process_skip
 \cs_new_protected:Npn \__fontscale_arg_process_skip:n #1
   {
-    \__fontscale_skip_set_from_user:Nn \l__fontscale_arg_process_skip {#1}
-    \tl_set:NV \ProcessedArgument \l__fontscale_arg_process_skip
+    \group_begin:
+      \__fontscale_skip_set_from_user:Nn \l_tmpa_skip {#1}
+    \exp_args:NNNV \group_end:
+    \tl_set:Nn \ProcessedArgument \l_tmpa_skip
   }
 % Used to define \tiny to \Huge. Sets \@currsize only for compatibility. Need
 % \dim_use:N only for compatibility with versions of the microtype package
@@ -291,89 +372,21 @@
 % 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
-  { \exp_args:Ne \__fontscale_set_font_size_aux:n { \dim_to_decimal:n {#1} } }
+  { \exp_args:Ne \__fontscale_set_font_size_aux:n { \dim_eval:n {#1} } }
 \cs_new_protected:Npn \__fontscale_set_font_size_aux:n #1
   {
-    \dim_compare:nNnTF { #1 pt } > \c_zero_dim
+    \dim_compare:nNnTF {#1} > \c_zero_dim
       {
-        \fontsize { #1 pt }
-          { \fp_to_dim:n { #1 * \l__fontscale_baselineskip_size_ratio_fp } }
+        \fontsize {#1}
+          {
+            \fp_to_dim:n
+              { \dim_to_fp:n {#1} * \l__fontscale_baselineskip_size_ratio_fp }
+          }
         \selectfont
       }
-      { \msg_error:nnn { fontscale } { font-size-out-of-bounds } { #1 pt } }
+      { \msg_error:nnn { fontscale } { font-size-out-of-bounds } {#1} }
   }
 
-% MESSAGES
-
-\msg_new:nnn { fontscale } { key-musical-base-out-of-bounds }
-  {
-    Invalid~ value~ '#1'~ \msg_line_context:. \\
-    The~ value~ of~ the~ key~ 'musical / base'~
-    must~ be~ a~ positive~ length.
-  }
-\msg_new:nnn { fontscale } { key-musical-ratio-out-of-bounds }
-  {
-    Invalid~ value~ '#1'~ \msg_line_context:. \\
-    The~ value~ of~ the~ key~ 'musical / ratio'~
-    must~ be~ greater~ than~ 1.
-  }
-\msg_new:nnn { fontscale } { key-musical-notes-out-of-bounds }
-  {
-    Invalid~ value~ '#1'~ \msg_line_context:. \\
-    The~ value~ of~ the~ key~ 'musical / notes'~
-    must~ be~ a~ positive~ integer.
-  }
-\msg_new:nnn { fontscale } { key-font-scale-out-of-bounds }
-  {
-    Invalid~ value~ '#1'~ \msg_line_context:. \\
-    The~ value~ of~ the~ key~ '#2 / scale'~
-    must~ be~ positive.
-  }
-\msg_new:nnn { fontscale } { key-font-size-out-of-bounds }
-  {
-    Invalid~ value~ '#1'~ \msg_line_context:. \\
-    The~ value~ of~ the~ key~ '#2 / size'~
-    must~ be~ a~ positive~ length.
-  }
-\msg_new:nnn { fontscale } { key-font-scale-overwritten }
-  {
-    The~ font~ size~ set~ by~ the~ key~ '#1 / scale'~
-    has~ been~ overwritten~ by~ the~ key~ '#1 / size'~ \msg_line_context:.
-  }
-\msg_new:nnn { fontscale } { font-sizes-out-of-order }
-  {
-    The~ font~ sizes~ are~ not~ in~ the~ correct~ order~ \msg_line_context:. \\
-    The~ lengths~ of~ the~ font~ sizes~ should~ be~ ordered~ from~
-    \iow_char:N \\tiny~ to~ \iow_char:N \\Huge.
-  }
-
-% This package tests for math mode only at the user level because this is not
-% necessary for programmers. To avoid confusion, this package issues a warning
-% when \fontsize + \selectfont would be used in math mode because it would not
-% change the math font size.
-\msg_new:nnn { fontscale } { math-mode-warning }
-  { '#1'~ does~ nothing~ if~ used~ in~ math~ mode~ \msg_line_context:. }
-% \@ and \par cannot be used in math mode.
-\msg_new:nnn { fontscale } { math-mode-error }
-  { '#1'~ cannot~ be~ used~ in~ math~ mode~ \msg_line_context:. }
-\msg_new:nnn { fontscale } { font-size-out-of-bounds }
-  {
-    Invalid~ font~ size~ '#1'~ \msg_line_context:. \\
-    The~ font~ size~ must~ be~ a~ positive~ length.
-  }
-\msg_new:nnn { fontscale } { font-step-out-of-bounds }
-  {
-    Invalid~ font~ step~ '#1'~ \msg_line_context:. \\
-    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 }
-  {
-    The~ new~ font~ step~ could~ not~ be~ calculated~
-    because~ the~ current~ font~ step~ is~ undefined~ \msg_line_context:.
-  }
-
 % DEFINE KEYS
 
 \str_new:N \l__fontscale_typographic_scale_str
@@ -393,11 +406,8 @@
 \cs_new_protected:Npn \__fontscale_keys_code_name:
   {
     \tl_if_in:NnTF \l_keys_value_tl { / }
+      { \exp_after:wN \__fontscale_keys_code_name:ww \l_keys_value_tl \q_stop }
       {
-        \exp_last_unbraced:NV \__fontscale_keys_code_name:ww \l_keys_value_tl
-          \q_stop
-      }
-      {
         \tl_set_eq:cN { l__fontscale_ \l_keys_key_str _size_tl }
           \l_keys_value_tl
       }
@@ -713,7 +723,9 @@
           }
       }
     \fp_set:Nn \l__fontscale_normalsize_size_fp
-      { \l_fontscale_normalsize_size_dim }
+      { \dim_to_fp:n { \l_fontscale_normalsize_size_dim } }
+    \fp_set:Nn \l__fontscale_normalsize_size_reciprocal_fp
+      { \c_one_fp / \l__fontscale_normalsize_size_fp }
     \quark_if_no_value:NTF \l__fontscale_normalsize_baselineskip_tl
       {
         \skip_set:Nn \l_fontscale_normalsize_baselineskip_skip
@@ -784,7 +796,7 @@
       {
         \l__fontscale_musical_base_fp * \l__fontscale_musical_ratio_fp
         ^ ( \use:c { c_fontscale_#1_step_fp }
-        / \l__fontscale_musical_notes_fp )
+        * \l__fontscale_musical_notes_reciprocal_fp )
       }
   }
 % Sets the font size, font scale, and font baselineskip of the other font size
@@ -812,13 +824,25 @@
         {
           \cs_set_eq:NN \__fontscale_keys_process_other_fn_aux:n
             \__fontscale_keys_process_other_musical:n
-          \fp_set:Nn \l__fontscale_musical_base_fp
-            { \l__fontscale_musical_base_dim }
-          \fp_set:Nn \l__fontscale_musical_notes_fp
-            { \l__fontscale_musical_notes_int }
+          \dim_compare:nNnTF \l__fontscale_musical_base_dim =
+            \l_fontscale_normalsize_size_dim
+            {
+              \fp_set_eq:NN \l__fontscale_musical_base_fp
+                \l__fontscale_normalsize_size_fp
+              \fp_set_eq:NN \l__fontscale_musical_base_reciprocal_fp
+                \l__fontscale_normalsize_size_reciprocal_fp
+            }
+            {
+              \fp_set:Nn \l__fontscale_musical_base_fp
+                { \dim_to_fp:n { \l__fontscale_musical_base_dim } }
+              \fp_set:Nn \l__fontscale_musical_base_reciprocal_fp
+                { \c_one_fp / \l__fontscale_musical_base_fp }
+            }
+          \fp_set:Nn \l__fontscale_musical_notes_reciprocal_fp
+            { \c_one_fp / \int_use:N \l__fontscale_musical_notes_int }
           \fp_set:Nn \l__fontscale_musical_selectfont_fp
             {
-              \l__fontscale_musical_notes_fp
+              \int_use:N \l__fontscale_musical_notes_int
               / ln ( \l__fontscale_musical_ratio_fp )
             }
         }
@@ -876,25 +900,23 @@
       { \__fontscale_keys_process_other_fn_aux:n {#1} }
     \prg_break:
     \prg_break_point:
+    \fp_set:cn { l_fontscale_#1_scale_fp }
+      {
+        \dim_to_fp:n { \use:c { l_fontscale_#1_size_dim } }
+        * \l__fontscale_normalsize_size_reciprocal_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
               {
-                \l__fontscale_tmp_fp * \l__fontscale_baselineskip_size_ratio_fp
+                \dim_to_fp:n { \use:c { l_fontscale_#1_size_dim } }
+                * \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_from_user:cn { l_fontscale_#1_baselineskip_skip }
           { \use:c { l__fontscale_#1_baselineskip_tl } }
       }
@@ -1100,8 +1122,6 @@
       { \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
   {
     \fp_set:Nn \l__fontscale_tmp_fp { round ( #1 , 5 ) }
@@ -1127,7 +1147,8 @@
                   {
                     \l__fontscale_musical_base_fp
                     * \l__fontscale_musical_ratio_fp
-                    ^ ( \l__fontscale_tmp_fp / \l__fontscale_musical_notes_fp )
+                    ^ ( \l__fontscale_tmp_fp
+                    * \l__fontscale_musical_notes_reciprocal_fp )
                   }
               }
           }
@@ -1188,10 +1209,17 @@
   {
     \fp_set:Nn \l__fontscale_tmp_fp {#1}
     \__fontscale_set_font_size:nn
-      { \fp_to_dim:n { \l__fontscale_tmp_fp * \l_fontscale_size_dim } }
       {
-        \fp_to_dim:n { \l__fontscale_tmp_fp * \l_fontscale_baselineskip_skip }
+        \fp_to_dim:n
+          { \l__fontscale_tmp_fp * \dim_to_fp:n { \l_fontscale_size_dim } }
       }
+      {
+        \fp_to_dim:n
+          {
+            \l__fontscale_tmp_fp
+            * \dim_to_fp:n { \l_fontscale_baselineskip_skip }
+          }
+      }
   }
 
 \NewDocumentCommand \SetFontSizeBaselineskip



More information about the tex-live-commits mailing list.