texlive[74414] Master/texmf-dist: fontscale (3mar25)
commits+karl at tug.org
commits+karl at tug.org
Mon Mar 3 22:17:13 CET 2025
Revision: 74414
https://tug.org/svn/texlive?view=revision&revision=74414
Author: karl
Date: 2025-03-03 22:17:13 +0100 (Mon, 03 Mar 2025)
Log Message:
-----------
fontscale (3mar25)
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-code.pdf
trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-code.tex
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
Added Paths:
-----------
trunk/Master/texmf-dist/tex/latex/fontscale/fontscale-v3.sty
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/CHANGELOG.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/CHANGELOG.md 2025-03-03 21:16:35 UTC (rev 74413)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/CHANGELOG.md 2025-03-03 21:17:13 UTC (rev 74414)
@@ -7,6 +7,39 @@
## [Unreleased]
+## [v4.0.0] - 2025-03-02
+
+### Added
+- `fontscale` version 3 can be used by declaring `\usepackage{fontscale}[=v3]`.
+- `fontscale-v3.sty`
+
+### Removed
+- The package keys and commands that take a dimen or skip expression as a value
+ or argument no longer append a default unit of `pt` and remove extra trailing
+ tokens, if any. (This feature had relied on exploiting `expl3` implementation
+ details.)
+
+### Changed
+- `fontscale` is no longer compatible with the `scalefnt` package.
+- The keys `<font size command>` are now shortcuts for the keys
+ `<font size command>/size`. (The previous functionality no longer makes
+ syntactic sense given the removal of default unit support.)
+- Renamed the document commands using the recommended all-lowercase convention:
+ - `\CurrentFontStep` to `\currentfontstep`
+ - `\CurrentFontScale` to `\currentfontscale`
+ - `\CurrentFontSize` to `\currentfontsize`
+ - `\CurrentFontBaselineskip` to `\currentfontbaselineskip`
+ - `\SetFontStep` to `\setfontstep`
+ - `\SetFontScale` to `\setfontscale`
+ - `\SetFontSize` to `\setfontsize`
+ - `\ScaleFont` to `\scalefont`
+ - `\SetFontSizeBaselineskip` to `\setfontsizebaselineskip`
+ - `\SetFontBaselineskip` to `\setfontbaselineskip`
+ - `\PrintFontSizeParameters` to `\printfontsizeparameters`
+ - `\PrintAllFontSizeParameters` to `\printallfontsizeparameters`
+ - `\PrintSampleText` to `\printsampletext`
+ - `\PrintFontSizeCommand` to `\printfontsizecommand`
+
## [v3.1.2] - 2025-02-13
### Fixed
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls 2025-03-03 21:16:35 UTC (rev 74413)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/beery.cls 2025-03-03 21:17:13 UTC (rev 74414)
@@ -3,11 +3,7 @@
% LOADING THE CLASS
\NeedsTeXFormat{LaTeX2e}[2023-11-01]
-\ProvidesExplClass
- {beery}
- {2025-02-13}
- {0.0.0}
- {}
+\ProvidesExplClass{beery}{2025-03-02}{0.0.0}{}
\prop_gput:Nnn \g_msg_module_type_prop { beery } { Class }
@@ -42,16 +38,16 @@
\RequirePackage { fontscale }
\fontscalesetup { musical }
\RequirePackage { siunitx }
-\sisetup { list-final-separator = { ,~ and~ } , mode = match }
+\sisetup { list-final-separator = { ,~ and~ } , mode = math }
\RequirePackage { mathtools }
-\RequirePackage [ shortcuts , allowbreakbefore ] { extdash }
\RequirePackage { csquotes }
\RequirePackage { lmodern }
\RequirePackage { scaletextbullet }
+\settextbulletfactor { 0.4 }
\RequirePackage { tcolorbox }
\tcbuselibrary { breakable }
-\NewTColorBox { mydisplaycode } { }
+\NewTColorBox { displaycode } { }
{
size = minimal
, left = 2pt
@@ -61,6 +57,12 @@
, breakable
}
+\RequirePackage { fancyvrb }
+\cs_new_protected:Npn \__beery_hook_begindocument_fancyvrb:
+ { \DefineShortVerb { \| } }
+\hook_gput_code:nnn { begindocument } { beery }
+ { \__beery_hook_begindocument_fancyvrb: }
+
% SOME VARIABLES
\fp_const:Nn \c_beery_golden_ratio_fp { 1.6180 3398 8749 8948 }
@@ -69,38 +71,75 @@
\tl_const:Nn \c_beery_pangram_tl
{ The~ quick~ brown~ fox~ jumps~ over~ the~ lazy~ dog. }
+\tl_new:N \l__beery_print_key_tl
+\tl_new:N \l__beery_print_cs_tl
+
% Scratch variables
\box_new:N \l__beery_tmp_box
% CUSTOM MACROS
+\cs_generate_variant:Nn \tl_replace_all:Nnn { NeV }
+
+\cs_new_protected:Npn \__beery_print_langle: { \ensuremath { \langle } }
+\cs_new_protected:Npn \__beery_print_rangle: { \ensuremath { \rangle } }
+
\NewExpandableDocumentCommand \alphabet { } { \c_beery_alphabet_tl }
\NewExpandableDocumentCommand \digits { } { \c_beery_digits_tl }
\NewExpandableDocumentCommand \pangram { } { \c_beery_pangram_tl }
-\NewDocumentCommand \Key
+\NewDocumentCommand \displaykey
{ >{ \TrimSpaces } m >{ \TrimSpaces } o >{ \TrimSpaces } o }
{
\mode_leave_vertical:
\IfNoValueTF {#2}
- { \__beery_print_key:n {#1} }
+ { \__beery_print_display_key:n {#1} }
{
\IfNoValueTF {#3}
- { \__beery_print_key:nn {#1} {#2} }
- { \__beery_print_key:nnn {#1} {#2} {#3} }
+ { \__beery_print_display_key:nn {#1} {#2} }
+ { \__beery_print_display_key:nnn {#1} {#2} {#3} }
}
}
-\cs_new_protected:Npn \__beery_print_key:n #1 { \texttt {#1} }
-\cs_new_protected:Npn \__beery_print_key:nn #1#2
- { \texttt { #1 \ensuremath { \,=\, } \allowbreak #2 } }
-\cs_new_protected:Npn \__beery_print_key:nnn #1#2#3
+\cs_new_protected:Npn \__beery_print_display_key:n #1 { \texttt {#1} }
+\cs_new_protected:Npn \__beery_print_display_key:nn #1#2
+ { \texttt { #1 \__beery_print_display_key_equal: #2 } }
+\cs_new_protected:Npn \__beery_print_display_key:nnn #1#2#3
{
\group_begin:
\ttfamily
- #1 \ensuremath { \,=\, } #2 \hspace* { \fill }
- \hbox:n { initial \ensuremath { \,=\, } #3 }
+ #1 \__beery_print_display_key_equal: #2
+ \hspace* { \fill }
+ \hbox:n { initial \__beery_print_display_key_equal: #3 }
\group_end:
}
+\cs_new_protected:Npn \__beery_print_display_key_equal:
+ { \ensuremath { \,=\, } }
+\NewDocumentCommand \key { >{ \TrimSpaces } m }
+ {
+ \mode_if_math:TF
+ { \msg_error:nne { beery } { math-mode-error } { \token_to_str:N \key } }
+ { \__beery_print_key:n {#1} }
+ }
+\cs_new_protected:Npn \__beery_print_key:n #1
+ {
+ \tl_set:Nn \l__beery_print_key_tl {#1}
+ \tl_replace_all:Nnn \l__beery_print_key_tl { = }
+ { \__beery_print_key_equal: }
+ \tl_replace_all:Nnn \l__beery_print_key_tl { / } { \slash }
+ \texttt { \l__beery_print_key_tl } \@
+ }
+\cs_new_protected:Npn \__beery_print_key_equal:
+ { \ensuremath { \,=\, } \allowbreak }
+\NewDocumentCommand \keyvalue { >{ \TrimSpaces } m }
+ {
+ \mode_if_math:TF
+ {
+ \msg_error:nne { beery } { math-mode-error }
+ { \token_to_str:N \keyvalue }
+ }
+ { \__beery_print_key_value:n {#1} }
+ }
+\cs_new_protected:Npn \__beery_print_key_value:n #1 { \texttt {#1} \@ }
\NewDocumentCommand \cs { >{ \TrimSpaces } m }
{
\mode_if_math:TF
@@ -108,7 +147,12 @@
{ \__beery_print_cs:n {#1} }
}
\cs_new_protected:Npn \__beery_print_cs:n #1
- { \texttt { \token_to_str:c {#1} } \@ }
+ {
+ \tl_set:Nn \l__beery_print_cs_tl {#1}
+ \tl_replace_all:NeV \l__beery_print_cs_tl
+ { \char_generate:nn { `_ } { 8 } } \c_underscore_str
+ \texttt { \textbackslash \l__beery_print_cs_tl } \@
+ }
\NewDocumentCommand \marg { >{ \TrimSpaces } m }
{ \__beery_print_m_arg:n {#1} }
\cs_new_protected:Npn \__beery_print_m_arg:n #1
@@ -115,11 +159,11 @@
{
\allowbreak
\texttt { \c_left_brace_str }
- \ensuremath \langle
+ \__beery_print_langle:
\group_begin:
\normalfont \itshape #1
\group_end:
- \ensuremath \rangle
+ \__beery_print_rangle:
\texttt { \c_right_brace_str }
}
\NewDocumentCommand \oarg { >{ \TrimSpaces } m }
@@ -128,24 +172,24 @@
{
\allowbreak
\texttt { [ }
- \ensuremath \langle
+ \__beery_print_langle:
\group_begin:
\normalfont \itshape #1
\group_end:
- \ensuremath \rangle
+ \__beery_print_rangle:
\texttt { ] }
}
\NewDocumentCommand \sarg { } { \__beery_print_s_arg: }
\cs_new_protected:Npn \__beery_print_s_arg:
- { \ensuremath \langle \texttt {*} \ensuremath \rangle }
+ { \__beery_print_langle: \texttt {*} \__beery_print_rangle: }
\NewDocumentCommand \meta { >{ \TrimSpaces } m } { \__beery_print_meta:n {#1} }
\cs_new_protected:Npn \__beery_print_meta:n #1
{
- \ensuremath \langle
+ \__beery_print_langle:
\group_begin:
\normalfont \itshape #1
\group_end:
- \ensuremath \rangle
+ \__beery_print_rangle:
}
\NewDocumentCommand \cls { >{ \TrimSpaces } m }
{
@@ -168,6 +212,15 @@
{ \__beery_print_pkg:n {#1} }
}
\cs_new_protected:Npn \__beery_print_pkg:n #1 { \textsf {#1} \@ }
+\NewDocumentCommand \hook { >{ \TrimSpaces } m }
+ {
+ \mode_if_math:TF
+ {
+ \msg_error:nne { beery } { math-mode-error } { \token_to_str:N \hook }
+ }
+ { \__beery_print_hook:n {#1} }
+ }
+\cs_new_protected:Npn \__beery_print_hook:n #1 { \texttt {#1} \@ }
\NewDocumentCommand \latin { >{ \TrimSpaces } m }
{
\mode_if_math:TF
@@ -216,10 +269,8 @@
\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
- { \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_const:Nn \c_beery_medium_dim { \c_beery_big_dim / 2 }
+\dim_const:Nn \c_beery_small_dim { \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
@@ -227,8 +278,8 @@
\skip_const:Nn \c_beery_big_skip
{
\c_beery_big_dim
- 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 }
+ plus \dim_eval:n { \c_beery_big_dim / 2 }
+ minus \dim_eval: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 }
@@ -277,6 +328,7 @@
% PARAGRAPH STYLE
+% \frenchspacing
\nonfrenchspacing
\linespread { 1 }
\RequirePackage [ skip = \c_beery_medium_skip ] { parskip }
@@ -440,7 +492,7 @@
\skip_zero:N \topsep
\skip_zero:N \partopsep
}
- \item #1 \endlist
+ \item \tl_trim_spaces:n {#1} \endlist
}
\coffin_typeset:Nnnnn \l__beery_footnote_coffin { l } { b }
{ \c_zero_dim } { - \c_beery_footnote_baselineheight_dim }
@@ -448,10 +500,19 @@
% REFERENCES
-\cs_new_protected:Npn \__beery_hook_code_shipout_last_page:
+\cs_new_protected:Npn \__beery_hook_code_shipout_lastpage:
{ \label { LastPage } }
-\hook_gput_code:nnn { shipout / last page } { beery }
- { \__beery_hook_code_shipout_last_page: }
+\hook_gput_code:nnn { shipout / lastpage } { beery }
+ { \__beery_hook_code_shipout_lastpage: }
\RequirePackage { xurl }
\RequirePackage { hyperref }
-\hypersetup { bookmarksnumbered , hidelinks , linktoc = page }
\ No newline at end of file
+\hypersetup { bookmarksnumbered , hidelinks , linktoc = page }
+\cs_new:Npn \__beery_pdfstring_cs:n #1
+ { \textbackslash \tl_to_str:e { \tl_trim_spaces:n {#1} } }
+\cs_new:Npn \__beery_pdfstring_key:n #1
+ { \tl_to_str:e { \tl_trim_spaces:n {#1} } }
+\pdfstringdefDisableCommands
+ {
+ \cs_set_eq:NN \key \__beery_pdfstring_key:n
+ \cs_set_eq:NN \cs \__beery_pdfstring_cs:n
+ }
\ No newline at end of file
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-code.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-code.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-code.tex 2025-03-03 21:16:35 UTC (rev 74413)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-code.tex 2025-03-03 21:17:13 UTC (rev 74414)
@@ -20,7 +20,7 @@
Oliver Beery
-Version 3.1.2\quad{}13 February 2025
+Version 4.0.0\quad{}2 March 2025
\dochighinput[language=latex/latex3]{fontscale.sty}
Modified: trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex 2025-03-03 21:16:35 UTC (rev 74413)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-classic.tex 2025-03-03 21:17:13 UTC (rev 74414)
@@ -1,4 +1,4 @@
-\ProvidesFile{fontscale-table-classic.tex}[2025-02-13]
+\ProvidesFile{fontscale-table-classic.tex}[2025-03-02]
\begin{table}
\centering
@@ -19,7 +19,7 @@
}
, cell{1}{2-Z}={guard}
, cell{2-Z}{1}={cmd=\cs}
- , cell{1}{2-Z}={cmd=\Key}
+ , cell{1}{2-Z}={cmd=\key}
}
\toprule
font size command & classic-10pt & classic-11pt & classic-12pt \\
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-03-03 21:16:35 UTC (rev 74413)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-font-steps.tex 2025-03-03 21:17:13 UTC (rev 74414)
@@ -1,4 +1,4 @@
-\ProvidesFile{fontscale-table-font-steps.tex}[2025-02-13]
+\ProvidesFile{fontscale-table-font-steps.tex}[2025-03-02]
\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-03-03 21:16:35 UTC (rev 74413)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale-table-musical.tex 2025-03-03 21:17:13 UTC (rev 74414)
@@ -1,4 +1,4 @@
-\ProvidesFile{fontscale-table-musical.tex}[2025-02-13]
+\ProvidesFile{fontscale-table-musical.tex}[2025-03-02]
\begin{table}
\centering
@@ -20,7 +20,7 @@
, cell{2-Z}{1}={cmd=\cs}
}
\toprule
- font size command & \Key{musical} \\
+ font size command & \key{musical} \\
\midrule
tiny & 5.74 \\
scriptsize & 6.60 \\
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-03-03 21:16:35 UTC (rev 74413)
+++ trunk/Master/texmf-dist/doc/latex/fontscale/fontscale.tex 2025-03-03 21:17:13 UTC (rev 74414)
@@ -6,7 +6,7 @@
\section*
{%
- \SetFontStep*{1}%
+ \setfontstep*{1}%
The \pkg{fontscale} package%
}
@@ -14,7 +14,7 @@
Oliver Beery
-Version 3.1.2\quad{}13 February 2025
+Version 4.0.0\quad{}2 March 2025
\section{Introduction}
@@ -30,7 +30,7 @@
\item
Set arbitrary font sizes and font baselineskips for the standard \LaTeX{} font size commands \cs{tiny}, \cs{scriptsize}, \cs{footnotesize}, \cs{small}, \cs{normalsize}, \cs{large}, \cs{Large}, \cs{LARGE}, \cs{huge}, and \cs{Huge} (\S\ref{subsec:overwriting}).
\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}).
+ 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, or font baselineskip (\S\ref{subsec:expandable}).
\item
@@ -42,25 +42,32 @@
\subsection{Loading the package}
\label{subsec:loading}
+If you still rely on a previous version of this package, you can declare:
+
+\begin{verbatim}
+\usepackage{fontscale}[=v3]
+\end{verbatim}
+
\listheading{Requirements:}
\begin{itemize}
\item \LaTeXe{} version 2023-11-01 or newer
\item \pkg{l3kernel} version 2023-11-09 or newer
+ \item \pkg{fontscale} is incompatible with the \pkg{scalefnt} package.
\end{itemize}
-You may need to ensure that your \LaTeX{} installation is up\-/to\-/date before using this package.
+You may need to ensure that your \LaTeX{} installation is up-to-date before using this package.
This package lets the user set arbitrary font sizes.
This works with most fonts produced today, but, for historical reasons, the default Computer Modern font is available only in a number of discrete font sizes.
-If you get a warning that Computer Modern is not available in the requested font size, you may need to add the code \cs{RequirePackage}\allowbreak\verb|{fix-cm}| before \cs{documentclass} to make Computer Modern available at arbitrary font sizes.
+If you get a warning that Computer Modern is not available in the requested font size, you may need to add the code \cs{RequirePackage}\allowbreak|{fix-cm}| before \cs{documentclass} to make Computer Modern available at arbitrary font sizes.
Alternatively, you can use the Latin Modern font by loading the \pkg{lmodern} package.
The \pkg{fontscale} package has no package options.
-Instead, this package provides the command \cs{fontscalesetup}\marg{key$\,=\,$value list} (\S\ref{subsec:fontscalesetup}) which sets the package keys (\S\ref{sec:keys}).
+Instead, this package provides the command \cs{fontscalesetup}\marg{keys} (\S\ref{subsec:fontscalesetup}) which sets the package keys (\S\ref{sec:keys}).
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
@@ -104,70 +111,60 @@
This section documents the keys provided by the \pkg{fontscale} package.
This package has no package options.
-Set the package keys using \cs{fontscalesetup}\marg{key$\,=\,$value list} (\S\ref{subsec:fontscalesetup}).
+Set the package keys using \cs{fontscalesetup}\marg{keys} (\S\ref{subsec:fontscalesetup}).
-\subsection
- {%
- The key
- \texorpdfstring
- {\Key{typographic-scale}}
- {typographic-scale}%
- }
+\subsection{The key \key{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}.
-\begin{mydisplaycode}
- \Key{typographic-scale}
- [
- classic-10pt$\,\vert\,$\allowbreak
- classic-11pt$\,\vert\,$\allowbreak
- classic-12pt$\,\vert\,$\allowbreak\hspace*{1.5em}%
- musical
- ]
- [classic-10pt]
- \newline
- \Key{classic-10pt}
- \newline
- \Key{classic-11pt}
- \newline
- \Key{classic-12pt}
- \nopagebreak\newline
- \Key{musical}
-\end{mydisplaycode}
+\begin{displaycode}
+ \displaykey{typographic-scale}[\meta{choice}][classic-10pt]
+\end{displaycode}
-The value of the key \Key{typographic-scale} must be \texttt{classic-10pt}, \texttt{classic-11pt}, \texttt{classic-12pt}, or \texttt{musical}.
-The initial value is \texttt{classic-10pt}.
+\meta{choice} must be \keyvalue{classic-10pt}, \keyvalue{classic-11pt}, \keyvalue{classic-12pt}, or \keyvalue{musical}.
+The initial value is \keyvalue{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.
+\begin{displaycode}
+ \displaykey{classic-10pt}
+ \nopagebreak\newline
+ \displaykey{classic-11pt}
+ \newline
+ \displaykey{classic-12pt}
+ \nopagebreak\newline
+ \displaykey{musical}
+\end{displaycode}
+
+These keys are shortcuts that 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 \texttt{classic-10pt}, \texttt{classic-11pt}, or \texttt{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}.
+Setting the value of the key \key{typographic-scale} to \keyvalue{classic-10pt}, \keyvalue{classic-11pt}, or \keyvalue{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---\qty{10}{pt}, \qty{11}{pt}, or \qty{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.
\input{./fontscale-table-classic.tex}
-\begin{mydisplaycode}
- \Key{musical/base}[\meta{dimen expression}][10pt]%
+\begin{displaycode}
+ \displaykey{musical/base}[\meta{dimen expression}][10pt]%
\nopagebreak\newline
- \Key{musical/ratio}[\meta{floating point expression}][2]%
+ \displaykey{musical/ratio}[\meta{floating point expression}][2]%
\nopagebreak\newline
- \Key{musical/notes}[\meta{integer expression}][5]
-\end{mydisplaycode}
+ \displaykey{musical/notes}[\meta{integer expression}][5]
+\end{displaycode}
-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
- {%
+ {
I have referenced this article by Spencer Mortensen:
\newline
- \url{https://spencermortensen.com/articles/typographic-scale/}%
+ \url{https://spencermortensen.com/articles/typographic-scale/}
}
\begin{equation}\label{eq:musical}
f_i = f_0 \times r ^ { i / n }
@@ -174,40 +171,33 @@
\end{equation}
$f_i$ is the font size with font step $i$.
$f_0$ is the base font size.
-$n$ is the number of musical notes\---the number of font size gradations or steps above $f_0$.
+$n$ is the number of musical notes---the number of font size gradations or steps above $f_0$.
$r$ is the musical ratio, the ratio of the highest to the lowest note $ f_n / f_0 $.
-The key \Key{musical\slash{}base} sets the base font size to the value of \meta{dimen expression}, appending a default unit of \unit{pt}.
+The key \key{musical/base} sets the base font size to the value of \meta{dimen expression}.
The base font size is the font size of \cs{normalsize}.
The initial value is \qty{10}{pt}.
-The key \Key{musical\slash{}ratio} sets the musical ratio to the result of computing the \meta{floating point expression}.
+The key \key{musical/ratio} sets the musical ratio to the result of computing the \meta{floating point expression}.
The initial value is \num{2}.
-The key \Key{musical\slash{}notes} sets the number of musical notes to the value of \meta{integer expression}.
+The key \key{musical/notes} sets the number of musical notes to the value of \meta{integer expression}.
The initial value is \num{5}.
Table \ref{table:musical} displays the font size of each font size command when using a musical typographic scale with the initial values.
\input{./fontscale-table-musical.tex}
-\subsection
- {%
- The key
- \texorpdfstring
- {\Key{baselineskip-size-ratio}}
- {baselineskip-size-ratio}%
- }
+\subsection{The key \key{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}.
-\begin{mydisplaycode}
- \Key{baselineskip-size-ratio}[\meta{floating point expression}][1.2]
-\end{mydisplaycode}
+\begin{displaycode}
+ \displaykey{baselineskip-size-ratio}[\meta{floating point expression}][1.2]
+\end{displaycode}
Sets the font baselineskip of each font size command from \cs{tiny} to \cs{Huge} equal to its font size \texttimes{} the result of computing the \meta{floating point expression}.
-Sets the font baselineskip set by \cs{SetFontStep}, \cs{SetFontScale}, and \cs{SetFontSize} equal to the new font size \texttimes{} the result of computing the \meta{floating point expression} (\S\ref{subsec:fontsize}).
+Sets the font baselineskip set by \cs{setfontstep}, \cs{setfontscale}, and \cs{setfontsize} equal to the new font size \texttimes{} the result of computing the \meta{floating point expression} (\S\ref{subsec:fontsize}).
The initial value is \num{1.2}.
-
\subsection{Overwriting the previous keys}
\label{subsec:overwriting}
@@ -219,46 +209,37 @@
If the font sizes are in the wrong order, \cs{fontscalesetup} will issue a warning and some package features may not work correctly.
The syntax \meta{font size command} represents the name of a font size command from \cs{tiny} to \cs{Huge}, omitting the backslash character.
-\pagebreak%manual
-\begin{mydisplaycode}
- \Key{\meta{font size command}/scale}[\meta{floating point expression}][\meta{not set}]
-\end{mydisplaycode}
+\begin{displaycode}
+ \displaykey{\meta{font size command}/scale}[\meta{floating point expression}][\meta{not set}]
+\end{displaycode}
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}.
These keys are initially not set.
-The key \Key{normalsize\slash{}scale} is not defined.
+The key \key{normalsize/scale} is not defined.
-\begin{mydisplaycode}
- \Key{\meta{font size command}/size}[\meta{dimen expression}][\meta{not set}]
-\end{mydisplaycode}
+\begin{displaycode}
+ \displaykey{\meta{font size command}/size}[\meta{dimen expression}][\meta{not set}]
+\end{displaycode}
-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}.
+Sets the font size of \meta{font size command} to the value of \meta{dimen expression}.
+Overwrites the font size set by the keys \key{typographic-scale} and \key{\meta{font size command}/scale}.
These keys are initially not set.
-\begin{mydisplaycode}
- \Key{\meta{font size command}/baselineskip}[\meta{skip expression}][\meta{not set}]
-\end{mydisplaycode}
+\begin{displaycode}
+ \displaykey{\meta{font size command}/baselineskip}[\meta{skip expression}][\meta{not set}]
+\end{displaycode}
-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}.
+Sets the font baselineskip of \meta{font size command} to the value of \meta{skip expression}.
+Overwrites the font baselineskip set by the key \key{baselineskip-size-ratio}.
These keys are initially not set.
-\begin{mydisplaycode}
- \Key{\meta{font size command}}[\meta{dimen expression}]
- \nopagebreak\newline
- \Key{\meta{font size command}}[\meta{dimen expression}/\meta{skip expression}]
-\end{mydisplaycode}
+\begin{displaycode}
+ \displaykey{\meta{font size command}}[\meta{dimen expression}]
+\end{displaycode}
-Sets the keys \Key{\meta{font size command}\slash{}size}[\meta{dimen expression}] or \Key{\meta{font size command}\slash{}baselineskip}[\meta{skip expression}] in a condensed format.%
-\footnote
- {%
- 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.
+Sets the key \key{\meta{font size command}/size=\meta{dimen expression}}.
\section{Commands}
@@ -269,14 +250,13 @@
\subsection{Setting the keys}
\label{subsec:fontscalesetup}
-\begin{mydisplaycode}
- \cs{fontscalesetup} \sarg{} \marg{key$\,=\,$value list}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{fontscalesetup} \sarg{} \marg{keys}
+\end{displaycode}
-Sets and processes the \pkg{fontscale} package keys (\S\ref{sec:keys}) in \meta{key$\,=\,$value list} and then uses \cs{normalsize}.
+Sets and processes the \pkg{fontscale} package keys (\S\ref{sec:keys}) in \meta{keys} and then uses \cs{normalsize}.
Adding the optional star \sarg{} first resets all the \pkg{fontscale} package keys to their initial values.
-The order of the keys in \meta{key$\,=\,$value list} does not affect how the keys are processed (unless a key is set more than once).
-Can be used mid\-/document.
+Can be used mid-document.
The scope of the effect is local to the current group.
Does nothing, except issue a warning, if used in math mode.
\cs{fontscalesetup} should typically be used only once in the preamble or omitted if the user is satisfied with the initial font sizes and font baselineskips.
@@ -284,23 +264,23 @@
\subsection{Expandable font size parameters}
\label{subsec:expandable}
-\begin{mydisplaycode}
- \cs{CurrentFontStep}
+\begin{displaycode}
+ \cs{currentfontstep}
\nopagebreak\newline
- \cs{CurrentFontScale}
+ \cs{currentfontscale}
\newline
- \cs{CurrentFontSize}
+ \cs{currentfontsize}
\nopagebreak\newline
- \cs{CurrentFontBaselineskip}
-\end{mydisplaycode}
+ \cs{currentfontbaselineskip}
+\end{displaycode}
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.
-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}).
-If not and if the value of the key \Key{typographic-scale} is \texttt{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.
+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}).
+If not and if the value of the key \key{typographic-scale} is \keyvalue{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.
\subsection{More font size commands}
\label{subsec:fontsize}
@@ -308,13 +288,13 @@
This package provides additional font size commands for use only in special cases.
Users should prefer the standard \LaTeX{} font size commands from \cs{tiny} to \cs{Huge} for typographic and syntactic consistency.
-\begin{mydisplaycode}
- \cs{SetFontStep} \sarg{} \marg{floating point expression}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{setfontstep} \sarg{} \marg{floating point expression}
+\end{displaycode}
Sets the font size by setting the font step to the result of computing the \meta{floating point expression}.
Adding the optional star \sarg{} instead sets the font step equal to the current font step + 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}.
+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}
@@ -321,40 +301,40 @@
\item
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.%
\footnote
- {%
+ {
\label{fn:setfontstep}%
- The font step is rounded to \num{5} decimal places when testing equality due to floating point precision.%
+ The font step is rounded to \num{5} decimal places when testing equality due to floating point precision.
}
\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 \texttt{musical}.%
+ \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 \keyvalue{musical}.%
\footnote{See Footnote \ref{fn:setfontstep}.}
- \cs{SetFontStep*} will always issue an error if the current font step is undefined.
+ \cs{setfontstep*} will always issue an error if the current font step is undefined.
\item
Does nothing, except issue a warning, if used in math mode.
\end{itemize}
-\begin{mydisplaycode}
- \cs{SetFontScale} \sarg{} \marg{floating point expression}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{setfontscale} \sarg{} \marg{floating point expression}
+\end{displaycode}
Sets the font size by setting the font scale to the result of computing the \meta{floating point expression}.
Adding the optional star \sarg{} 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}.
+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.
-\begin{mydisplaycode}
- \cs{SetFontSize} \sarg{} \marg{dimen expression}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{setfontsize} \sarg{} \marg{dimen expression}
+\end{displaycode}
-Sets the font size to the value of \meta{dimen expression}, appending a default unit of \unit{pt}.
-Adding the optional star \sarg{} 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}.
+Sets the font size to the value of \meta{dimen expression}.
+Adding the optional star \sarg{} instead sets the font size equal to the current font size + the result of \meta{dimen 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.
-\begin{mydisplaycode}
- \cs{ScaleFont} \marg{floating point expression}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{scalefont} \marg{floating point expression}
+\end{displaycode}
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}.
@@ -362,12 +342,12 @@
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}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{setfontsizebaselineskip} \marg{dimen expression} \marg{skip expression}
+\end{displaycode}
-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}.
+Sets the font size to the value of \meta{dimen expression}.
+Sets the font baselineskip to the value of \meta{skip expression}.
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}.
@@ -374,12 +354,12 @@
\subsection{Setting only the font baselineskip}
\label{subsec:setfontbaselineskip}
-\begin{mydisplaycode}
- \cs{SetFontBaselineskip} \sarg{} \marg{skip expression}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{setfontbaselineskip} \sarg{} \marg{skip expression}
+\end{displaycode}
-Sets the font baselineskip to the value of \meta{skip expression}, appending a default unit of \unit{pt}.
-Adding the optional star \sarg{} instead sets the font baselineskip equal to the current font baselineskip + the result of \meta{skip expression}, appending a default unit of \unit{pt}.
+Sets the font baselineskip to the value of \meta{skip expression}.
+Adding the optional star \sarg{} instead sets the font baselineskip equal to the current font baselineskip + the result of \meta{skip expression}.
Does not change the font size.
Does nothing, except issue a warning, if used in math mode.
@@ -389,38 +369,42 @@
This subsection documents commands that are intended primarily for testing and debugging.
I have used them often when developing this package so I think users will find them helpful.
-\begin{mydisplaycode}
- \cs{PrintFontSizeParameters}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{printfontsizeparameters}
+\end{displaycode}
Prints the current font step, font scale, font size, and font baselineskip.
The printed font step and font scale are rounded to \num{5} decimal places.
-To print with more decimal places, use \cs{CurrentFontStep} and \cs{CurrentFontScale} (\S\ref{subsec:expandable}).
-The printed font step will be left blank if it is undefined (as explained for \cs{CurrentFontStep} in \S\ref{subsec:expandable}).
+To print with more decimal places, use \cs{currentfontstep} and \cs{currentfontscale} (\S\ref{subsec:expandable}).
+The printed font step will be left blank if it is undefined (as explained for \cs{currentfontstep} in \S\ref{subsec:expandable}).
-\begin{mydisplaycode}
- \cs{PrintAllFontSizeParameters}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{printallfontsizeparameters}
+\end{displaycode}
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}).
+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}
-\end{mydisplaycode}
+\begin{displaycode}
+ \cs{printsampletext} \sarg{} \marg{text}
+\end{displaycode}
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 \sarg{} 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}\}}.
+One useful way of printing sample text is:
-\begin{mydisplaycode}
- \cs{PrintFontSizeCommand}
-\end{mydisplaycode}
+\begin{verbatim*}
+\printsampletext{\printfontsizecommand: \printfontsizeparameters}
+\end{verbatim*}
+\begin{displaycode}
+ \cs{printfontsizecommand}
+\end{displaycode}
+
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.
If not, prints \enquote{\string\undefined}.
@@ -432,13 +416,7 @@
This section documents the \pkg{expl3} programming support provided by the \pkg{fontscale} package.
-\subsection
- {%
- Compatibility with
- \texorpdfstring
- {\cs{text_purify:n}}
- {\textbackslash{}text\_purify:n}%
- }
+\subsection{Compatibility with \cs{text_purify:n}}
\label{subsec:textpurify}
\cs{text_purify:n} will correctly remove the formatting commands defined by this package.
@@ -450,20 +428,19 @@
This package does not define any public \pkg{expl3} functions.
This package defines some public \pkg{expl3} variables.
-They are set either by \cs{fontscalesetup} or in the \texttt{selectfont} hook.
+They are set either by \cs{fontscalesetup} or in the \hook{selectfont} hook.
They should never be modified directly.
The syntax \meta{font size command} represents the name of a font size command from \cs{tiny} to \cs{Huge}, omitting the backslash character.
-\begin{mydisplaycode}
- \ttfamily
- \textbackslash{}c\_fontscale\_\meta{font size command}\_step\_fp
+\begin{displaycode}
+ \cs{c_fontscale_\meta{font size command}_step_fp}
\nopagebreak\newline
- \textbackslash{}l\_fontscale\_\meta{font size command}\_scale\_fp
+ \cs{l_fontscale_\meta{font size command}_scale_fp}
\newline
- \textbackslash{}l\_fontscale\_\meta{font size command}\_size\_dim
+ \cs{l_fontscale_\meta{font size command}_size_dim}
\nopagebreak\newline
- \textbackslash{}l\_fontscale\_\meta{font size command}\_baselineskip\_skip
-\end{mydisplaycode}
+ \cs{l_fontscale_\meta{font size command}_baselineskip_skip}
+\end{displaycode}
Stores the font step, font scale, font size, and font baselineskip of each font size command from \cs{tiny} to \cs{Huge}.
Exception:
@@ -471,7 +448,7 @@
The font scale of \cs{normalsize} is stored in \cs{c_fontscale_normalsize_scale_fp}.
The local variables are set by \cs{fontscalesetup}.
-\begin{mydisplaycode}
+\begin{displaycode}
\cs{l_fontscale_step_fp}
\nopagebreak\newline
\cs{l_fontscale_scale_fp}
@@ -479,11 +456,11 @@
\cs{l_fontscale_size_dim}
\nopagebreak\newline
\cs{l_fontscale_baselineskip_skip}
-\end{mydisplaycode}
+\end{displaycode}
Stores the current font step, font scale, font size, and font baselineskip.
-\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}).
-These variables are set in the \texttt{selectfont} hook.
+\cs{l_fontscale_step_fp} equals \cs{c_nan_fp} if the current font step is undefined (as explained for \cs{currentfontstep} in \S\ref{subsec:expandable}).
+These variables are set in the \hook{selectfont} hook.
\end{document}
\ No newline at end of file
Added: trunk/Master/texmf-dist/tex/latex/fontscale/fontscale-v3.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/fontscale/fontscale-v3.sty (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/fontscale/fontscale-v3.sty 2025-03-03 21:17:13 UTC (rev 74414)
@@ -0,0 +1,1355 @@
+%%% Package : fontscale -- A flexible interface for setting font sizes
+%%% 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
+
+%%> \section{Loading the package}
+
+% LaTeX2e version 2023-11-01 added \IfExplAtLeastTF.
+\NeedsTeXFormat{LaTeX2e}[2023-11-01]
+\ProvidesExplPackage
+ {fontscale}
+ {2025-02-13}
+ {3.1.2}
+ {A flexible interface for setting font sizes}
+
+% l3kernel version 2023-11-09 added documentation for \c_nan_fp.
+\IfExplAtLeastTF { 2023-11-09 } { }
+ {
+ \msg_new:nnn { fontscale } { l3kernel-out-of-date }
+ {
+ The~ fontscale~ package~ could~ not~ load. \\
+ This~ package~ requires~
+ L3~ programming~ layer~ version~ 2023-11-09~ or~ newer.
+ }
+ \msg_critical:nn { fontscale } { l3kernel-out-of-date }
+ }
+
+%%> \section{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~ '#2'~ \msg_line_context:. \\
+ The~ value~ of~ the~ key~ '#1 / scale'~ must~ be~ positive.
+ }
+\msg_new:nnn { fontscale } { key-font-size-out-of-bounds }
+ {
+ Invalid~ value~ '#2'~ \msg_line_context:. \\
+ The~ value~ of~ the~ key~ '#1 / 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:.
+ }
+
+%%> \section{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 }
+\fp_const:Nn \c_fontscale_small_step_fp { -1 }
+\fp_const:Nn \c_fontscale_normalsize_step_fp { 0 }
+\fp_const:Nn \c_fontscale_large_step_fp { 1 }
+\fp_const:Nn \c_fontscale_Large_step_fp { 2 }
+\fp_const:Nn \c_fontscale_LARGE_step_fp { 3 }
+\fp_const:Nn \c_fontscale_huge_step_fp { 4 }
+\fp_const:Nn \c_fontscale_Huge_step_fp { 5 }
+
+\fp_const:Nn \c_fontscale_normalsize_scale_fp { 1 }
+
+\fp_new:N \l_fontscale_tiny_scale_fp
+\fp_new:N \l_fontscale_scriptsize_scale_fp
+\fp_new:N \l_fontscale_footnotesize_scale_fp
+\fp_new:N \l_fontscale_small_scale_fp
+\fp_new:N \l_fontscale_large_scale_fp
+\fp_new:N \l_fontscale_Large_scale_fp
+\fp_new:N \l_fontscale_LARGE_scale_fp
+\fp_new:N \l_fontscale_huge_scale_fp
+\fp_new:N \l_fontscale_Huge_scale_fp
+
+\dim_new:N \l_fontscale_tiny_size_dim
+\dim_new:N \l_fontscale_scriptsize_size_dim
+\dim_new:N \l_fontscale_footnotesize_size_dim
+\dim_new:N \l_fontscale_small_size_dim
+\dim_new:N \l_fontscale_normalsize_size_dim
+\dim_new:N \l_fontscale_large_size_dim
+\dim_new:N \l_fontscale_Large_size_dim
+\dim_new:N \l_fontscale_LARGE_size_dim
+\dim_new:N \l_fontscale_huge_size_dim
+\dim_new:N \l_fontscale_Huge_size_dim
+
+\skip_new:N \l_fontscale_tiny_baselineskip_skip
+\skip_new:N \l_fontscale_scriptsize_baselineskip_skip
+\skip_new:N \l_fontscale_footnotesize_baselineskip_skip
+\skip_new:N \l_fontscale_small_baselineskip_skip
+\skip_new:N \l_fontscale_normalsize_baselineskip_skip
+\skip_new:N \l_fontscale_large_baselineskip_skip
+\skip_new:N \l_fontscale_Large_baselineskip_skip
+\skip_new:N \l_fontscale_LARGE_baselineskip_skip
+\skip_new:N \l_fontscale_huge_baselineskip_skip
+\skip_new:N \l_fontscale_Huge_baselineskip_skip
+
+\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 }
+\fp_set:Nn \l_fontscale_small_scale_fp { 0.9 }
+\fp_set:Nn \l_fontscale_large_scale_fp { 1.1 }
+\fp_set:Nn \l_fontscale_Large_scale_fp { 1.2 }
+\fp_set:Nn \l_fontscale_LARGE_scale_fp { 1.4 }
+\fp_set:Nn \l_fontscale_huge_scale_fp { 1.6 }
+\fp_set:Nn \l_fontscale_Huge_scale_fp { 1.8 }
+
+\dim_set:Nn \l_fontscale_tiny_size_dim { 6pt }
+\dim_set:Nn \l_fontscale_scriptsize_size_dim { 7pt }
+\dim_set:Nn \l_fontscale_footnotesize_size_dim { 8pt }
+\dim_set:Nn \l_fontscale_small_size_dim { 9pt }
+\dim_set:Nn \l_fontscale_normalsize_size_dim { 10pt }
+\dim_set:Nn \l_fontscale_large_size_dim { 11pt }
+\dim_set:Nn \l_fontscale_Large_size_dim { 12pt }
+\dim_set:Nn \l_fontscale_LARGE_size_dim { 14pt }
+\dim_set:Nn \l_fontscale_huge_size_dim { 16pt }
+\dim_set:Nn \l_fontscale_Huge_size_dim { 18pt }
+
+\skip_set:Nn \l_fontscale_tiny_baselineskip_skip { 7.2pt }
+\skip_set:Nn \l_fontscale_scriptsize_baselineskip_skip { 8.4pt }
+\skip_set:Nn \l_fontscale_footnotesize_baselineskip_skip { 9.6pt }
+\skip_set:Nn \l_fontscale_small_baselineskip_skip { 10.8pt }
+\skip_set:Nn \l_fontscale_normalsize_baselineskip_skip { 12 pt }
+\skip_set:Nn \l_fontscale_large_baselineskip_skip { 13.2pt }
+\skip_set:Nn \l_fontscale_Large_baselineskip_skip { 14.4pt }
+\skip_set:Nn \l_fontscale_LARGE_baselineskip_skip { 16.8pt }
+\skip_set:Nn \l_fontscale_huge_baselineskip_skip { 19.2pt }
+\skip_set:Nn \l_fontscale_Huge_baselineskip_skip { 21.6pt }
+
+% 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
+
+% For speed, \__fontscale_hook_code_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. \f at size and \f at baselineskip are not used
+% elsewhere in the code.
+\cs_new_protected:Npn \__fontscale_hook_code_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_code_selectfont_auxi: }
+ }
+\cs_new_protected:Npn \__fontscale_hook_code_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_code_selectfont_auxii: }
+ }
+\cs_new_protected:Npn \__fontscale_hook_code_selectfont_auxii:
+ {
+ \fp_set:Nn \l_fontscale_scale_fp
+ {
+ \dim_to_fp:n { \l_fontscale_size_dim } /
+ \l__fontscale_normalsize_size_fp
+ }
+ \str_if_eq:VnTF \l__fontscale_typographic_scale_str { musical }
+ {
+ \fp_set:Nn \l_fontscale_step_fp
+ {
+ \l__fontscale_musical_selectfont_fp *
+ ln
+ (
+ \dim_compare:nNnTF \l__fontscale_musical_base_dim =
+ \l_fontscale_normalsize_size_dim
+ { \l_fontscale_scale_fp }
+ {
+ \dim_to_fp:n { \l_fontscale_size_dim } /
+ \l__fontscale_musical_base_fp
+ }
+ )
+ }
+ }
+ { \fp_set_eq:NN \l_fontscale_step_fp \c_nan_fp }
+ }
+\hook_gput_code:nnn { selectfont } { fontscale }
+ { \__fontscale_hook_code_selectfont: }
+
+% 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
+
+\fp_const:Nn \c__fontscale_five_fp { 5 }
+
+% Scratch variables
+\dim_new:N \l__fontscale_tmp_dim
+\skip_new:N \l__fontscale_tmp_skip
+\fp_new:N \l__fontscale_tmp_fp
+
+%%> \section{Some functions}
+
+% Variants of l3kernel functions
+\cs_generate_variant:Nn \msg_error:nnnn { nnnv }
+% Sets a dimen/skip variable from a dimen/skip expression, appending a default
+% unit 'pt', and removes extra trailing tokens, if any.
+\cs_new_protected:Npn \__fontscale_dim_set_default_pt:Nn #1#2
+ {
+ \afterassignment \use_none_delimit_by_q_stop:w
+ #1 = \dimexpr #2 pt \relax
+ \q_stop
+ }
+\cs_generate_variant:Nn \__fontscale_dim_set_default_pt:Nn { c }
+\cs_new_protected:Npn \__fontscale_skip_set_default_pt:Nn #1#2
+ {
+ \afterassignment \use_none_delimit_by_q_stop:w
+ #1 = \glueexpr #2 pt \relax
+ \q_stop
+ }
+\cs_generate_variant:Nn \__fontscale_skip_set_default_pt:Nn { c }
+% Argument processors
+\cs_new_protected:Npn \__fontscale_arg_process_dim: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_process_skip: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 versions of the microtype package
+% older than v3.2 2024-12-12.
+\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 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 positive.
+\cs_new_protected:Npn \__fontscale_set_font_size:nn #1#2
+ {
+ \use:e
+ {
+ \__fontscale_set_font_size_aux:nn { \dim_eval:n {#1} }
+ { \skip_eval:n {#2} }
+ }
+ }
+\cs_new_protected:Npn \__fontscale_set_font_size_aux:nn #1#2
+ {
+ \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
+ { \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} > \c_zero_dim
+ {
+ \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} }
+ }
+\cs_new:Npn \__fontscale_fp_eval_round:n #1
+ { \fp_eval:n { round ( #1 , \c__fontscale_five_fp ) } }
+
+%%> \section{Define keys}
+
+\str_new:N \l__fontscale_typographic_scale_str
+\dim_new:N \l__fontscale_musical_base_dim
+
+\cs_new_protected:Npn \__fontscale_keys_code_musical_base:
+ {
+ \__fontscale_dim_set_default_pt:Nn \l__fontscale_musical_base_dim
+ { \l_keys_value_tl }
+ }
+\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 }
+ {
+ \tl_set_eq:cN { l__fontscale_ \l_keys_key_str _size_tl }
+ \l_keys_value_tl
+ }
+ }
+\cs_new_protected:Npn \__fontscale_keys_code_name:ww #1 / #2 \q_stop
+ {
+ \tl_set:cn { l__fontscale_ \l_keys_key_str _size_tl } {#1}
+ \tl_set:cn { l__fontscale_ \l_keys_key_str _baselineskip_tl } {#2}
+ }
+
+\keys_define:nn { fontscale }
+ {
+ baselineskip-size-ratio .fp_set:N =
+ \l__fontscale_baselineskip_size_ratio_fp
+ , baselineskip-size-ratio .value_required:n = true
+
+ , typographic-scale .choices:nn =
+ { classic-10pt , classic-11pt , classic-12pt , musical }
+ { \str_set:Nn \l__fontscale_typographic_scale_str {#1} }
+ , typographic-scale .value_required:n = true
+
+ , classic-10pt .meta:n = { typographic-scale = classic-10pt }
+ , classic-10pt .value_forbidden:n = true
+
+ , classic-11pt .meta:n = { typographic-scale = classic-11pt }
+ , classic-11pt .value_forbidden:n = true
+
+ , classic-12pt .meta:n = { typographic-scale = classic-12pt }
+ , classic-12pt .value_forbidden:n = true
+
+ , musical .meta:n = { typographic-scale = musical }
+ , musical .value_forbidden:n = true
+ }
+\keys_define:nn { fontscale / musical }
+ {
+ base .code:n = \__fontscale_keys_code_musical_base:
+ , base .value_required:n = true
+
+ , ratio .fp_set:N = \l__fontscale_musical_ratio_fp
+ , ratio .value_required:n = true
+
+ , notes .int_set:N = \l__fontscale_musical_notes_int
+ , notes .value_required:n = true
+ }
+\keys_define:nn { fontscale / normalsize }
+ {
+ size .tl_set:N = \l__fontscale_normalsize_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_normalsize_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale / tiny }
+ {
+ scale .tl_set:N = \l__fontscale_tiny_scale_tl
+ , scale .value_required:n = true
+
+ , size .tl_set:N = \l__fontscale_tiny_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_tiny_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale / scriptsize }
+ {
+ scale .tl_set:N = \l__fontscale_scriptsize_scale_tl
+ , scale .value_required:n = true
+
+ , size .tl_set:N = \l__fontscale_scriptsize_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_scriptsize_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale / footnotesize }
+ {
+ scale .tl_set:N = \l__fontscale_footnotesize_scale_tl
+ , scale .value_required:n = true
+
+ , size .tl_set:N = \l__fontscale_footnotesize_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_footnotesize_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale / small }
+ {
+ scale .tl_set:N = \l__fontscale_small_scale_tl
+ , scale .value_required:n = true
+
+ , size .tl_set:N = \l__fontscale_small_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_small_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale / large }
+ {
+ scale .tl_set:N = \l__fontscale_large_scale_tl
+ , scale .value_required:n = true
+
+ , size .tl_set:N = \l__fontscale_large_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_large_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale / Large }
+ {
+ scale .tl_set:N = \l__fontscale_Large_scale_tl
+ , scale .value_required:n = true
+
+ , size .tl_set:N = \l__fontscale_Large_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_Large_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale / LARGE }
+ {
+ scale .tl_set:N = \l__fontscale_LARGE_scale_tl
+ , scale .value_required:n = true
+
+ , size .tl_set:N = \l__fontscale_LARGE_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_LARGE_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale / huge }
+ {
+ scale .tl_set:N = \l__fontscale_huge_scale_tl
+ , scale .value_required:n = true
+
+ , size .tl_set:N = \l__fontscale_huge_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_huge_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale / Huge }
+ {
+ scale .tl_set:N = \l__fontscale_Huge_scale_tl
+ , scale .value_required:n = true
+
+ , size .tl_set:N = \l__fontscale_Huge_size_tl
+ , size .value_required:n = true
+
+ , baselineskip .tl_set:N = \l__fontscale_Huge_baselineskip_tl
+ , baselineskip .value_required:n = true
+ }
+\keys_define:nn { fontscale }
+ {
+ tiny .code:n = \__fontscale_keys_code_name:
+ , tiny .value_required:n = true
+
+ , scriptsize .code:n = \__fontscale_keys_code_name:
+ , scriptsize .value_required:n = true
+
+ , footnotesize .code:n = \__fontscale_keys_code_name:
+ , footnotesize .value_required:n = true
+
+ , small .code:n = \__fontscale_keys_code_name:
+ , small .value_required:n = true
+
+ , normalsize .code:n = \__fontscale_keys_code_name:
+ , normalsize .value_required:n = true
+
+ , large .code:n = \__fontscale_keys_code_name:
+ , large .value_required:n = true
+
+ , Large .code:n = \__fontscale_keys_code_name:
+ , Large .value_required:n = true
+
+ , LARGE .code:n = \__fontscale_keys_code_name:
+ , LARGE .value_required:n = true
+
+ , huge .code:n = \__fontscale_keys_code_name:
+ , huge .value_required:n = true
+
+ , Huge .code:n = \__fontscale_keys_code_name:
+ , Huge .value_required:n = true
+ }
+
+%%> \section{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. The special value of \q_no_value is used to test if the
+% corresponding key has been set by the user.
+\cs_new_protected:Npn \__fontscale_keys_set_initial:
+ {
+ \fp_set:Nn \l__fontscale_baselineskip_size_ratio_fp { 1.2 }
+ \str_set:Nn \l__fontscale_typographic_scale_str { classic-10pt }
+ \dim_set:Nn \l__fontscale_musical_base_dim { 10pt }
+ \fp_set:Nn \l__fontscale_musical_ratio_fp { 2 }
+ \int_set:Nn \l__fontscale_musical_notes_int { 5 }
+
+ \tl_map_inline:nn
+ {
+ \l__fontscale_tiny_scale_tl
+ \l__fontscale_scriptsize_scale_tl
+ \l__fontscale_footnotesize_scale_tl
+ \l__fontscale_small_scale_tl
+ \l__fontscale_large_scale_tl
+ \l__fontscale_Large_scale_tl
+ \l__fontscale_LARGE_scale_tl
+ \l__fontscale_huge_scale_tl
+ \l__fontscale_Huge_scale_tl
+
+ \l__fontscale_tiny_size_tl
+ \l__fontscale_scriptsize_size_tl
+ \l__fontscale_footnotesize_size_tl
+ \l__fontscale_small_size_tl
+ \l__fontscale_normalsize_size_tl
+ \l__fontscale_large_size_tl
+ \l__fontscale_Large_size_tl
+ \l__fontscale_LARGE_size_tl
+ \l__fontscale_huge_size_tl
+ \l__fontscale_Huge_size_tl
+
+ \l__fontscale_tiny_baselineskip_tl
+ \l__fontscale_scriptsize_baselineskip_tl
+ \l__fontscale_footnotesize_baselineskip_tl
+ \l__fontscale_small_baselineskip_tl
+ \l__fontscale_normalsize_baselineskip_tl
+ \l__fontscale_large_baselineskip_tl
+ \l__fontscale_Large_baselineskip_tl
+ \l__fontscale_LARGE_baselineskip_tl
+ \l__fontscale_huge_baselineskip_tl
+ \l__fontscale_Huge_baselineskip_tl
+ }
+ { \tl_set:Nn ##1 { \q_no_value } }
+ }
+\__fontscale_keys_set_initial:
+
+%%> \section{Set and process keys}
+
+\NewDocumentCommand \fontscalesetup { s m }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \fontscalesetup }
+ }
+ {
+ \IfBooleanTF #1
+ { \__fontscale_keys_reset:n {#2} }
+ { \__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}
+ \__fontscale_keys_process:
+ \normalsize
+ \prg_break:
+ \prg_break_point:
+ }
+\cs_new_protected:Npn \__fontscale_keys_process:
+ {
+ \__fontscale_keys_process_start:
+ \__fontscale_keys_process_normalsize:
+ \__fontscale_keys_process_other:
+ \__fontscale_keys_process_check_order:
+ }
+\cs_new_protected:Npn \__fontscale_keys_process_start:
+ {
+ \dim_compare:nNnF \l__fontscale_musical_base_dim > \c_zero_dim
+ {
+ \msg_error:nnV { fontscale } { key-musical-base-out-of-bounds }
+ \l__fontscale_musical_base_dim
+ \prg_break:
+ }
+ \fp_compare:nNnF \l__fontscale_musical_ratio_fp > \c_one_fp
+ {
+ \msg_error:nne { fontscale } { key-musical-ratio-out-of-bounds }
+ { \fp_use:N \l__fontscale_musical_ratio_fp }
+ \prg_break:
+ }
+ \int_compare:nNnF \l__fontscale_musical_notes_int > 0
+ {
+ \msg_error:nnV { fontscale } { key-musical-notes-out-of-bounds }
+ \l__fontscale_musical_notes_int
+ \prg_break:
+ }
+ }
+% Sets the font size and font baselineskip of \normalsize. Its font size must
+% be set before doing any processing involving the font scale.
+\cs_new_protected:Npn \__fontscale_keys_process_normalsize:
+ {
+ \quark_if_no_value:NTF \l__fontscale_normalsize_size_tl
+ {
+ \dim_set:Nn \l_fontscale_normalsize_size_dim
+ {
+ \str_case:Vn \l__fontscale_typographic_scale_str
+ {
+ { classic-10pt } { 10pt }
+ { classic-11pt } { 11pt }
+ { classic-12pt } { 12pt }
+ { musical } { \l__fontscale_musical_base_dim }
+ }
+ }
+ }
+ {
+ \__fontscale_dim_set_default_pt:Nn \l_fontscale_normalsize_size_dim
+ { \l__fontscale_normalsize_size_tl }
+ \dim_compare:nNnF \l_fontscale_normalsize_size_dim > \c_zero_dim
+ {
+ \msg_error:nnnV { fontscale } { key-font-size-out-of-bounds }
+ { normalsize } \l_fontscale_normalsize_size_dim
+ \prg_break:
+ }
+ }
+ \fp_set:Nn \l__fontscale_normalsize_size_fp
+ { \dim_to_fp:n { \l_fontscale_normalsize_size_dim } }
+ \quark_if_no_value:NTF \l__fontscale_normalsize_baselineskip_tl
+ {
+ \skip_set:Nn \l_fontscale_normalsize_baselineskip_skip
+ {
+ \fp_to_dim:n
+ {
+ \l__fontscale_normalsize_size_fp *
+ \l__fontscale_baselineskip_size_ratio_fp
+ }
+ }
+ }
+ {
+ \__fontscale_skip_set_default_pt:Nn
+ \l_fontscale_normalsize_baselineskip_skip
+ { \l__fontscale_normalsize_baselineskip_tl }
+ }
+ }
+% Auxiliary functions that expand to the font size depending on the name of the
+% font size command.
+\cs_new:Npn \__fontscale_keys_process_other_classic_xpt:n #1
+ {
+ \str_case:nn {#1}
+ {
+ { tiny } { 6pt }
+ { scriptsize } { 7pt }
+ { footnotesize } { 8pt }
+ { small } { 9pt }
+ { large } { 11pt }
+ { Large } { 12pt }
+ { LARGE } { 14pt }
+ { huge } { 16pt }
+ { Huge } { 18pt }
+ }
+ }
+\cs_new:Npn \__fontscale_keys_process_other_classic_xipt:n #1
+ {
+ \str_case:nn {#1}
+ {
+ { tiny } { 7pt }
+ { scriptsize } { 8pt }
+ { footnotesize } { 9pt }
+ { small } { 10pt }
+ { large } { 12pt }
+ { Large } { 14pt }
+ { LARGE } { 16pt }
+ { huge } { 18pt }
+ { Huge } { 21pt }
+ }
+ }
+\cs_new:Npn \__fontscale_keys_process_other_classic_xiipt:n #1
+ {
+ \str_case:nn {#1}
+ {
+ { tiny } { 8pt }
+ { scriptsize } { 9pt }
+ { footnotesize } { 10pt }
+ { small } { 11pt }
+ { large } { 14pt }
+ { Large } { 16pt }
+ { LARGE } { 18pt }
+ { huge } { 21pt }
+ { Huge } { 24pt }
+ }
+ }
+\cs_new:Npn \__fontscale_keys_process_other_musical:n #1
+ {
+ \fp_to_dim:n
+ {
+ \l__fontscale_musical_base_fp * \l__fontscale_musical_ratio_fp ^
+ ( \use:c { c_fontscale_#1_step_fp } / \l__fontscale_musical_notes_fp )
+ }
+ }
+% Sets the font size, font scale, and font baselineskip of the other font size
+% commands.
+\cs_new_protected:Npn \__fontscale_keys_process_other:
+ {
+ \str_case:Vn \l__fontscale_typographic_scale_str
+ {
+ { classic-10pt }
+ {
+ \cs_set_eq:NN \__fontscale_keys_process_other_fn_aux:n
+ \__fontscale_keys_process_other_classic_xpt:n
+ }
+ { classic-11pt }
+ {
+ \cs_set_eq:NN \__fontscale_keys_process_other_fn_aux:n
+ \__fontscale_keys_process_other_classic_xipt:n
+ }
+ { classic-12pt }
+ {
+ \cs_set_eq:NN \__fontscale_keys_process_other_fn_aux:n
+ \__fontscale_keys_process_other_classic_xiipt:n
+ }
+ { musical }
+ {
+ \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
+ { \dim_to_fp:n { \l__fontscale_musical_base_dim } }
+ \fp_set:Nn \l__fontscale_musical_notes_fp
+ { \int_use:N \l__fontscale_musical_notes_int }
+ \fp_set:Nn \l__fontscale_musical_selectfont_fp
+ {
+ \int_use:N \l__fontscale_musical_notes_int /
+ ln ( \l__fontscale_musical_ratio_fp )
+ }
+ }
+ }
+ \tl_map_function:nN
+ {
+ {tiny} {scriptsize} {footnotesize} {small}
+ {large} {Large} {LARGE} {huge} {Huge}
+ }
+ \__fontscale_keys_process_other_fn:n
+ }
+\cs_new_protected:Npn \__fontscale_keys_process_other_fn:n #1
+ {
+ \quark_if_no_value:cF { l__fontscale_#1_scale_tl }
+ {
+ \dim_set:cn { l_fontscale_#1_size_dim }
+ {
+ \fp_to_dim:n
+ {
+ \l__fontscale_normalsize_size_fp *
+ ( \use:c { l__fontscale_#1_scale_tl } )
+ }
+ }
+ \dim_compare:nNnF { \use:c { l_fontscale_#1_size_dim } } > \c_zero_dim
+ {
+ \tl_map_break:n
+ {
+ \msg_error:nnne { fontscale } { key-font-scale-out-of-bounds }
+ {#1} { \fp_eval:n { \use:c { l__fontscale_#1_scale_tl } } }
+ \prg_break:
+ }
+ }
+ \quark_if_no_value:cT { l__fontscale_#1_size_tl } { \prg_break: }
+ }
+ \quark_if_no_value:cF { l__fontscale_#1_size_tl }
+ {
+ \__fontscale_dim_set_default_pt:cn { l_fontscale_#1_size_dim }
+ { \use:c { l__fontscale_#1_size_tl } }
+ \dim_compare:nNnF { \use:c { l_fontscale_#1_size_dim } } > \c_zero_dim
+ {
+ \tl_map_break:n
+ {
+ \msg_error:nnnv { fontscale } { key-font-size-out-of-bounds }
+ {#1} { l_fontscale_#1_size_dim }
+ \prg_break:
+ }
+ }
+ \quark_if_no_value:cF { l__fontscale_#1_scale_tl }
+ {
+ \msg_warning:nnn { fontscale } { key-font-scale-overwritten } {#1}
+ }
+ \prg_break:
+ }
+ \dim_set:cn { l_fontscale_#1_size_dim }
+ { \__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_fp
+ }
+ \quark_if_no_value:cTF { l__fontscale_#1_baselineskip_tl }
+ {
+ \skip_set:cn { l_fontscale_#1_baselineskip_skip }
+ {
+ \fp_to_dim:n
+ {
+ \dim_to_fp:n { \use:c { l_fontscale_#1_size_dim } } *
+ \l__fontscale_baselineskip_size_ratio_fp
+ }
+ }
+ }
+ {
+ \__fontscale_skip_set_default_pt:cn
+ { l_fontscale_#1_baselineskip_skip }
+ { \use:c { l__fontscale_#1_baselineskip_tl } }
+ }
+ }
+% Issues a warning if the font sizes are not in the correct order.
+\cs_new_protected:Npn \__fontscale_keys_process_check_order:
+ {
+ \dim_compare:nF
+ {
+ \l_fontscale_tiny_size_dim
+ < \l_fontscale_scriptsize_size_dim
+ < \l_fontscale_footnotesize_size_dim
+ < \l_fontscale_small_size_dim
+ < \l_fontscale_normalsize_size_dim
+ < \l_fontscale_large_size_dim
+ < \l_fontscale_Large_size_dim
+ < \l_fontscale_LARGE_size_dim
+ < \l_fontscale_huge_size_dim
+ < \l_fontscale_Huge_size_dim
+ }
+ { \msg_warning:nn { fontscale } { font-sizes-out-of-order } }
+ }
+
+%%> \section{Document commands}
+
+% Defines the standard LaTeX font size commands from \tiny to \Huge and
+% initializes to \normalsize. Their internal functions are not used elsewhere
+% in the code for compatibility with hooks such as
+% \AddToHook{cmd/<font size command>/after}{<code>}.
+\DeclareDocumentCommand \tiny { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \tiny }
+ }
+ { \__fontscale_tiny: }
+ }
+\cs_new_protected:Npn \__fontscale_tiny:
+ {
+ \__fontscale_name:NNN \tiny \l_fontscale_tiny_size_dim
+ \l_fontscale_tiny_baselineskip_skip
+ }
+\DeclareDocumentCommand \scriptsize { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \scriptsize }
+ }
+ { \__fontscale_scriptsize: }
+ }
+\cs_new_protected:Npn \__fontscale_scriptsize:
+ {
+ \__fontscale_name:NNN \scriptsize \l_fontscale_scriptsize_size_dim
+ \l_fontscale_scriptsize_baselineskip_skip
+ }
+\DeclareDocumentCommand \footnotesize { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \footnotesize }
+ }
+ { \__fontscale_footnotesize: }
+ }
+\cs_new_protected:Npn \__fontscale_footnotesize:
+ {
+ \__fontscale_name:NNN \footnotesize \l_fontscale_footnotesize_size_dim
+ \l_fontscale_footnotesize_baselineskip_skip
+ }
+\DeclareDocumentCommand \small { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \small }
+ }
+ { \__fontscale_small: }
+ }
+\cs_new_protected:Npn \__fontscale_small:
+ {
+ \__fontscale_name:NNN \small \l_fontscale_small_size_dim
+ \l_fontscale_small_baselineskip_skip
+ }
+\DeclareDocumentCommand \normalsize { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \normalsize }
+ }
+ { \__fontscale_normalsize: }
+ }
+\cs_new_protected:Npn \__fontscale_normalsize:
+ {
+ \__fontscale_name:NNN \normalsize \l_fontscale_normalsize_size_dim
+ \l_fontscale_normalsize_baselineskip_skip
+ }
+\DeclareDocumentCommand \large { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \large }
+ }
+ { \__fontscale_large: }
+ }
+\cs_new_protected:Npn \__fontscale_large:
+ {
+ \__fontscale_name:NNN \large \l_fontscale_large_size_dim
+ \l_fontscale_large_baselineskip_skip
+ }
+\DeclareDocumentCommand \Large { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \Large }
+ }
+ { \__fontscale_Large: }
+ }
+\cs_new_protected:Npn \__fontscale_Large:
+ {
+ \__fontscale_name:NNN \Large \l_fontscale_Large_size_dim
+ \l_fontscale_Large_baselineskip_skip
+ }
+\DeclareDocumentCommand \LARGE { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \LARGE }
+ }
+ { \__fontscale_LARGE: }
+ }
+\cs_new_protected:Npn \__fontscale_LARGE:
+ {
+ \__fontscale_name:NNN \LARGE \l_fontscale_LARGE_size_dim
+ \l_fontscale_LARGE_baselineskip_skip
+ }
+\DeclareDocumentCommand \huge { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \huge }
+ }
+ { \__fontscale_huge: }
+ }
+\cs_new_protected:Npn \__fontscale_huge:
+ {
+ \__fontscale_name:NNN \huge \l_fontscale_huge_size_dim
+ \l_fontscale_huge_baselineskip_skip
+ }
+\DeclareDocumentCommand \Huge { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \Huge }
+ }
+ { \__fontscale_Huge: }
+ }
+\cs_new_protected:Npn \__fontscale_Huge:
+ {
+ \__fontscale_name:NNN \Huge \l_fontscale_Huge_size_dim
+ \l_fontscale_Huge_baselineskip_skip
+ }
+\normalsize
+
+\NewExpandableDocumentCommand \CurrentFontStep { } { \__fontscale_step: }
+\cs_new:Npn \__fontscale_step:
+ { \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_use:N \l_fontscale_scale_fp }
+
+\NewExpandableDocumentCommand \CurrentFontSize { } { \__fontscale_size: }
+\cs_new:Npn \__fontscale_size: { \dim_use:N \l_fontscale_size_dim }
+
+\NewExpandableDocumentCommand \CurrentFontBaselineskip { }
+ { \__fontscale_baselineskip: }
+\cs_new:Npn \__fontscale_baselineskip:
+ { \skip_use:N \l_fontscale_baselineskip_skip }
+
+\NewDocumentCommand \SetFontStep { s m }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \SetFontStep }
+ }
+ {
+ \IfBooleanTF #1
+ { \__fontscale_add_font_step:n {#2} }
+ { \__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 } }
+ }
+\cs_new_protected:Npn \__fontscale_set_font_step:n #1
+ {
+ \fp_set:Nn \l__fontscale_tmp_fp {#1}
+ \str_case:enF { \__fontscale_fp_eval_round:n { \l__fontscale_tmp_fp } }
+ {
+ { -4 } { \tiny }
+ { -3 } { \scriptsize }
+ { -2 } { \footnotesize }
+ { -1 } { \small }
+ { 0 } { \normalsize }
+ { 1 } { \large }
+ { 2 } { \Large }
+ { 3 } { \LARGE }
+ { 4 } { \huge }
+ { 5 } { \Huge }
+ }
+ {
+ \str_if_eq:VnTF \l__fontscale_typographic_scale_str { musical }
+ {
+ \__fontscale_set_font_size:n
+ {
+ \fp_to_dim:n
+ {
+ \l__fontscale_musical_base_fp *
+ \l__fontscale_musical_ratio_fp ^
+ ( \l__fontscale_tmp_fp / \l__fontscale_musical_notes_fp )
+ }
+ }
+ }
+ {
+ \msg_error:nne { fontscale } { font-step-out-of-bounds }
+ { \fp_use:N \l__fontscale_tmp_fp }
+ }
+ }
+ }
+
+\NewDocumentCommand \SetFontScale { s m }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \SetFontScale }
+ }
+ {
+ \IfBooleanTF #1
+ { \__fontscale_add_font_scale:n {#2} }
+ { \__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_set_font_size:n
+ { \fp_to_dim:n { (#1) * \l__fontscale_normalsize_size_fp } }
+ }
+
+\NewDocumentCommand \SetFontSize { s >{ \__fontscale_arg_process_dim:n } m }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \SetFontSize }
+ }
+ {
+ \IfBooleanTF #1
+ { \__fontscale_add_font_size:n {#2} }
+ { \__fontscale_set_font_size:n {#2} }
+ }
+ }
+\cs_new_protected:Npn \__fontscale_add_font_size:n #1
+ { \__fontscale_set_font_size:n { (#1) + \l_fontscale_size_dim } }
+
+\NewDocumentCommand \ScaleFont { m }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \ScaleFont }
+ }
+ { \__fontscale_scale_font:n {#1} }
+ }
+\cs_new_protected:Npn \__fontscale_scale_font:n #1
+ {
+ \fp_set:Nn \l__fontscale_tmp_fp {#1}
+ \__fontscale_set_font_size:nn
+ {
+ \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
+ {
+ >{ \__fontscale_arg_process_dim:n } m
+ >{ \__fontscale_arg_process_skip:n } m
+ }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \SetFontSizeBaselineskip }
+ }
+ { \__fontscale_set_font_size:nn {#1} {#2} }
+ }
+
+\NewDocumentCommand \SetFontBaselineskip
+ { s >{ \__fontscale_arg_process_skip:n } m }
+ {
+ \mode_if_math:TF
+ {
+ \msg_warning:nne { fontscale } { math-mode-warning }
+ { \token_to_str:N \SetFontBaselineskip }
+ }
+ {
+ \IfBooleanTF #1
+ { \__fontscale_add_font_baselineskip:n {#2} }
+ { \__fontscale_set_font_baselineskip:n {#2} }
+ }
+ }
+\cs_new_protected:Npn \__fontscale_add_font_baselineskip:n #1
+ {
+ \__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: }
+\cs_new_protected:Npn \__fontscale_print_font_size_parameters:
+ {
+ step~ =~
+ \fp_if_nan:nF { \l_fontscale_step_fp }
+ { \__fontscale_fp_eval_round:n { \l_fontscale_step_fp } }
+ ,~
+ scale~ =~ \__fontscale_fp_eval_round:n { \l_fontscale_scale_fp } ,~
+ size~ =~ \dim_use:N \l_fontscale_size_dim ,~
+ baselineskip~ =~ \skip_use:N \l_fontscale_baselineskip_skip
+ }
+
+\NewDocumentCommand \PrintAllFontSizeParameters { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_error:nne { fontscale } { math-mode-error }
+ { \token_to_str:N \PrintAllFontSizeParameters }
+ }
+ { \__fontscale_print_all_font_size_parameters: }
+ }
+\cs_new_protected:Npn \__fontscale_print_all_font_size_parameters:
+ {
+ \tl_map_inline:nn
+ {
+ {tiny} {scriptsize} {footnotesize} {small} {normalsize}
+ {large} {Large} {LARGE} {huge} {Huge}
+ }
+ {
+ \token_to_str:c {##1} \@ \c_colon_str \c_space_tl
+ step~ =~ \fp_use:c { c_fontscale_##1_step_fp } ,~
+ scale~ =~
+ \str_if_eq:nnTF {##1} { normalsize }
+ { 1 }
+ {
+ \__fontscale_fp_eval_round:n
+ { \use:c { l_fontscale_##1_scale_fp } }
+ }
+ ,~
+ size~ =~ \dim_use:c { l_fontscale_##1_size_dim } ,~
+ baselineskip~ =~ \skip_use:c { l_fontscale_##1_baselineskip_skip }
+ \str_if_eq:nnF {##1} { Huge } { \newline }
+ }
+ }
+
+\NewDocumentCommand \PrintSampleText { >{ \ReverseBoolean } s +m }
+ {
+ \mode_if_math:TF
+ {
+ \msg_error:nne { fontscale } { math-mode-error }
+ { \token_to_str:N \PrintSampleText }
+ }
+ {
+ \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
+ {
+ \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
+ {
+ \group_begin:
+ \tl_map_inline:nn
+ {
+ \Huge \huge \LARGE \Large \large
+ \normalsize \small \footnotesize \scriptsize \tiny
+ }
+ { ##1 #1 \par }
+ \group_end:
+ }
+
+\NewDocumentCommand \PrintFontSizeCommand { }
+ {
+ \mode_if_math:TF
+ {
+ \msg_error:nne { fontscale } { math-mode-error }
+ { \token_to_str:N \PrintFontSizeCommand }
+ }
+ { \__fontscale_print_name: }
+ }
+\cs_new_protected:Npn \__fontscale_print_name:
+ {
+ \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 }
+ }
+ \@
+ }
+
+%%> \section{Purifying text}
+
+\NewExpandableDocumentCommand \__fontscale_use_none_sm:w { s m } { }
+\tl_map_inline:nn
+ {
+ \fontscalesetup
+ \SetFontStep
+ \SetFontScale
+ \SetFontSize
+ \SetFontBaselineskip
+ }
+ { \text_declare_purify_equivalent:Nn #1 { \__fontscale_use_none_sm:w } }
+\text_declare_purify_equivalent:Nn \ScaleFont { \use_none:n }
+\text_declare_purify_equivalent:Nn \SetFontSizeBaselineskip { \use_none:nn }
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/tex/latex/fontscale/fontscale-v3.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty 2025-03-03 21:16:35 UTC (rev 74413)
+++ trunk/Master/texmf-dist/tex/latex/fontscale/fontscale.sty 2025-03-03 21:17:13 UTC (rev 74414)
@@ -8,10 +8,9 @@
% LaTeX2e version 2023-11-01 added \IfExplAtLeastTF.
\NeedsTeXFormat{LaTeX2e}[2023-11-01]
-\ProvidesExplPackage
- {fontscale}
- {2025-02-13}
- {3.1.2}
+\DeclareRelease{v3}{2025-02-13}{fontscale-v3.sty}
+\DeclareCurrentRelease{}{2025-03-02}
+\ProvidesExplPackage{fontscale}{2025-03-02}{4.0.0}
{A flexible interface for setting font sizes}
% l3kernel version 2023-11-09 added documentation for \c_nan_fp.
@@ -26,30 +25,43 @@
\msg_critical:nn { fontscale } { l3kernel-out-of-date }
}
+% fontscale defines \scalefont.
+\cs_new_protected:Npn \__fontscale_hook_scalefnt:
+ {
+ \msg_new:nnn { fontscale } { package-scalefnt-incompatible }
+ {
+ The~ fontscale~ package~ is~ incompatible~ with~ the~ 'scalefnt'~
+ package.
+ }
+ \msg_error:nn { fontscale } { package-scalefnt-incompatible }
+ }
+\hook_gput_code:nnn { package / scalefnt / before } { fontscale }
+ { \__fontscale_hook_scalefnt: }
+
%%> \section{Messages}
-\msg_new:nnn { fontscale } { key-musical-base-out-of-bounds }
+\msg_new:nnn { fontscale } { key-musical-base-invalid }
{
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 }
+\msg_new:nnn { fontscale } { key-musical-ratio-invalid }
{
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 }
+\msg_new:nnn { fontscale } { key-musical-notes-invalid }
{
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 }
+\msg_new:nnn { fontscale } { key-font-scale-invalid }
{
Invalid~ value~ '#2'~ \msg_line_context:. \\
The~ value~ of~ the~ key~ '#1 / scale'~ must~ be~ positive.
}
-\msg_new:nnn { fontscale } { key-font-size-out-of-bounds }
+\msg_new:nnn { fontscale } { key-font-size-invalid }
{
Invalid~ value~ '#2'~ \msg_line_context:. \\
The~ value~ of~ the~ key~ '#1 / size'~ must~ be~ a~ positive~ length.
@@ -59,7 +71,7 @@
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 }
+\msg_new:nnn { fontscale } { font-sizes-wrong-order }
{
The~ font~ sizes~ are~ not~ in~ the~ correct~ order~ \msg_line_context:. \\
The~ lengths~ of~ the~ font~ sizes~ should~ be~ ordered~ from~
@@ -75,12 +87,12 @@
% \@ 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 }
+\msg_new:nnn { fontscale } { font-size-invalid }
{
Invalid~ font~ size~ '#1'~ \msg_line_context:. \\
The~ font~ size~ must~ be~ a~ positive~ length.
}
-\msg_new:nnn { fontscale } { font-step-out-of-bounds }
+\msg_new:nnn { fontscale } { font-step-invalid }
{
Invalid~ font~ step~ '#1'~ \msg_line_context:. \\
The~ font~ step~ must~ equal~ the~ font~ step~ of~
@@ -87,7 +99,7 @@
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 }
+\msg_new:nnn { fontscale } { current-font-step-invalid }
{
The~ new~ font~ step~ could~ not~ be~ calculated~
because~ the~ current~ font~ step~ is~ undefined~ \msg_line_context:.
@@ -182,13 +194,13 @@
\dim_new:N \l_fontscale_size_dim
\skip_new:N \l_fontscale_baselineskip_skip
-% For speed, \__fontscale_hook_code_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. \f at size and \f at baselineskip are not used
-% elsewhere in the code.
-\cs_new_protected:Npn \__fontscale_hook_code_selectfont:
+% 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. \f at size and \f at baselineskip are not used elsewhere in
+% this package.
+\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 }
@@ -197,9 +209,9 @@
\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_code_selectfont_auxi: }
+ { \__fontscale_hook_selectfont_auxi: }
}
-\cs_new_protected:Npn \__fontscale_hook_code_selectfont_auxi:
+\cs_new_protected:Npn \__fontscale_hook_selectfont_auxi:
{
\dim_case:nnF { \l_fontscale_size_dim }
{
@@ -250,9 +262,9 @@
\fp_set_eq:NN \l_fontscale_scale_fp \l_fontscale_Huge_scale_fp
}
}
- { \__fontscale_hook_code_selectfont_auxii: }
+ { \__fontscale_hook_selectfont_auxii: }
}
-\cs_new_protected:Npn \__fontscale_hook_code_selectfont_auxii:
+\cs_new_protected:Npn \__fontscale_hook_selectfont_auxii:
{
\fp_set:Nn \l_fontscale_scale_fp
{
@@ -279,7 +291,7 @@
{ \fp_set_eq:NN \l_fontscale_step_fp \c_nan_fp }
}
\hook_gput_code:nnn { selectfont } { fontscale }
- { \__fontscale_hook_code_selectfont: }
+ { \__fontscale_hook_selectfont: }
% Used only to speed up floating point calculations.
\fp_new:N \l__fontscale_normalsize_size_fp
@@ -290,50 +302,13 @@
\fp_const:Nn \c__fontscale_five_fp { 5 }
-% Scratch variables
-\dim_new:N \l__fontscale_tmp_dim
-\skip_new:N \l__fontscale_tmp_skip
-\fp_new:N \l__fontscale_tmp_fp
+% Scratch variable
+\fp_new:N \l__fontscale_tmp_fp
%%> \section{Some functions}
% Variants of l3kernel functions
\cs_generate_variant:Nn \msg_error:nnnn { nnnv }
-% Sets a dimen/skip variable from a dimen/skip expression, appending a default
-% unit 'pt', and removes extra trailing tokens, if any.
-\cs_new_protected:Npn \__fontscale_dim_set_default_pt:Nn #1#2
- {
- \afterassignment \use_none_delimit_by_q_stop:w
- #1 = \dimexpr #2 pt \relax
- \q_stop
- }
-\cs_generate_variant:Nn \__fontscale_dim_set_default_pt:Nn { c }
-\cs_new_protected:Npn \__fontscale_skip_set_default_pt:Nn #1#2
- {
- \afterassignment \use_none_delimit_by_q_stop:w
- #1 = \glueexpr #2 pt \relax
- \q_stop
- }
-\cs_generate_variant:Nn \__fontscale_skip_set_default_pt:Nn { c }
-% Argument processors
-\cs_new_protected:Npn \__fontscale_arg_process_dim: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_process_skip: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 versions of the microtype package
-% older than v3.2 2024-12-12.
-\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 without appending a default
% unit of 'pt'.
@@ -352,7 +327,7 @@
{
\dim_compare:nNnTF {#1} > \c_zero_dim
{ \fontsize {#1} {#2} \selectfont }
- { \msg_error:nnn { fontscale } { font-size-out-of-bounds } {#1} }
+ { \msg_error:nnn { fontscale } { font-size-invalid } {#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.
@@ -369,7 +344,7 @@
}
\selectfont
}
- { \msg_error:nnn { fontscale } { font-size-out-of-bounds } {#1} }
+ { \msg_error:nnn { fontscale } { font-size-invalid } {#1} }
}
\cs_new:Npn \__fontscale_fp_eval_round:n #1
{ \fp_eval:n { round ( #1 , \c__fontscale_five_fp ) } }
@@ -377,28 +352,7 @@
%%> \section{Define keys}
\str_new:N \l__fontscale_typographic_scale_str
-\dim_new:N \l__fontscale_musical_base_dim
-\cs_new_protected:Npn \__fontscale_keys_code_musical_base:
- {
- \__fontscale_dim_set_default_pt:Nn \l__fontscale_musical_base_dim
- { \l_keys_value_tl }
- }
-\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 }
- {
- \tl_set_eq:cN { l__fontscale_ \l_keys_key_str _size_tl }
- \l_keys_value_tl
- }
- }
-\cs_new_protected:Npn \__fontscale_keys_code_name:ww #1 / #2 \q_stop
- {
- \tl_set:cn { l__fontscale_ \l_keys_key_str _size_tl } {#1}
- \tl_set:cn { l__fontscale_ \l_keys_key_str _baselineskip_tl } {#2}
- }
-
\keys_define:nn { fontscale }
{
baselineskip-size-ratio .fp_set:N =
@@ -424,7 +378,7 @@
}
\keys_define:nn { fontscale / musical }
{
- base .code:n = \__fontscale_keys_code_musical_base:
+ base .dim_set:N = \l__fontscale_musical_base_dim
, base .value_required:n = true
, ratio .fp_set:N = \l__fontscale_musical_ratio_fp
@@ -441,135 +395,54 @@
, baselineskip .tl_set:N = \l__fontscale_normalsize_baselineskip_tl
, baselineskip .value_required:n = true
}
-\keys_define:nn { fontscale / tiny }
+\tl_map_inline:nn
{
- scale .tl_set:N = \l__fontscale_tiny_scale_tl
- , scale .value_required:n = true
-
- , size .tl_set:N = \l__fontscale_tiny_size_tl
- , size .value_required:n = true
-
- , baselineskip .tl_set:N = \l__fontscale_tiny_baselineskip_tl
- , baselineskip .value_required:n = true
+ {tiny} {scriptsize} {footnotesize} {small}
+ {large} {Large} {LARGE} {huge} {Huge}
}
-\keys_define:nn { fontscale / scriptsize }
{
- scale .tl_set:N = \l__fontscale_scriptsize_scale_tl
- , scale .value_required:n = true
+ \keys_define:nn { fontscale / #1 }
+ {
+ scale .tl_set:c = { l__fontscale_#1_scale_tl }
+ , scale .value_required:n = true
- , size .tl_set:N = \l__fontscale_scriptsize_size_tl
- , size .value_required:n = true
+ , size .tl_set:c = { l__fontscale_#1_size_tl }
+ , size .value_required:n = true
- , baselineskip .tl_set:N = \l__fontscale_scriptsize_baselineskip_tl
- , baselineskip .value_required:n = true
+ , baselineskip .tl_set:c = { l__fontscale_#1_baselineskip_tl }
+ , baselineskip .value_required:n = true
+ }
}
-\keys_define:nn { fontscale / footnotesize }
- {
- scale .tl_set:N = \l__fontscale_footnotesize_scale_tl
- , scale .value_required:n = true
-
- , size .tl_set:N = \l__fontscale_footnotesize_size_tl
- , size .value_required:n = true
-
- , baselineskip .tl_set:N = \l__fontscale_footnotesize_baselineskip_tl
- , baselineskip .value_required:n = true
- }
-\keys_define:nn { fontscale / small }
- {
- scale .tl_set:N = \l__fontscale_small_scale_tl
- , scale .value_required:n = true
-
- , size .tl_set:N = \l__fontscale_small_size_tl
- , size .value_required:n = true
-
- , baselineskip .tl_set:N = \l__fontscale_small_baselineskip_tl
- , baselineskip .value_required:n = true
- }
-\keys_define:nn { fontscale / large }
- {
- scale .tl_set:N = \l__fontscale_large_scale_tl
- , scale .value_required:n = true
-
- , size .tl_set:N = \l__fontscale_large_size_tl
- , size .value_required:n = true
-
- , baselineskip .tl_set:N = \l__fontscale_large_baselineskip_tl
- , baselineskip .value_required:n = true
- }
-\keys_define:nn { fontscale / Large }
- {
- scale .tl_set:N = \l__fontscale_Large_scale_tl
- , scale .value_required:n = true
-
- , size .tl_set:N = \l__fontscale_Large_size_tl
- , size .value_required:n = true
-
- , baselineskip .tl_set:N = \l__fontscale_Large_baselineskip_tl
- , baselineskip .value_required:n = true
- }
-\keys_define:nn { fontscale / LARGE }
- {
- scale .tl_set:N = \l__fontscale_LARGE_scale_tl
- , scale .value_required:n = true
-
- , size .tl_set:N = \l__fontscale_LARGE_size_tl
- , size .value_required:n = true
-
- , baselineskip .tl_set:N = \l__fontscale_LARGE_baselineskip_tl
- , baselineskip .value_required:n = true
- }
-\keys_define:nn { fontscale / huge }
- {
- scale .tl_set:N = \l__fontscale_huge_scale_tl
- , scale .value_required:n = true
-
- , size .tl_set:N = \l__fontscale_huge_size_tl
- , size .value_required:n = true
-
- , baselineskip .tl_set:N = \l__fontscale_huge_baselineskip_tl
- , baselineskip .value_required:n = true
- }
-\keys_define:nn { fontscale / Huge }
- {
- scale .tl_set:N = \l__fontscale_Huge_scale_tl
- , scale .value_required:n = true
-
- , size .tl_set:N = \l__fontscale_Huge_size_tl
- , size .value_required:n = true
-
- , baselineskip .tl_set:N = \l__fontscale_Huge_baselineskip_tl
- , baselineskip .value_required:n = true
- }
\keys_define:nn { fontscale }
{
- tiny .code:n = \__fontscale_keys_code_name:
+ tiny .tl_set:N = \l__fontscale_tiny_size_tl
, tiny .value_required:n = true
- , scriptsize .code:n = \__fontscale_keys_code_name:
+ , scriptsize .tl_set:N = \l__fontscale_scriptsize_size_tl
, scriptsize .value_required:n = true
- , footnotesize .code:n = \__fontscale_keys_code_name:
+ , footnotesize .tl_set:N = \l__fontscale_footnotesize_size_tl
, footnotesize .value_required:n = true
- , small .code:n = \__fontscale_keys_code_name:
+ , small .tl_set:N = \l__fontscale_small_size_tl
, small .value_required:n = true
- , normalsize .code:n = \__fontscale_keys_code_name:
+ , normalsize .tl_set:N = \l__fontscale_normalsize_size_tl
, normalsize .value_required:n = true
- , large .code:n = \__fontscale_keys_code_name:
+ , large .tl_set:N = \l__fontscale_large_size_tl
, large .value_required:n = true
- , Large .code:n = \__fontscale_keys_code_name:
+ , Large .tl_set:N = \l__fontscale_Large_size_tl
, Large .value_required:n = true
- , LARGE .code:n = \__fontscale_keys_code_name:
+ , LARGE .tl_set:N = \l__fontscale_LARGE_size_tl
, LARGE .value_required:n = true
- , huge .code:n = \__fontscale_keys_code_name:
+ , huge .tl_set:N = \l__fontscale_huge_size_tl
, huge .value_required:n = true
- , Huge .code:n = \__fontscale_keys_code_name:
+ , Huge .tl_set:N = \l__fontscale_Huge_size_tl
, Huge .value_required:n = true
}
@@ -661,19 +534,19 @@
{
\dim_compare:nNnF \l__fontscale_musical_base_dim > \c_zero_dim
{
- \msg_error:nnV { fontscale } { key-musical-base-out-of-bounds }
+ \msg_error:nnV { fontscale } { key-musical-base-invalid }
\l__fontscale_musical_base_dim
\prg_break:
}
\fp_compare:nNnF \l__fontscale_musical_ratio_fp > \c_one_fp
{
- \msg_error:nne { fontscale } { key-musical-ratio-out-of-bounds }
+ \msg_error:nne { fontscale } { key-musical-ratio-invalid }
{ \fp_use:N \l__fontscale_musical_ratio_fp }
\prg_break:
}
\int_compare:nNnF \l__fontscale_musical_notes_int > 0
{
- \msg_error:nnV { fontscale } { key-musical-notes-out-of-bounds }
+ \msg_error:nnV { fontscale } { key-musical-notes-invalid }
\l__fontscale_musical_notes_int
\prg_break:
}
@@ -696,11 +569,11 @@
}
}
{
- \__fontscale_dim_set_default_pt:Nn \l_fontscale_normalsize_size_dim
+ \dim_set:Nn \l_fontscale_normalsize_size_dim
{ \l__fontscale_normalsize_size_tl }
\dim_compare:nNnF \l_fontscale_normalsize_size_dim > \c_zero_dim
{
- \msg_error:nnnV { fontscale } { key-font-size-out-of-bounds }
+ \msg_error:nnnV { fontscale } { key-font-size-invalid }
{ normalsize } \l_fontscale_normalsize_size_dim
\prg_break:
}
@@ -707,9 +580,9 @@
}
\fp_set:Nn \l__fontscale_normalsize_size_fp
{ \dim_to_fp:n { \l_fontscale_normalsize_size_dim } }
- \quark_if_no_value:NTF \l__fontscale_normalsize_baselineskip_tl
+ \skip_set:Nn \l_fontscale_normalsize_baselineskip_skip
{
- \skip_set:Nn \l_fontscale_normalsize_baselineskip_skip
+ \quark_if_no_value:NTF \l__fontscale_normalsize_baselineskip_tl
{
\fp_to_dim:n
{
@@ -717,10 +590,6 @@
\l__fontscale_baselineskip_size_ratio_fp
}
}
- }
- {
- \__fontscale_skip_set_default_pt:Nn
- \l_fontscale_normalsize_baselineskip_skip
{ \l__fontscale_normalsize_baselineskip_tl }
}
}
@@ -787,22 +656,22 @@
{
{ classic-10pt }
{
- \cs_set_eq:NN \__fontscale_keys_process_other_fn_aux:n
+ \cs_set_eq:NN \__fontscale_keys_process_other_aux:n
\__fontscale_keys_process_other_classic_xpt:n
}
{ classic-11pt }
{
- \cs_set_eq:NN \__fontscale_keys_process_other_fn_aux:n
+ \cs_set_eq:NN \__fontscale_keys_process_other_aux:n
\__fontscale_keys_process_other_classic_xipt:n
}
{ classic-12pt }
{
- \cs_set_eq:NN \__fontscale_keys_process_other_fn_aux:n
+ \cs_set_eq:NN \__fontscale_keys_process_other_aux:n
\__fontscale_keys_process_other_classic_xiipt:n
}
{ musical }
{
- \cs_set_eq:NN \__fontscale_keys_process_other_fn_aux:n
+ \cs_set_eq:NN \__fontscale_keys_process_other_aux:n
\__fontscale_keys_process_other_musical:n
\fp_set:Nn \l__fontscale_musical_base_fp
{ \dim_to_fp:n { \l__fontscale_musical_base_dim } }
@@ -820,9 +689,9 @@
{tiny} {scriptsize} {footnotesize} {small}
{large} {Large} {LARGE} {huge} {Huge}
}
- \__fontscale_keys_process_other_fn:n
+ \__fontscale_keys_process_other:n
}
-\cs_new_protected:Npn \__fontscale_keys_process_other_fn:n #1
+\cs_new_protected:Npn \__fontscale_keys_process_other:n #1
{
\quark_if_no_value:cF { l__fontscale_#1_scale_tl }
{
@@ -838,8 +707,8 @@
{
\tl_map_break:n
{
- \msg_error:nnne { fontscale } { key-font-scale-out-of-bounds }
- {#1} { \fp_eval:n { \use:c { l__fontscale_#1_scale_tl } } }
+ \msg_error:nnne { fontscale } { key-font-scale-invalid } {#1}
+ { \fp_eval:n { \use:c { l__fontscale_#1_scale_tl } } }
\prg_break:
}
}
@@ -847,14 +716,14 @@
}
\quark_if_no_value:cF { l__fontscale_#1_size_tl }
{
- \__fontscale_dim_set_default_pt:cn { l_fontscale_#1_size_dim }
+ \dim_set:cn { l_fontscale_#1_size_dim }
{ \use:c { l__fontscale_#1_size_tl } }
\dim_compare:nNnF { \use:c { l_fontscale_#1_size_dim } } > \c_zero_dim
{
\tl_map_break:n
{
- \msg_error:nnnv { fontscale } { key-font-size-out-of-bounds }
- {#1} { l_fontscale_#1_size_dim }
+ \msg_error:nnnv { fontscale } { key-font-size-invalid } {#1}
+ { l_fontscale_#1_size_dim }
\prg_break:
}
}
@@ -865,7 +734,7 @@
\prg_break:
}
\dim_set:cn { l_fontscale_#1_size_dim }
- { \__fontscale_keys_process_other_fn_aux:n {#1} }
+ { \__fontscale_keys_process_other_aux:n {#1} }
\prg_break:
\prg_break_point:
\fp_set:cn { l_fontscale_#1_scale_fp }
@@ -873,9 +742,9 @@
\dim_to_fp:n { \use:c { l_fontscale_#1_size_dim } } /
\l__fontscale_normalsize_size_fp
}
- \quark_if_no_value:cTF { l__fontscale_#1_baselineskip_tl }
+ \skip_set:cn { l_fontscale_#1_baselineskip_skip }
{
- \skip_set:cn { l_fontscale_#1_baselineskip_skip }
+ \quark_if_no_value:cTF { l__fontscale_#1_baselineskip_tl }
{
\fp_to_dim:n
{
@@ -883,10 +752,6 @@
\l__fontscale_baselineskip_size_ratio_fp
}
}
- }
- {
- \__fontscale_skip_set_default_pt:cn
- { l_fontscale_#1_baselineskip_skip }
{ \use:c { l__fontscale_#1_baselineskip_tl } }
}
}
@@ -906,178 +771,67 @@
< \l_fontscale_huge_size_dim
< \l_fontscale_Huge_size_dim
}
- { \msg_warning:nn { fontscale } { font-sizes-out-of-order } }
+ { \msg_warning:nn { fontscale } { font-sizes-wrong-order } }
}
%%> \section{Document commands}
% Defines the standard LaTeX font size commands from \tiny to \Huge and
-% initializes to \normalsize. Their internal functions are not used elsewhere
-% in the code for compatibility with hooks such as
+% initializes to \normalsize. Sets \@currsize only for compatibility. Need
+% \dim_use:N only for compatibility with versions of the microtype package
+% older than v3.2 2024-12-12. The internal functions are not used elsewhere for
+% compatibility with hooks such as
% \AddToHook{cmd/<font size command>/after}{<code>}.
-\DeclareDocumentCommand \tiny { }
+\tl_map_inline:nn
{
- \mode_if_math:TF
- {
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \tiny }
- }
- { \__fontscale_tiny: }
+ {tiny} {scriptsize} {footnotesize} {small} {normalsize}
+ {large} {Large} {LARGE} {huge} {Huge}
}
-\cs_new_protected:Npn \__fontscale_tiny:
{
- \__fontscale_name:NNN \tiny \l_fontscale_tiny_size_dim
- \l_fontscale_tiny_baselineskip_skip
- }
-\DeclareDocumentCommand \scriptsize { }
- {
- \mode_if_math:TF
+ \use:e
{
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \scriptsize }
+ \DeclareDocumentCommand \exp_not:c {#1} { }
+ {
+ \exp_not:N \mode_if_math:TF
+ {
+ \msg_warning:nnn { fontscale } { math-mode-warning }
+ { \token_to_str:c {#1} }
+ }
+ { \exp_not:c { __fontscale_#1: } }
+ }
}
- { \__fontscale_scriptsize: }
- }
-\cs_new_protected:Npn \__fontscale_scriptsize:
- {
- \__fontscale_name:NNN \scriptsize \l_fontscale_scriptsize_size_dim
- \l_fontscale_scriptsize_baselineskip_skip
- }
-\DeclareDocumentCommand \footnotesize { }
- {
- \mode_if_math:TF
+ \cs_new_protected:cpe { __fontscale_#1: }
{
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \footnotesize }
+ \cs_set_eq:NN \exp_not:N \@currsize \exp_not:c {#1}
+ \exp_not:N \fontsize
+ { \exp_not:N \dim_use:N \exp_not:c { l_fontscale_#1_size_dim } }
+ \exp_not:c { l_fontscale_#1_baselineskip_skip }
+ \exp_not:N \selectfont
}
- { \__fontscale_footnotesize: }
}
-\cs_new_protected:Npn \__fontscale_footnotesize:
- {
- \__fontscale_name:NNN \footnotesize \l_fontscale_footnotesize_size_dim
- \l_fontscale_footnotesize_baselineskip_skip
- }
-\DeclareDocumentCommand \small { }
- {
- \mode_if_math:TF
- {
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \small }
- }
- { \__fontscale_small: }
- }
-\cs_new_protected:Npn \__fontscale_small:
- {
- \__fontscale_name:NNN \small \l_fontscale_small_size_dim
- \l_fontscale_small_baselineskip_skip
- }
-\DeclareDocumentCommand \normalsize { }
- {
- \mode_if_math:TF
- {
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \normalsize }
- }
- { \__fontscale_normalsize: }
- }
-\cs_new_protected:Npn \__fontscale_normalsize:
- {
- \__fontscale_name:NNN \normalsize \l_fontscale_normalsize_size_dim
- \l_fontscale_normalsize_baselineskip_skip
- }
-\DeclareDocumentCommand \large { }
- {
- \mode_if_math:TF
- {
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \large }
- }
- { \__fontscale_large: }
- }
-\cs_new_protected:Npn \__fontscale_large:
- {
- \__fontscale_name:NNN \large \l_fontscale_large_size_dim
- \l_fontscale_large_baselineskip_skip
- }
-\DeclareDocumentCommand \Large { }
- {
- \mode_if_math:TF
- {
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \Large }
- }
- { \__fontscale_Large: }
- }
-\cs_new_protected:Npn \__fontscale_Large:
- {
- \__fontscale_name:NNN \Large \l_fontscale_Large_size_dim
- \l_fontscale_Large_baselineskip_skip
- }
-\DeclareDocumentCommand \LARGE { }
- {
- \mode_if_math:TF
- {
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \LARGE }
- }
- { \__fontscale_LARGE: }
- }
-\cs_new_protected:Npn \__fontscale_LARGE:
- {
- \__fontscale_name:NNN \LARGE \l_fontscale_LARGE_size_dim
- \l_fontscale_LARGE_baselineskip_skip
- }
-\DeclareDocumentCommand \huge { }
- {
- \mode_if_math:TF
- {
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \huge }
- }
- { \__fontscale_huge: }
- }
-\cs_new_protected:Npn \__fontscale_huge:
- {
- \__fontscale_name:NNN \huge \l_fontscale_huge_size_dim
- \l_fontscale_huge_baselineskip_skip
- }
-\DeclareDocumentCommand \Huge { }
- {
- \mode_if_math:TF
- {
- \msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \Huge }
- }
- { \__fontscale_Huge: }
- }
-\cs_new_protected:Npn \__fontscale_Huge:
- {
- \__fontscale_name:NNN \Huge \l_fontscale_Huge_size_dim
- \l_fontscale_Huge_baselineskip_skip
- }
\normalsize
-\NewExpandableDocumentCommand \CurrentFontStep { } { \__fontscale_step: }
+\NewExpandableDocumentCommand \currentfontstep { } { \__fontscale_step: }
\cs_new:Npn \__fontscale_step:
{ \fp_if_nan:nF { \l_fontscale_step_fp } { \fp_use:N \l_fontscale_step_fp } }
-\NewExpandableDocumentCommand \CurrentFontScale { } { \__fontscale_scale: }
+\NewExpandableDocumentCommand \currentfontscale { } { \__fontscale_scale: }
\cs_new:Npn \__fontscale_scale: { \fp_use:N \l_fontscale_scale_fp }
-\NewExpandableDocumentCommand \CurrentFontSize { } { \__fontscale_size: }
+\NewExpandableDocumentCommand \currentfontsize { } { \__fontscale_size: }
\cs_new:Npn \__fontscale_size: { \dim_use:N \l_fontscale_size_dim }
-\NewExpandableDocumentCommand \CurrentFontBaselineskip { }
+\NewExpandableDocumentCommand \currentfontbaselineskip { }
{ \__fontscale_baselineskip: }
\cs_new:Npn \__fontscale_baselineskip:
{ \skip_use:N \l_fontscale_baselineskip_skip }
-\NewDocumentCommand \SetFontStep { s m }
+\NewDocumentCommand \setfontstep { s m }
{
\mode_if_math:TF
{
\msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \SetFontStep }
+ { \token_to_str:N \setfontstep }
}
{
\IfBooleanTF #1
@@ -1088,7 +842,7 @@
\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 } }
+ { \msg_error:nn { fontscale } { current-font-step-invalid } }
{ \__fontscale_set_font_step:n { (#1) + \l_fontscale_step_fp } }
}
\cs_new_protected:Npn \__fontscale_set_font_step:n #1
@@ -1121,18 +875,18 @@
}
}
{
- \msg_error:nne { fontscale } { font-step-out-of-bounds }
+ \msg_error:nne { fontscale } { font-step-invalid }
{ \fp_use:N \l__fontscale_tmp_fp }
}
}
}
-\NewDocumentCommand \SetFontScale { s m }
+\NewDocumentCommand \setfontscale { s m }
{
\mode_if_math:TF
{
\msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \SetFontScale }
+ { \token_to_str:N \setfontscale }
}
{
\IfBooleanTF #1
@@ -1148,12 +902,12 @@
{ \fp_to_dim:n { (#1) * \l__fontscale_normalsize_size_fp } }
}
-\NewDocumentCommand \SetFontSize { s >{ \__fontscale_arg_process_dim:n } m }
+\NewDocumentCommand \setfontsize { s m }
{
\mode_if_math:TF
{
\msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \SetFontSize }
+ { \token_to_str:N \setfontsize }
}
{
\IfBooleanTF #1
@@ -1164,12 +918,12 @@
\cs_new_protected:Npn \__fontscale_add_font_size:n #1
{ \__fontscale_set_font_size:n { (#1) + \l_fontscale_size_dim } }
-\NewDocumentCommand \ScaleFont { m }
+\NewDocumentCommand \scalefont { m }
{
\mode_if_math:TF
{
\msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \ScaleFont }
+ { \token_to_str:N \scalefont }
}
{ \__fontscale_scale_font:n {#1} }
}
@@ -1190,27 +944,22 @@
}
}
-\NewDocumentCommand \SetFontSizeBaselineskip
+\NewDocumentCommand \setfontsizebaselineskip { m m }
{
- >{ \__fontscale_arg_process_dim:n } m
- >{ \__fontscale_arg_process_skip:n } m
- }
- {
\mode_if_math:TF
{
\msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \SetFontSizeBaselineskip }
+ { \token_to_str:N \setfontsizebaselineskip }
}
{ \__fontscale_set_font_size:nn {#1} {#2} }
}
-\NewDocumentCommand \SetFontBaselineskip
- { s >{ \__fontscale_arg_process_skip:n } m }
+\NewDocumentCommand \setfontbaselineskip { s m }
{
\mode_if_math:TF
{
\msg_warning:nne { fontscale } { math-mode-warning }
- { \token_to_str:N \SetFontBaselineskip }
+ { \token_to_str:N \setfontbaselineskip }
}
{
\IfBooleanTF #1
@@ -1226,7 +975,7 @@
\cs_new_protected:Npn \__fontscale_set_font_baselineskip:n
{ \__fontscale_set_font_size:nn { \l_fontscale_size_dim } }
-\NewDocumentCommand \PrintFontSizeParameters { }
+\NewDocumentCommand \printfontsizeparameters { }
{ \__fontscale_print_font_size_parameters: }
\cs_new_protected:Npn \__fontscale_print_font_size_parameters:
{
@@ -1239,12 +988,12 @@
baselineskip~ =~ \skip_use:N \l_fontscale_baselineskip_skip
}
-\NewDocumentCommand \PrintAllFontSizeParameters { }
+\NewDocumentCommand \printallfontsizeparameters { }
{
\mode_if_math:TF
{
\msg_error:nne { fontscale } { math-mode-error }
- { \token_to_str:N \PrintAllFontSizeParameters }
+ { \token_to_str:N \printallfontsizeparameters }
}
{ \__fontscale_print_all_font_size_parameters: }
}
@@ -1272,12 +1021,12 @@
}
}
-\NewDocumentCommand \PrintSampleText { >{ \ReverseBoolean } s +m }
+\NewDocumentCommand \printsampletext { >{ \ReverseBoolean } s +m }
{
\mode_if_math:TF
{
\msg_error:nne { fontscale } { math-mode-error }
- { \token_to_str:N \PrintSampleText }
+ { \token_to_str:N \printsampletext }
}
{
\IfBooleanTF #1
@@ -1308,12 +1057,12 @@
\group_end:
}
-\NewDocumentCommand \PrintFontSizeCommand { }
+\NewDocumentCommand \printfontsizecommand { }
{
\mode_if_math:TF
{
\msg_error:nne { fontscale } { math-mode-error }
- { \token_to_str:N \PrintFontSizeCommand }
+ { \token_to_str:N \printfontsizecommand }
}
{ \__fontscale_print_name: }
}
@@ -1345,11 +1094,11 @@
\tl_map_inline:nn
{
\fontscalesetup
- \SetFontStep
- \SetFontScale
- \SetFontSize
- \SetFontBaselineskip
+ \setfontstep
+ \setfontscale
+ \setfontsize
+ \setfontbaselineskip
}
{ \text_declare_purify_equivalent:Nn #1 { \__fontscale_use_none_sm:w } }
-\text_declare_purify_equivalent:Nn \ScaleFont { \use_none:n }
-\text_declare_purify_equivalent:Nn \SetFontSizeBaselineskip { \use_none:nn }
\ No newline at end of file
+\text_declare_purify_equivalent:Nn \scalefont { \use_none:n }
+\text_declare_purify_equivalent:Nn \setfontsizebaselineskip { \use_none:nn }
\ No newline at end of file
More information about the tex-live-commits
mailing list.