From 79e9e48f9496fe82b7e76b2b318d24e9aab1ca8a Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Thu, 28 Mar 2024 03:01:34 +0000
Subject: CTAN sync 202403280301

---
 macros/latex/contrib/fontscale/fontscale.sty | 248 +++++++++++++++++++--------
 1 file changed, 173 insertions(+), 75 deletions(-)

(limited to 'macros/latex/contrib/fontscale/fontscale.sty')

diff --git a/macros/latex/contrib/fontscale/fontscale.sty b/macros/latex/contrib/fontscale/fontscale.sty
index ba1ba40b87..3a6d63676a 100644
--- a/macros/latex/contrib/fontscale/fontscale.sty
+++ b/macros/latex/contrib/fontscale/fontscale.sty
@@ -8,8 +8,8 @@
 \NeedsTeXFormat{LaTeX2e}[2022-06-01]
 \ProvidesExplPackage
   {fontscale}
-  {2024-03-22}
-  {1.0.2}
+  {2024-03-26}
+  {1.0.3}
   {A user interface for setting document font sizes}
 
 % The 2023-10-10 l3kernel update added many 'e'-variants.
@@ -127,12 +127,11 @@
 \tl_new:N  \l__fontscale_keys_precompile_preamble_tl
 
 % Temporary variables
-\seq_new:N \l__fontscale_tmp_seq
-
-\tl_new:N  \l__fontscale_step_tl
-\fp_new:N  \l__fontscale_step_fp
-\tl_new:N  \l__fontscale_scale_tl
-\dim_new:N \l__fontscale_size_dim
+\fp_new:N   \l__fontscale_step_fp
+\tl_new:N   \l__fontscale_step_tl
+\tl_new:N   \l__fontscale_scale_tl
+\dim_new:N  \l__fontscale_size_dim
+\skip_new:N \l__fontscale_baselineskip_skip
 
 % INITIAL FONT PARAMETERS
 
