[latex3-commits] [git/LaTeX3-latex3-latex2e] gh315: Handling \seriesdefault changes in a better way (#315) (ed7291ea)

Frank Mittelbach frank.mittelbach at latex-project.org
Mon Apr 13 11:06:40 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : gh315
Link       : https://github.com/latex3/latex2e/commit/ed7291ea4d8cb7ff73bdda3e7b3a4856df97de3c

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

commit ed7291ea4d8cb7ff73bdda3e7b3a4856df97de3c
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Mon Apr 13 11:06:40 2020 +0200

    Handling \seriesdefault changes in a better way (#315)


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

ed7291ea4d8cb7ff73bdda3e7b3a4856df97de3c
 base/changes.txt                             |  7 ++-
 base/doc/ltnews32.tex                        | 39 +++++++++++++---
 base/ltfssdcl.dtx                            | 12 +++--
 base/ltfssini.dtx                            | 70 +++++++++++++++++++++-------
 base/testfiles/github-0306b.lvt              |  2 +-
 base/testfiles/github-0306b.tlg              | 14 +++---
 base/testfiles/github-0315a.lvt              | 51 ++++++++++++++++++++
 base/testfiles/github-0315a.tlg              | 50 ++++++++++++++++++++
 base/testfiles/github-0315b.lvt              | 57 ++++++++++++++++++++++
 base/testfiles/github-0315b.tlg              | 58 +++++++++++++++++++++++
 base/testfiles/github-robust-0123.luatex.tlg |  4 --
 base/testfiles/github-robust-0123.lvt        |  4 +-
 base/testfiles/github-robust-0123.tlg        |  4 --
 base/testfiles/github-robust-0123.xetex.tlg  |  4 --
 14 files changed, 323 insertions(+), 53 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index 8381bfba..766c69a5 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -1,3 +1,8 @@
+2020-04-13  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
+
+	* ltfssini.dtx (subsection{Miscellaneous}):
+	Handling \seriesdefault changes in a better way (gh/315).
+
 2020-04-09  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
 
 	* ltfloat.dtx (subsection{Footnotes}):
@@ -14,7 +19,7 @@
 
 	* ltfssini.dtx (section{Custom series settings for main document families}):
 	Added hooks \@expandfontdefaultshook, \@setbfseriesdefaultshook and
-	\@setndseriesdefaultshook to better support Japanese etc (gh/306)
+	\@setmdseriesdefaultshook to better support Japanese etc (gh/306)
 
 2020-03-19  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
 
diff --git a/base/doc/ltnews32.tex b/base/doc/ltnews32.tex
index 448bb597..d1e19561 100644
--- a/base/doc/ltnews32.tex
+++ b/base/doc/ltnews32.tex
@@ -223,6 +223,20 @@ to the right. This has been corrected.
 \githubissue{274}
 
 
+\subsection{Better support for the legacy series default interface}
+
+In the initial implementation of \LaTeX's font selection scheme (NFSS)
+changes to any default where always carried out by redefining some
+commands, e.g., \cs{seriesdefault}. In 2019 we introduced various
+extensions and with it new methods of customising certain parts of
+NFSS, e.g., the recommended way for changing the series default(s) is
+now through \cs{DeclareFontSeriesDefault}~\cite{32:ltnews31}. In this
+release we improved the support for legacy documents using the old
+method was improved to cover additional edge cases.
+%
+\githubissue[s]{306,315}
+
+
 \subsection{Support for uncommon font series defaults}
 
 If a font family was set up with fairly unusual font series defaults,
@@ -241,13 +255,6 @@ been corrected.
 \githubissue{291}
 
 
-\subsection{Support for the legacy series default interface}
-
-\emph{to write}
-%
-\githubissue{306}
-
-
 
 \subsection{Avoid spurious package option warning}
 
@@ -370,4 +377,22 @@ processed as part of the formula.
 \githubissue{5}
 
 
+
+\begin{thebibliography}{9}
+
+\fontsize{9.3}{11.3}\selectfont
+
+\bibitem{32:ltnews31} \LaTeX{} Project Team:
+  \emph{\LaTeXe{} news 31}.\\
+  \url{https://latex-project.org/news/latex2e-news/ltnews31.pdf}
+
+\bibitem{32:site-doc}
+  \emph{\LaTeX{} documentation on the \LaTeX{} Project Website}.\\
+  \url{https://latex-project.org/help/documentation/}
+
+\end{thebibliography}
+
+
+
+
 \end{document}
diff --git a/base/ltfssdcl.dtx b/base/ltfssdcl.dtx
index a90635c6..291cd136 100644
--- a/base/ltfssdcl.dtx
+++ b/base/ltfssdcl.dtx
@@ -36,7 +36,7 @@
 %
 %
 \ProvidesFile{ltfssdcl.dtx}
-            [2020/03/19 v3.0u LaTeX Kernel (NFSS Declarative Interface)]
+            [2020/03/19 v3.0v LaTeX Kernel (NFSS Declarative Interface)]
 % \iffalse
 \documentclass{ltxdoc}
 \begin{document}
@@ -623,17 +623,19 @@
 %    \begin{macrocode}
     \let\select at group\document at select@group
 %    \end{macrocode}
-%    Install the default font attributes they are currently pointing
-%    to error font shape.
+%    Install the default font attributes as they are currently pointing
+%    to error font face. We can speed up the process by just using
+%    \cs{edef}, thereby avoiding all kind of extra processing.
 %    Don't use |\reset at font| since that would trigger |\selectfont|.
+% \changes{v3.0v}{2020/04/13}{Small update for speed.}
 %    \begin{macrocode}
     \fontencoding\encodingdefault
     \edef\f at family{\familydefault}%
     \edef\f at series{\seriesdefault}%
     \edef\f at shape{\shapedefault}%
 %    \end{macrocode}
-%    Kill all macros not longer needed.
-%    we need to add many more!!!!!!
+%    Drop stuff not longer needed.
+%    We need to add many more!!!!!!
 %    \begin{macrocode}
  \everyjob{}%
 }
diff --git a/base/ltfssini.dtx b/base/ltfssini.dtx
index 855c37d7..71d49b3a 100644
--- a/base/ltfssini.dtx
+++ b/base/ltfssini.dtx
@@ -36,7 +36,7 @@
 %
 %
 \ProvidesFile{ltfssini.dtx}
-             [2020/04/06 v3.1m LaTeX Kernel (NFSS Initialisation)]
+             [2020/04/13 v3.1n LaTeX Kernel (NFSS Initialisation)]
 % \iffalse
 \documentclass{ltxdoc}
 \begin{document}
@@ -394,7 +394,6 @@
 %  \begin{macro}{\tt at def@ult}
 %  \begin{macro}{\md at def@ult}
 %  \begin{macro}{\bf at def@ult}
-%  \begin{macro}{\fam at def@ult}
 %
 %    The family specific defaults are fully expanded, i.e., they are
 %    defined via \cs{edef} inside \cs{DeclareFontSeriesDefault}.
@@ -416,7 +415,6 @@
 %    \begin{macrocode}
   \series at maybe@drop at one@m\bfdefault\bfdef at ult
   \series at maybe@drop at one@m\mddefault\mddef at ult
-  \edef\famdef at ult{\familydefault}%
 %    \end{macrocode}
 %    Formats that set up parallel fonts, e.g., for Japanese, can use
 %    this hook to add additional code here.
@@ -425,8 +423,6 @@
   \@expandfontdefaultshook
 }
 %    \end{macrocode}
-%
-%  \end{macro}
 %  \end{macro}
 %  \end{macro}
 %  \end{macro}
@@ -962,24 +958,42 @@
 %    \end{macrocode}
 %
 %    If the document preamble has changed the \cs{familydefault} or if
-%    the if the \cs{rmdefault} contains a new font family, we have to
+%    the if the \cs{rmdefault} contains a new font family, we may have to
 %    adjust the series defaults accordingly, before starting
 %    typesetting.
 %    
-%    On the other hand if we still typeset in CM or LM then
-%    \cs{bfdefault} is wrong since it is now saying \texttt{b} and not
-%    \texttt{bx}.
-%
-%    To fix this we run \cs{rmfamily}, \cs{sffamily} or
-%    \cs{ttfamily} depending on the situation and this will correct
-%    the setup for us.
+%    Similarly, if the user has changed the \cs{mddefault} or the
+%    medium series for the family selected as document font we may
+%    also have to adjust the \cs{seriesdefault}.    
+%
+%    On the other hand if the document font is still CM or LM then
+%    \cs{bfdefault} is wrong, because it is now saying \texttt{b} and not
+%    \texttt{bx} as it should for such fonts.
+%
+%    To fix all this we first run \cs{reset at font} (the internal kernel
+%    name for \cs{normalfont}). This will set up the document encoding,
+%    family, series and shape based on the current values of
+%    \cs{encodingdefault}, \cs{familydefault}, \cs{seriesdefault} and
+%    \cs{shapedefault}.
+%    However, if the family (from \cs{familydefault}) has special medium
+%    default we should switch to that (and not use what is current
+%    value from \cs{seriesdefault). This can be achieved by afterwards
+%    calling \cs{mediumseries} and then changing \cs{seriesdefault} to
+%    the now current series value (in \cs{f at series}).
+%
+%    But what should happen if \cs{seriesdefault} got explicitly
+%    changed?  In that case the explicit change should surive and we
+%    should not alter \cs{seriesdefault}. This is solved by comparing
+%    the current value of \cs{seriesdefault} with a kernel version
+%    saved in the format and if they differ we do not call
+%    \cs{mdseries} or change \cs{seriesdefault}.
+% \changes{v3.1n}{2020/04/13}{Handling \cs{seriesdefault} changes (gh/315)}
 %    \begin{macrocode}
-  \expand at font@defaults
-%  \ifx\famdef at ult\rmdef at ult      \rmfamily
-%  \else\ifx\famdef at ult\sfdef at ult \sffamily
-%  \else\ifx\famdef at ult\ttdef at ult \ttfamily
-%  \fi\fi\fi
   \reset at font
+  \ifx\seriesdefault\seriesdefault at kernel
+    \mdseries
+    \let\seriesdefault\f at series
+  \fi
 }%
 %    \end{macrocode}
 %  \end{macro}
@@ -1658,6 +1672,26 @@
 %    \end{macrocode}
 %
 %
+%
+%  \begin{macro}{\seriesdefault}
+%  \begin{macro}{\seriesdefault at kernel}
+%    After \cs{seriesdefault} got defined inside \texttt{fonttext.ltx}
+%    or a \texttt{.cfg} file overwriting it, we alter its value by
+%    appending \cs{@empty} to it. This will vanish if expanded but
+%    allows us to check if the default gets altered (even to the same
+%    value) in the document preamble. All we have to do is to save the
+%    current value somewhere and later compare the two. For this we
+%    use \cs{seriesdefault at kernel}.
+% \changes{v3.1n}{2020/04/13}{Handling \cs{seriesdefault} changes (gh/315)}
+%    \begin{macrocode}
+\expandafter\def\expandafter\seriesdefault\expandafter{\seriesdefault\@empty}
+\let\seriesdefault at kernel\seriesdefault
+%    \end{macrocode}
+%  \end{macro}
+%  \end{macro}
+%
+%
+%
 % \begin{macro}{\@acci}
 % \begin{macro}{\@accii}
 % \begin{macro}{\@acciii}
diff --git a/base/testfiles/github-0306b.lvt b/base/testfiles/github-0306b.lvt
index 8688f9d4..c077a9b0 100644
--- a/base/testfiles/github-0306b.lvt
+++ b/base/testfiles/github-0306b.lvt
@@ -47,7 +47,7 @@
 \begin{document}
 \TIMO
 
-\currentstate{after begin document}
+\currentstate{after begin document (normalfont now uses mddefault = b)}
 
 
 \bfseries
diff --git a/base/testfiles/github-0306b.tlg b/base/testfiles/github-0306b.tlg
index f4a384ce..2ca0ac8b 100644
--- a/base/testfiles/github-0306b.tlg
+++ b/base/testfiles/github-0306b.tlg
@@ -51,18 +51,18 @@ Don't change this file in any respect.
     \bfseries at rm@kernel = bx 
     \bfseries at sf@kernel = bx 
     \bfseries at tt@kernel = bx 
-==== We are after begin document =====
+==== We are after begin document (normalfont now uses mddefault = b) =====
     \mddefault = b 
     \bfdefault = sb 
 ------
     \mddef at ult = b 
     \bfdef at ult = sb 
 ------
-    \mdseries at rm = m 
+    \mdseries at rm = b 
     \bfseries at rm = bx 
-    \mdseries at sf = m 
+    \mdseries at sf = b 
     \bfseries at sf = bx 
-    \mdseries at tt = m 
+    \mdseries at tt = b 
     \bfseries at tt = bx 
 ------
     \bfseries at rm@kernel = bx 
@@ -77,11 +77,11 @@ LaTeX Font Warning: Font shape `OT1/cmr/sb/n' undefined
     \mddef at ult = b 
     \bfdef at ult = sb 
 ------
-    \mdseries at rm = m 
+    \mdseries at rm = b 
     \bfseries at rm = sb 
-    \mdseries at sf = m 
+    \mdseries at sf = b 
     \bfseries at sf = sb 
-    \mdseries at tt = m 
+    \mdseries at tt = b 
     \bfseries at tt = sb 
 ------
     \bfseries at rm@kernel = bx 
diff --git a/base/testfiles/github-0315a.lvt b/base/testfiles/github-0315a.lvt
new file mode 100644
index 00000000..27ccdc63
--- /dev/null
+++ b/base/testfiles/github-0315a.lvt
@@ -0,0 +1,51 @@
+
+
+\makeatletter
+\def\showme#1{\typeout{\@spaces\string#1 = \meaning#1}}
+\def\currentstate#1{%
+ \typeout{==== We are #1 =====}%
+  \showme\seriesdefault
+  \showme\seriesdefault at kernel
+ \typeout{------}%
+  \showme\f at series
+ \typeout{------}%
+ \typeout{\@spaces\expandafter\meaning\the\font}
+ \typeout{------}%
+ \typeout{}%
+  }
+\makeatother
+
+\input{test2e}
+
+
+\START
+
+\currentstate{at kernel state}
+
+\OMIT
+\documentclass{article}
+\TIMO
+
+\currentstate{after class}
+
+\DeclareFontSeriesDefault[rm]{md}{b}
+
+\currentstate{after changing rm md default (not change yet before begin document)}
+
+
+\OMIT
+\begin{document}
+\TIMO
+
+\currentstate{after begin document}
+
+\normalfont
+\currentstate{after \string\normalfont}
+
+
+\mdseries 
+\currentstate{after \string\mdseries}
+
+
+ 
+\END
diff --git a/base/testfiles/github-0315a.tlg b/base/testfiles/github-0315a.tlg
new file mode 100644
index 00000000..fcadaae5
--- /dev/null
+++ b/base/testfiles/github-0315a.tlg
@@ -0,0 +1,50 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+==== We are at kernel state =====
+    \seriesdefault = macro:->\mddefault \@empty 
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->m
+------
+    select font nullfont
+------
+==== We are after class =====
+    \seriesdefault = macro:->\mddefault \@empty 
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->m
+------
+    select font cmr10
+------
+==== We are after changing rm md default (not change yet before begin document) =====
+    \seriesdefault = macro:->\mddefault \@empty 
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->m
+------
+    select font cmr10
+------
+==== We are after begin document =====
+    \seriesdefault = macro:->b
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->b
+------
+    select font cmb10
+------
+==== We are after \normalfont =====
+    \seriesdefault = macro:->b
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->b
+------
+    select font cmb10
+------
+==== We are after \mdseries =====
+    \seriesdefault = macro:->b
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->b
+------
+    select font cmb10
+------
diff --git a/base/testfiles/github-0315b.lvt b/base/testfiles/github-0315b.lvt
new file mode 100644
index 00000000..2444ec6b
--- /dev/null
+++ b/base/testfiles/github-0315b.lvt
@@ -0,0 +1,57 @@
+
+
+\makeatletter
+\def\showme#1{\typeout{\@spaces\string#1 = \meaning#1}}
+\def\currentstate#1{%
+ \typeout{==== We are #1 =====}%
+  \showme\seriesdefault
+  \showme\seriesdefault at kernel
+ \typeout{------}%
+  \showme\f at series
+ \typeout{------}%
+ \typeout{\@spaces\expandafter\meaning\the\font}
+ \typeout{------}%
+ \typeout{}%
+  }
+\makeatother
+
+\input{test2e}
+
+
+\START
+
+\currentstate{at kernel state}
+
+\OMIT
+\documentclass{article}
+\TIMO
+
+\currentstate{after class}
+
+\DeclareFontSeriesDefault[rm]{md}{b}
+\renewcommand\familydefault{cmss}
+\renewcommand\seriesdefault{bx}
+
+
+\currentstate{after changing rm md default (not change yet before begin document)}
+
+
+\OMIT
+\begin{document}
+\TIMO
+
+\currentstate{after begin document}
+
+\normalfont
+\currentstate{after \string\normalfont}
+
+
+
+\mdseries 
+\currentstate{after \string\mdseries}
+
+\rmfamily
+\currentstate{after \string\rmfamily}
+
+ 
+\END
diff --git a/base/testfiles/github-0315b.tlg b/base/testfiles/github-0315b.tlg
new file mode 100644
index 00000000..741b99ed
--- /dev/null
+++ b/base/testfiles/github-0315b.tlg
@@ -0,0 +1,58 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+==== We are at kernel state =====
+    \seriesdefault = macro:->\mddefault \@empty 
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->m
+------
+    select font nullfont
+------
+==== We are after class =====
+    \seriesdefault = macro:->\mddefault \@empty 
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->m
+------
+    select font cmr10
+------
+==== We are after changing rm md default (not change yet before begin document) =====
+    \seriesdefault = \long macro:->bx
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->m
+------
+    select font cmr10
+------
+==== We are after begin document =====
+    \seriesdefault = \long macro:->bx
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->bx
+------
+    select font cmssbx10
+------
+==== We are after \normalfont =====
+    \seriesdefault = \long macro:->bx
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->bx
+------
+    select font cmssbx10
+------
+==== We are after \mdseries =====
+    \seriesdefault = \long macro:->bx
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->m
+------
+    select font cmss10
+------
+==== We are after \rmfamily =====
+    \seriesdefault = \long macro:->bx
+    \seriesdefault at kernel = macro:->\mddefault \@empty 
+------
+    \f at series = macro:->b
+------
+    select font cmb10
+------
diff --git a/base/testfiles/github-robust-0123.luatex.tlg b/base/testfiles/github-robust-0123.luatex.tlg
index c3d35eec..1bf4e093 100644
--- a/base/testfiles/github-robust-0123.luatex.tlg
+++ b/base/testfiles/github-robust-0123.luatex.tlg
@@ -183,10 +183,6 @@ l. ...\show\Downarrow
 ---------------------------------------
 \fnsymbol{page} -> \TextOrMath  {\textasteriskcentered }{*}
 ---------------------------------------
-\hline -> \noalign {\hrule height\arrayrulewidth \futurelet ??}
----------------------------------------
-\label{foo} -> \relax \begingroup \let 1\relax \let \@unexpandable at protect\edef ??{\write \@auxout {\newlabel{foo}{{}{1}}}}??\endgroup \relax 
----------------------------------------
 \pageref{foo} -> \G at refundefinedtrue{\mbox {\normalfont \bfseries ??}}\GenericWarning {               }{LaTeX Warning: Reference `foo' on page 1 undefined}
 ---------------------------------------
 \ref{foo} -> \G at refundefinedtrue{\mbox {\normalfont \bfseries ??}}\GenericWarning {               }{LaTeX Warning: Reference `foo' on page 1 undefined}
diff --git a/base/testfiles/github-robust-0123.lvt b/base/testfiles/github-robust-0123.lvt
index cc0171b3..3ce26639 100644
--- a/base/testfiles/github-robust-0123.lvt
+++ b/base/testfiles/github-robust-0123.lvt
@@ -269,8 +269,8 @@
 \test{\alph{page}}
 \test{\arabic{page}}
 \test{\fnsymbol{page}}
-\test{\hline}           % may not be easy to make that robust (\noalign needs to be seen)
-\test{\label{foo}}      % again may not be easy to make robust
+%%\test{\hline}           % may not be easy to make that robust (\noalign needs to be seen)
+%%\test{\label{foo}}      % again may not be easy to make robust
 \test{\pageref{foo}}              % maybe difficult to make robust
 \test{\ref{foo}}                      % maybe difficult to make robust
 \test{\roman{page}}
diff --git a/base/testfiles/github-robust-0123.tlg b/base/testfiles/github-robust-0123.tlg
index 66897506..67714df6 100644
--- a/base/testfiles/github-robust-0123.tlg
+++ b/base/testfiles/github-robust-0123.tlg
@@ -183,10 +183,6 @@ l. ...\show\Downarrow
 ---------------------------------------
 \fnsymbol{page} -> \TextOrMath  {\textasteriskcentered }{*}
 ---------------------------------------
-\hline -> \noalign {\hrule height\arrayrulewidth \futurelet ??}
----------------------------------------
-\label{foo} -> \relax \begingroup \let 1\relax \let \@unexpandable at protect\edef ??{\write \@auxout {\newlabel{foo}{{}{1}}}}??\endgroup \relax 
----------------------------------------
 \pageref{foo} -> \G at refundefinedtrue{\mbox {\normalfont \bfseries ??}}\GenericWarning {               }{LaTeX Warning: Reference `foo' on page 1 undefined}
 ---------------------------------------
 \ref{foo} -> \G at refundefinedtrue{\mbox {\normalfont \bfseries ??}}\GenericWarning {               }{LaTeX Warning: Reference `foo' on page 1 undefined}
diff --git a/base/testfiles/github-robust-0123.xetex.tlg b/base/testfiles/github-robust-0123.xetex.tlg
index 96a83b78..af847ba0 100644
--- a/base/testfiles/github-robust-0123.xetex.tlg
+++ b/base/testfiles/github-robust-0123.xetex.tlg
@@ -183,10 +183,6 @@ l. ...\show\Downarrow
 ---------------------------------------
 \fnsymbol{page} -> \TextOrMath  {\textasteriskcentered }{*}
 ---------------------------------------
-\hline -> \noalign {\hrule height\arrayrulewidth \futurelet ??}
----------------------------------------
-\label{foo} -> \relax \begingroup \let 1\relax \let \@unexpandable at protect\edef ??{\write \@auxout {\newlabel{foo}{{}{1}}}}??\endgroup \relax 
----------------------------------------
 \pageref{foo} -> \G at refundefinedtrue{\mbox {\normalfont \bfseries ??}}\GenericWarning {               }{LaTeX Warning: Reference `foo' on page 1 undefined}
 ---------------------------------------
 \ref{foo} -> \G at refundefinedtrue{\mbox {\normalfont \bfseries ??}}\GenericWarning {               }{LaTeX Warning: Reference `foo' on page 1 undefined}





More information about the latex3-commits mailing list.