[latex3-commits] [latex3/fontspec] develop, l3color, release/v2.9a: Use keyval for package options (#493) (3c11f26)

github at latex-project.org github at latex-project.org
Mon Dec 18 18:01:03 CET 2023


Repository : https://github.com/latex3/fontspec
On branches: develop,l3color,release/v2.9a
Link       : https://github.com/latex3/fontspec/commit/3c11f26f847109f1a03693a6c3a6a0183652b816

>---------------------------------------------------------------

commit 3c11f26f847109f1a03693a6c3a6a0183652b816
Author: Ulrike Fischer <news3 at nililand.de>
Date:   Mon Dec 18 18:01:03 2023 +0100

    Use keyval for package options (#493)
    
    * move to keyval-options
    
    * move missing messages into style
    
    * grumpf
    
    * add testfile
    
    ---------
    
    Co-authored-by: Ulrike Fischer <fischer at troubleshooting-tex.de>


>---------------------------------------------------------------

3c11f26f847109f1a03693a6c3a6a0183652b816
 CHANGES.md                             |  6 ++-
 fontspec-code-load.dtx                 |  4 +-
 fontspec-code-msg.dtx                  | 15 +++++-
 fontspec-code-opening.dtx              | 95 +++++++++++++++-------------------
 fontspec-code-vars.dtx                 |  6 ++-
 fontspec-doc-intro.tex                 | 16 +++---
 fontspec.ins                           |  3 ++
 testfiles/00-pkg-load-twice.luatex.tlg | 16 ++++++
 testfiles/00-pkg-load-twice.lvt        |  6 +++
 testfiles/00-pkg-load-twice.tlg        | 12 +++++
 10 files changed, 113 insertions(+), 66 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 10841c1..8aeb1d3 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,10 @@
 Change history
 ==============
-
+## [Unreleased]
+  * switched options to LaTeX keyval handler
+  * added option verbose to undo silent/quiet
+  * euenc/tuenc options are obsolete
+  * TU is the only encoding 
 ## v2.8a (2022/01/15)
 
   * Add `SwashFont` and `BoldSwashFont` features to support LaTeX's now-builtin `\textsw`
diff --git a/fontspec-code-load.dtx b/fontspec-code-load.dtx
index 4f7ec3b..a61c5af 100644
--- a/fontspec-code-load.dtx
+++ b/fontspec-code-load.dtx
@@ -21,7 +21,7 @@
   {
     \RequirePackage{luaotfload}
     \lua_now:e{require("fontspec")}
-    \RequirePackageWithOptions{fontspec-luatex}
+    \RequirePackage{fontspec-luatex}
     \endinput
   }
 %    \end{macrocode}
@@ -30,7 +30,7 @@
 %    \begin{macrocode}
 \sys_if_engine_xetex:T
   {
-    \RequirePackageWithOptions{fontspec-xetex}
+    \RequirePackage{fontspec-xetex}
     \endinput
   }
 %    \end{macrocode}
diff --git a/fontspec-code-msg.dtx b/fontspec-code-msg.dtx
index 4d80194..034ed6c 100644
--- a/fontspec-code-msg.dtx
+++ b/fontspec-code-msg.dtx
@@ -189,10 +189,21 @@
   Input mapping not supported in LuaTeX.\\
   Use "Ligatures=TeX" instead of "Mapping=tex-text".
  }
-\@@_msg_new:nn {cm-default-obsolete}
+%    \end{macrocode}
+% message for package options must be loaded earlier
+%    \begin{macrocode}
+%</fontspec>
+%<*options>
+\msg_new:nnn {fontspec} {cm-default-obsolete}
  {
-  The "cm-default" package option is obsolete.
+  The~"cm-default"~package~option~is~obsolete.
  }
+\msg_new:nnn {fontspec} {enc-obsolete}
+ {
+  The~"#1"~package~option~is~obsolete.~TU~is~the~default~encoding.
+ }
+%</options>
+%<*fontspec> 
 \@@_msg_new:nn {font-index-needs-ttc}
  {
   The "FontIndex" feature is only supported by TTC (TrueType Collection) fonts.\\
diff --git a/fontspec-code-opening.dtx b/fontspec-code-opening.dtx
index 60253a1..e19c261 100644
--- a/fontspec-code-opening.dtx
+++ b/fontspec-code-opening.dtx
@@ -4,75 +4,74 @@
 %
 % \iffalse
 %    \begin{macrocode}
-%<*fontspec>
+%<*options>
 %    \end{macrocode}
 % \fi
 %
 % \subsection{Package options}
 %
 %    \begin{macrocode}
-\DeclareOption{cm-default}
+\DeclareKeys 
   {
-    \@@_warning:n {cm-default-obsolete}
-  }
+    cm-default  .code:n = { \msg_warning:nn   {fontspec} {cm-default-obsolete} }    
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\DeclareOption {math}     { \bool_gset_true:N  \g_@@_math_bool  }
-\DeclareOption {no-math}  { \bool_gset_false:N \g_@@_math_bool  }
-\DeclareOption {config}   { \bool_gset_true:N  \g_@@_cfg_bool   }
-\DeclareOption {no-config}{ \bool_gset_false:N \g_@@_cfg_bool   }
-\DeclareOption {euenc}    { \bool_gset_true:N  \g_@@_euenc_bool }
-\DeclareOption {tuenc}    { \bool_gset_false:N \g_@@_euenc_bool }
+    ,math    .bool_gset:N = \g_@@_math_bool
+    ,math    .usage:n     =  preamble
+    ,no-math .bool_gset_inverse:N = \g_@@_math_bool
+    ,no-math .usage:n             =  preamble
+    ,config  .bool_gset:N = \g_@@_cfg_bool
+    ,config  .usage:n     = load
+    ,no-config  .bool_gset_inverse:N = \g_@@_cfg_bool
+    ,no-config  .usage:n             = load
+    ,euenc  .code:n = { \msg_warning:nnn   {fontspec} {enc-obsolete}{euenc} }    
+    ,tuenc  .code:n = { \msg_warning:nnn   {fontspec} {enc-obsolete}{tuenc} }    
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\DeclareOption {quiet}
-  {
-    \msg_redirect_module:nnn { fontspec } { warning } { info }
-    \msg_redirect_module:nnn { fontspec } { info } { none }
-  }
-\DeclareOption{silent}
-  {
-    \msg_redirect_module:nnn { fontspec } { warning } { none }
-    \msg_redirect_module:nnn { fontspec } { info } { none }
+    ,quiet .code:n = 
+      {
+        \msg_redirect_module:nnn { fontspec } { warning } { info }
+        \msg_redirect_module:nnn { fontspec } { info } { none }
+      }
+    ,silent .code:n = 
+      {
+        \msg_redirect_module:nnn { fontspec } { warning } { none }
+        \msg_redirect_module:nnn { fontspec } { info } { none }
+      }
+    ,verbose .code:n = 
+      {
+        \msg_redirect_module:nnn { fontspec } { warning } { warning }
+        \msg_redirect_module:nnn { fontspec } { info } { info }      
+      }  
   }        
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\ExecuteOptions{config,math,tuenc}
-\ProcessOptions*
+\SetKeys{config,math}
+\ProcessKeyOptions
 %    \end{macrocode}
 %
-%
+% \iffalse
+%    \begin{macrocode}
+%</options>
+%<*fontspec>
+%    \end{macrocode}
+% \fi
 %
 %
 % \subsection{Encodings}
 %
-% Soon to be the default, with a just-in-case check:
+% Now the default, with a just-in-case check:
 %    \begin{macrocode}
-\bool_if:NF \g_@@_euenc_bool
-  {
-    \file_if_exist:nTF {tuenc.def}
-      {
-        \cs_if_exist:cF {T at TU}
-          {
-            \@@_warning:n {tu-clash}
-            \DeclareFontEncoding{TU}{}{}
-            \DeclareFontSubstitution{TU}{lmr}{m}{n}
-          }
-      }
-      {
-        \@@_warning:n {tu-missing}
-        \bool_gset_true:N \g_@@_euenc_bool
-      }
-  }
-\bool_if:NTF \g_@@_euenc_bool
+\cs_if_exist:cF {T at TU}
   {
-%<XE>    \tl_gset:Nn \g_fontspec_encoding_tl {EU1}
-%<LU>    \tl_gset:Nn \g_fontspec_encoding_tl {EU2}
+    \@@_warning:n {tu-clash}
+    \DeclareFontEncoding{TU}{}{}
+    \DeclareFontSubstitution{TU}{lmr}{m}{n}
   }
-  { \tl_gset:Nn \g_fontspec_encoding_tl { TU } }
+\tl_gset:Nn \g_fontspec_encoding_tl { TU }  
 %    \end{macrocode}
 %
 %    \begin{macrocode}
@@ -100,16 +99,6 @@
 % Something to do with \cmd\select at language\ ending up in the \texttt{.aux}
 % file which is read at the beginning of the document.
 %
-%    \begin{macrocode}
-\bool_if:NT \g_@@_euenc_bool
-  {
-%<LU>    \cs_set_eq:NN \fontspec_tmp: \XeTeXpicfile
-%<LU>    \cs_set:Npn \XeTeXpicfile {}
-    \RequirePackage{xunicode}
-%<LU>    \cs_set_eq:NN \XeTeXpicfile \fontspec_tmp:
-  }
-%    \end{macrocode}
-%
 %
 % \subsection{Generic functions}
 %
diff --git a/fontspec-code-vars.dtx b/fontspec-code-vars.dtx
index fc1321a..6c8ef4e 100644
--- a/fontspec-code-vars.dtx
+++ b/fontspec-code-vars.dtx
@@ -4,6 +4,7 @@
 %
 % \iffalse
 %    \begin{macrocode}
+%<@@=fontspec>
 %<*fontspec>
 %    \end{macrocode}
 % \fi
@@ -50,9 +51,12 @@
 %    \end{macrocode}
 % For package options:
 %    \begin{macrocode}
+%</fontspec>
+%<*options>
 \bool_new:N \g_@@_cfg_bool
 \bool_new:N \g_@@_math_bool
-\bool_new:N \g_@@_euenc_bool
+%</options>
+%<*fontspec>
 %    \end{macrocode}
 %
 %    \begin{macrocode}
diff --git a/fontspec-doc-intro.tex b/fontspec-doc-intro.tex
index 4e913b6..f062ab4 100644
--- a/fontspec-doc-intro.tex
+++ b/fontspec-doc-intro.tex
@@ -75,17 +75,19 @@ For basic use, no package options are required:
   \usepackage{fontspec}
 \end{Verbatim}
 Package options will be introduced below; some preliminary details are discussed first.
-
+Package options are setup with the in-built \LaTeX{} keyval options handler. This means
+that the package can be loaded more than once with different options without triggering
+an option clash error. The \texttt{config} and \texttt{no-config} option must be used in
+the first loading and are ignored later.
 
 \subsection{Font encodings}
 
-The (default) \texttt{tuenc} package option switches the \textsc{nfss} font encoding to \texttt{TU}.
+The package switches the \textsc{nfss} font encoding to \texttt{TU}.
 \texttt{TU} is a new Unicode font encoding, intended for both \XeTeX\ and \LuaTeX\ engines, and automatically contains support for symbols covered by \LaTeX's traditional \texttt{T1} and \texttt{TS1} font encodings (for example, |\%|, |\textbullet|, |\"u|, and so on).
 Some additional features are provided by \pkg{fontspec} to customise some encoding details; see Part~\vref{part:enc} for further details.
 
-Pre-2017 behaviour can be achieved with the \texttt{euenc} package option.
-This selects the \texttt{EU1} or \texttt{EU2} encoding (\XeTeX/\LuaTeX, resp.) and loads the \pkg{xunicode} package for symbol support.
-Package authors and users who have referred explicitly to the encoding names \texttt{EU1} or \texttt{EU2} should update their code or documents.
+Pre-2017 behaviour is now obsolete. The \texttt{euenc} and \texttt{tuenc} package options are
+ignored. Package authors and users who have referred explicitly to the encoding names \texttt{EU1} or \texttt{EU2} should update their code or documents.
 (See internal variable names described in \vref{sec:api} for how to do this properly.)
 
 
@@ -108,7 +110,7 @@ A |fontspec.cfg| file is distributed with \pkg{fontspec} with a small number of
 To customise \pkg{fontspec} to your liking, use the standard |.cfg| file as a starting point or write your own from scratch, then either place it in the same folder as the main document for isolated cases, or in a location
 that \XeTeX\ or \LuaTeX\ searches by default; \eg\ in Mac\TeX: \path{~/Library/texmf/tex/latex/}.
 
-The package option |no-config| will suppress the loading of the |fontspec.cfg| file under all circumstances.
+The package option |no-config| will suppress the loading of the |fontspec.cfg| file under all circumstances. Both options must be used the first time \pkg{fontspec} is loaded and are ignored in later calls.
 
 
 \subsection{Warnings}
@@ -121,7 +123,7 @@ transcript (\texttt{.log}) file instead.
 Use the |silent| package option to completely suppress these warnings if you
 don't even want the |.log| file cluttered up.
 
-
+Both options can also be used with \cs{Setkeys} in the document. Use the |verbose| option to get activate the warnings again.
 
 \section{Interaction with \LaTeXe\ and other packages}
 
diff --git a/fontspec.ins b/fontspec.ins
index be45e40..8cc3306 100644
--- a/fontspec.ins
+++ b/fontspec.ins
@@ -32,6 +32,9 @@ the conditions of the LaTeX Project Public License, version 1.3c or higher
 
 \generate{\file{fontspec.sty}{
   \from{fontspec.dtx}{fontspec,load\FSDEBUG}
+  \from{fontspec-code-vars.dtx}{options}
+  \from{fontspec-code-msg.dtx}{options}
+  \from{fontspec-code-opening.dtx}{options}
   \from{fontspec-code-load.dtx}{fontspec,load\FSDEBUG}
 }}
 
diff --git a/testfiles/00-pkg-load-twice.luatex.tlg b/testfiles/00-pkg-load-twice.luatex.tlg
new file mode 100644
index 0000000..990db5e
--- /dev/null
+++ b/testfiles/00-pkg-load-twice.luatex.tlg
@@ -0,0 +1,16 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+Completed box being shipped out [1]
+\hbox(0.0+0.0)x0.0, glue set - 1.0, direction TLT
+.\TU/lmr/m/n/10 h
+.\TU/lmr/m/n/10 e
+.\TU/lmr/m/n/10 l
+.\TU/lmr/m/n/10 l
+.\TU/lmr/m/n/10 o
+.\glue(\spaceskip) 3.33 plus 1.665 minus 1.11
+.\mathon
+.\OT1/cmr/m/n/10 a
+.\mathoff
+.\glue(\spaceskip) 3.33 plus 1.665 minus 1.11
+***************
+Compilation 1 of test file completed with exit status 0
diff --git a/testfiles/00-pkg-load-twice.lvt b/testfiles/00-pkg-load-twice.lvt
new file mode 100644
index 0000000..03ee837
--- /dev/null
+++ b/testfiles/00-pkg-load-twice.lvt
@@ -0,0 +1,6 @@
+\input{fontspec-testsetup}
+\usepackage{fontspec}
+\usepackage[no-math]{fontspec}
+\begin{document}
+\SHIPOUT{hello $\mathrm{a}$ } 
+\end{document}
diff --git a/testfiles/00-pkg-load-twice.tlg b/testfiles/00-pkg-load-twice.tlg
new file mode 100644
index 0000000..b7e94f0
--- /dev/null
+++ b/testfiles/00-pkg-load-twice.tlg
@@ -0,0 +1,12 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+Completed box being shipped out [1]
+\hbox(0.0+0.0)x0.0, glue set - 1.0
+.\TU/lmr/m/n/10 hello
+.\glue 3.33 plus 1.665 minus 1.11
+.\mathon
+.\OT1/cmr/m/n/10 a
+.\mathoff
+.\glue 3.33 plus 1.665 minus 1.11
+***************
+Compilation 1 of test file completed with exit status 0





More information about the latex3-commits mailing list.