@@ -415,43 +414,43 @@
   }
 \keys_define:nn { fontscale }
   {
-      tiny .code:n = \__fontscale_keys_name_fn:n {#1}
+      tiny .code:n = \__fontscale_keys_name_code:n {#1}
     , tiny .value_required:n = true
 
-    , scriptsize .code:n = \__fontscale_keys_name_fn:n {#1}
+    , scriptsize .code:n = \__fontscale_keys_name_code:n {#1}
     , scriptsize .value_required:n = true
 
-    , footnotesize .code:n = \__fontscale_keys_name_fn:n {#1}
+    , footnotesize .code:n = \__fontscale_keys_name_code:n {#1}
     , footnotesize .value_required:n = true
 
-    , small .code:n = \__fontscale_keys_name_fn:n {#1}
+    , small .code:n = \__fontscale_keys_name_code:n {#1}
     , small .value_required:n = true
 
-    , normalsize .code:n = \__fontscale_keys_name_fn:n {#1}
+    , normalsize .code:n = \__fontscale_keys_name_code:n {#1}
     , normalsize .value_required:n = true
 
-    , large .code:n = \__fontscale_keys_name_fn:n {#1}
+    , large .code:n = \__fontscale_keys_name_code:n {#1}
     , large .value_required:n = true
 
-    , Large .code:n = \__fontscale_keys_name_fn:n {#1}
+    , Large .code:n = \__fontscale_keys_name_code:n {#1}
     , Large .value_required:n = true
 
-    , LARGE .code:n = \__fontscale_keys_name_fn:n {#1}
+    , LARGE .code:n = \__fontscale_keys_name_code:n {#1}
     , LARGE .value_required:n = true
 
-    , huge .code:n = \__fontscale_keys_name_fn:n {#1}
+    , huge .code:n = \__fontscale_keys_name_code:n {#1}
     , huge .value_required:n = true
 
-    , Huge .code:n = \__fontscale_keys_name_fn:n {#1}
+    , Huge .code:n = \__fontscale_keys_name_code:n {#1}
     , Huge .value_required:n = true
   }
-\cs_new_protected:Npn \__fontscale_keys_name_fn:n #1
+\cs_new_protected:Npn \__fontscale_keys_name_code:n #1
   {
     \str_if_in:nnTF {#1} { / }
-      { \__fontscale_keys_name_fn_split:ww #1 \q_stop }
+      { \__fontscale_keys_name_code_split:ww #1 \q_stop }
       { \tl_set:cn { l__fontscale_ \l_keys_key_str _size_tl } {#1} }
   }
-\cs_new_protected:Npn \__fontscale_keys_name_fn_split:ww #1 / #2 \q_stop
+\cs_new_protected:Npn \__fontscale_keys_name_code_split: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}
@@ -601,6 +600,7 @@
   {
     \__fontscale_keys_process_normalsize:
     \__fontscale_keys_process_other:
+    \__fontscale_keys_process_other_props:
     \__fontscale_keys_process_check_order:
   }
 % Sets the size and baselineskip of \normalsize, stores them in a property
@@ -791,14 +791,67 @@
               { l_fontscale_##1_baselineskip_skip }
               { \use:c { l__fontscale_##1_baselineskip_tl } }
           }
-        \prop_put:cne { l_fontscale_##1_prop } { scale }
-          { \fp_use:c { l_fontscale_##1_scale_fp } }
-        \prop_put:cne { l_fontscale_##1_prop } { size }
-          { \dim_use:c { l_fontscale_##1_size_dim } }
-        \prop_put:cne { l_fontscale_##1_prop } { baselineskip }
-          { \skip_use:c { l_fontscale_##1_baselineskip_skip } }
       }
   }
+\cs_new_protected:Npn \__fontscale_keys_process_other_props:
+  {
+    \prop_put:Nne \l_fontscale_tiny_prop { scale }
+      { \fp_use:N \l_fontscale_tiny_scale_fp }
+    \prop_put:Nne \l_fontscale_scriptsize_prop { scale }
+      { \fp_use:N \l_fontscale_scriptsize_scale_fp }
+    \prop_put:Nne \l_fontscale_footnotesize_prop { scale }
+      { \fp_use:N \l_fontscale_footnotesize_scale_fp }
+    \prop_put:Nne \l_fontscale_small_prop { scale }
+      { \fp_use:N \l_fontscale_small_scale_fp }
+    \prop_put:Nne \l_fontscale_large_prop { scale }
+      { \fp_use:N \l_fontscale_large_scale_fp }
+    \prop_put:Nne \l_fontscale_Large_prop { scale }
+      { \fp_use:N \l_fontscale_Large_scale_fp }
+    \prop_put:Nne \l_fontscale_LARGE_prop { scale }
+      { \fp_use:N \l_fontscale_LARGE_scale_fp }
+    \prop_put:Nne \l_fontscale_huge_prop { scale }
+      { \fp_use:N \l_fontscale_huge_scale_fp }
+    \prop_put:Nne \l_fontscale_Huge_prop { scale }
+      { \fp_use:N \l_fontscale_Huge_scale_fp }
+
+    \prop_put:Nno \l_fontscale_tiny_prop { size }
+      { \dim_use:N \l_fontscale_tiny_size_dim }
+    \prop_put:Nno \l_fontscale_scriptsize_prop { size }
+      { \dim_use:N \l_fontscale_scriptsize_size_dim }
+    \prop_put:Nno \l_fontscale_footnotesize_prop { size }
+      { \dim_use:N \l_fontscale_footnotesize_size_dim }
+    \prop_put:Nno \l_fontscale_small_prop { size }
+      { \dim_use:N \l_fontscale_small_size_dim }
+    \prop_put:Nno \l_fontscale_large_prop { size }
+      { \dim_use:N \l_fontscale_large_size_dim }
+    \prop_put:Nno \l_fontscale_Large_prop { size }
+      { \dim_use:N \l_fontscale_Large_size_dim }
+    \prop_put:Nno \l_fontscale_LARGE_prop { size }
+      { \dim_use:N \l_fontscale_LARGE_size_dim }
+    \prop_put:Nno \l_fontscale_huge_prop { size }
+      { \dim_use:N \l_fontscale_huge_size_dim }
+    \prop_put:Nno \l_fontscale_Huge_prop { size }
+      { \dim_use:N \l_fontscale_Huge_size_dim }
+
+    \prop_put:Nno \l_fontscale_tiny_prop { baselineskip }
+      { \skip_use:N \l_fontscale_tiny_baselineskip_skip }
+    \prop_put:Nno \l_fontscale_scriptsize_prop { baselineskip }
+      { \skip_use:N \l_fontscale_scriptsize_baselineskip_skip }
+    \prop_put:Nno \l_fontscale_footnotesize_prop { baselineskip }
+      { \skip_use:N \l_fontscale_footnotesize_baselineskip_skip }
+    \prop_put:Nno \l_fontscale_small_prop { baselineskip }
+      { \skip_use:N \l_fontscale_small_baselineskip_skip }
+    \prop_put:Nno \l_fontscale_large_prop { baselineskip }
+      { \skip_use:N \l_fontscale_large_baselineskip_skip }
+    \prop_put:Nno \l_fontscale_Large_prop { baselineskip }
+      { \skip_use:N \l_fontscale_Large_baselineskip_skip }
+    \prop_put:Nno \l_fontscale_LARGE_prop { baselineskip }
+      { \skip_use:N \l_fontscale_LARGE_baselineskip_skip }
+    \prop_put:Nno \l_fontscale_huge_prop { baselineskip }
+      { \skip_use:N \l_fontscale_huge_baselineskip_skip }
+    \prop_put:Nno \l_fontscale_Huge_prop { baselineskip }
+      { \skip_use:N \l_fontscale_Huge_baselineskip_skip }
+  }
 % Issues a warning if the font sizes or font baselineskips are not in the
 % correct order.
 \cs_new_protected:Npn \__fontscale_keys_process_check_order:
@@ -961,23 +1014,15 @@
 \cs_new:Npn \__fontscale_current_font_baselineskip: { \f@baselineskip }
 
 \NewDocumentCommand \SetFontStep { s m }
-  { \__fontscale_set_font_step:Nn #1 {#2} }
-\cs_new_protected:Npn \__fontscale_set_font_step:Nn #1#2
   {
-    \bool_if:NTF #1
-      {
-        \tl_set:Ne \l__fontscale_step_tl { \__fontscale_current_font_step: }
-        \tl_if_empty:NTF \l__fontscale_step_tl
-          { \msg_error:nn { fontscale } { font-step-out-of-bounds } }
-          {
-            \fp_set:Nn \l__fontscale_step_fp { (#2) + \l__fontscale_step_tl }
-            \__fontscale_set_font_step_aux:N \l__fontscale_step_fp
-          }
-      }
-      {
-        \fp_set:Nn \l__fontscale_step_fp {#2}
-        \__fontscale_set_font_step_aux:N \l__fontscale_step_fp
-      }
+    \IfBooleanTF #1
+      { \__fontscale_add_font_step:n {#2} }
+      { \__fontscale_set_font_step:n {#2} }
+  }
+\cs_new_protected:Npn \__fontscale_set_font_step:n #1
+  {
+    \fp_set:Nn \l__fontscale_step_fp {#1}
+    \__fontscale_set_font_step_aux:N \l__fontscale_step_fp
   }
 \cs_new_protected:Npn \__fontscale_set_font_step_aux:N #1
   {
@@ -1001,7 +1046,7 @@
             {
               \fontsize
                 {
-                  \fp_eval:n
+                  \fp_to_dim:n
                     {
                       \l__fontscale_normalsize_size_fp
                       * \l__fontscale_modular_ratio_fp ^ #1
@@ -1012,7 +1057,7 @@
             {
               \fontsize
                 {
-                  \fp_eval:n
+                  \fp_to_dim:n
                     {
                       \l__fontscale_normalsize_size_fp
                       * \l__fontscale_musical_ratio_fp
@@ -1023,36 +1068,66 @@
           }
           {
             {
-              \fp_eval:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp }
+              \fp_to_dim:n
+                { \f@size * \l__fontscale_baselineskip_size_ratio_fp }
             }
             \selectfont
           }
           { \msg_error:nn { fontscale } { font-step-out-of-bounds } }
       }
   }
+\cs_new_protected:Npn \__fontscale_add_font_step:n #1
+  {
+    \tl_set:Ne \l__fontscale_step_tl { \__fontscale_current_font_step: }
+    \tl_if_empty:NTF \l__fontscale_step_tl
+      { \msg_error:nn { fontscale } { font-step-out-of-bounds } }
+      {
+        \fp_set:Nn \l__fontscale_step_fp { (#1) + \l__fontscale_step_tl }
+        \__fontscale_add_font_step_aux:N \l__fontscale_step_fp
+      }
+  }
+\cs_new_eq:NN \__fontscale_add_font_step_aux:N \__fontscale_set_font_step_aux:N
 
 \NewDocumentCommand \SetFontScale { s m }
-  { \__fontscale_set_font_scale:Nn #1 {#2} }
-\cs_new_protected:Npn \__fontscale_set_font_scale:Nn #1#2
   {
-    \dim_set:Nn \l__fontscale_size_dim
-      { \fp_to_dim:n { \l__fontscale_normalsize_size_fp * (#2) } }
-    \bool_if:NT #1
-      { \dim_add:Nn \l__fontscale_size_dim { \f@size pt } }
-    \fontsize \l__fontscale_size_dim
-      { \fp_eval:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } }
+    \IfBooleanTF #1
+      { \__fontscale_add_font_scale:n {#2} }
+      { \__fontscale_set_font_scale:n {#2} }
+  }
+\cs_new_protected:Npn \__fontscale_set_font_scale:n #1
+  {
+    \fontsize
+      { \fp_to_dim:n { \l__fontscale_normalsize_size_fp * (#1) } }
+      { \fp_to_dim:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } }
+    \selectfont
+  }
+\cs_new_protected:Npn \__fontscale_add_font_scale:n #1
+  {
+    \fontsize
+      { \fp_to_dim:n { \l__fontscale_normalsize_size_fp * (#1) + \f@size } }
+      { \fp_to_dim:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } }
     \selectfont
   }
 
 \NewDocumentCommand \SetFontSize { s m }
-  { \__fontscale_set_font_size:Nn #1 {#2} }
-\cs_new_protected:Npn \__fontscale_set_font_size:Nn #1#2
   {
-    \__fontscale_dim_set_with_default_unit:Nn \l__fontscale_size_dim {#2}
-    \bool_if:NT #1
-      { \dim_add:Nn \l__fontscale_size_dim { \f@size pt } }
+    \IfBooleanTF #1
+      { \__fontscale_add_font_size:n {#2} }
+      { \__fontscale_set_font_size:n {#2} }
+  }
+\cs_new_protected:Npn \__fontscale_set_font_size:n #1
+  {
+    \__fontscale_dim_set_with_default_unit:Nn \l__fontscale_size_dim {#1}
+    \fontsize \l__fontscale_size_dim
+      { \fp_to_dim:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } }
+    \selectfont
+  }
+\cs_new_protected:Npn \__fontscale_add_font_size:n #1
+  {
+    \__fontscale_dim_set_with_default_unit:Nn \l__fontscale_size_dim {#1}
+    \dim_add:Nn \l__fontscale_size_dim { \f@size pt }
     \fontsize \l__fontscale_size_dim
-      { \fp_eval:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } }
+      { \fp_to_dim:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } }
     \selectfont
   }
 
@@ -1060,15 +1135,21 @@
 \cs_new_protected:Npn \__fontscale_scalefont:n #1
   {
     \fontsize
-      { \fp_eval:n { \f@size                          * (#1) } }
-      { \fp_eval:n { \dim_to_fp:n { \f@baselineskip } * (#1) } }
+      { \fp_to_dim:n { \f@size                          * (#1) } }
+      { \fp_to_dim:n { \dim_to_fp:n { \f@baselineskip } * (#1) } }
     \selectfont
   }
 
 \NewDocumentCommand \SetFontSizeBaselineskip { m m }
   { \__fontscale_set_font_size_baselineskip:nn {#1} {#2} }
 \cs_new_protected:Npn \__fontscale_set_font_size_baselineskip:nn #1#2
-  { \exp_args:Nee \fontsize {#1} {#2} \selectfont }
+  {
+    \__fontscale_dim_set_with_default_unit:Nn \l__fontscale_size_dim {#1}
+    \__fontscale_skip_set_with_default_unit:Nn \l__fontscale_baselineskip_skip
+      {#2}
+    \fontsize \l__fontscale_size_dim \l__fontscale_baselineskip_skip
+    \selectfont
+  }
 
 \NewDocumentCommand \PrintFontParameters { }
   { \__fontscale_print_font_parameters: }
@@ -1104,19 +1185,36 @@
       A~ user~ interface~ for~ setting~ document~ font~ sizes
     }
   }
-  { \__fontscale_print_sample_text:Nn #1 {#2} }
-\cs_new_protected:Npn \__fontscale_print_sample_text:Nn #1#2
   {
-    \seq_set_eq:NN \l__fontscale_tmp_seq \c__fontscale_names_seq
-    \bool_if:NT #1 { \seq_reverse:N \l__fontscale_tmp_seq }
-    \seq_map_inline:Nn \l__fontscale_tmp_seq
-      {
-        \group_begin:
-          \use:c {##1}
-          #2
-          \par
-        \group_end:
-      }
+    \IfBooleanTF #1
+      { \__fontscale_print_sample_text_descending_order:n {#2} }
+      { \__fontscale_print_sample_text_ascending_order:n  {#2} }
+  }
+\cs_new_protected:Npn \__fontscale_print_sample_text_ascending_order:n #1
+  {
+    { \tiny         #1 \par }
+    { \scriptsize   #1 \par }
+    { \footnotesize #1 \par }
+    { \small        #1 \par }
+    { \normalsize   #1 \par }
+    { \large        #1 \par }
+    { \Large        #1 \par }
+    { \LARGE        #1 \par }
+    { \huge         #1 \par }
+    { \Huge         #1 \par }
+  }
+\cs_new_protected:Npn \__fontscale_print_sample_text_descending_order:n #1
+  {
+    { \Huge         #1 \par }
+    { \huge         #1 \par }
+    { \LARGE        #1 \par }
+    { \Large        #1 \par }
+    { \large        #1 \par }
+    { \normalsize   #1 \par }
+    { \small        #1 \par }
+    { \footnotesize #1 \par }
+    { \scriptsize   #1 \par }
+    { \tiny         #1 \par }
   }
 
 \NewDocumentCommand \PrintFontSizeCommand { } { \__fontscale_print_name: }
-- 
cgit v1.2.3

