[latex3-commits] [latex3/fontspec] use-keyval: move to keyval-options (84d5640)
github at latex-project.org
github at latex-project.org
Mon Dec 18 17:57:12 CET 2023
Repository : https://github.com/latex3/fontspec
On branch : use-keyval
Link : https://github.com/latex3/fontspec/commit/84d56404e30a5ef1c3e7bb80d7bbb32784497c08
>---------------------------------------------------------------
commit 84d56404e30a5ef1c3e7bb80d7bbb32784497c08
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sun Dec 17 17:18:20 2023 +0100
move to keyval-options
>---------------------------------------------------------------
84d56404e30a5ef1c3e7bb80d7bbb32784497c08
CHANGES.md | 6 ++-
fontspec-code-load.dtx | 4 +-
fontspec-code-msg.dtx | 4 ++
fontspec-code-opening.dtx | 95 +++++++++++++++++++++--------------------------
fontspec-code-vars.dtx | 6 ++-
fontspec-doc-intro.tex | 16 ++++----
fontspec.ins | 2 +
7 files changed, 69 insertions(+), 64 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..b2438c4 100644
--- a/fontspec-code-msg.dtx
+++ b/fontspec-code-msg.dtx
@@ -193,6 +193,10 @@
{
The "cm-default" package option is obsolete.
}
+\@@_msg_new:nn {enc-obsolete}
+ {
+ The "#1" package option is obsolete. TU is the default encoding.
+ }
\@@_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..2151252 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 = { \@@_warning:n {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 = { \@@_warning:nx {enc-obsolete}{euenc} }
+ ,tuenc .code:n = { \@@_warning:nx {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..597ef99 100644
--- a/fontspec.ins
+++ b/fontspec.ins
@@ -32,6 +32,8 @@ 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-opening.dtx}{options}
\from{fontspec-code-load.dtx}{fontspec,load\FSDEBUG}
}}
More information about the latex3-commits
mailing list.