summaryrefslogtreecommitdiff
path: root/macros/latex-dev/base/ltfssini.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-09-01 03:03:37 +0000
committerNorbert Preining <norbert@preining.info>2020-09-01 03:03:37 +0000
commita9726d029d99c128a7abb22e73074ba0a1ce838e (patch)
treea31816862a76ed100de957dc93c04447f254132c /macros/latex-dev/base/ltfssini.dtx
parent568fe838cef40f671837d9348dd73c93d9ea962b (diff)
CTAN sync 202009010303
Diffstat (limited to 'macros/latex-dev/base/ltfssini.dtx')
-rw-r--r--macros/latex-dev/base/ltfssini.dtx785
1 files changed, 444 insertions, 341 deletions
diff --git a/macros/latex-dev/base/ltfssini.dtx b/macros/latex-dev/base/ltfssini.dtx
index 952025375b..61d0a793a0 100644
--- a/macros/latex-dev/base/ltfssini.dtx
+++ b/macros/latex-dev/base/ltfssini.dtx
@@ -36,7 +36,7 @@
%
%
\ProvidesFile{ltfssini.dtx}
- [2020/05/19 v3.2a LaTeX Kernel (NFSS Initialisation)]
+ [2020/08/27 v3.2c LaTeX Kernel (NFSS Initialisation)]
% \iffalse
\documentclass{ltxdoc}
\begin{document}
@@ -388,326 +388,6 @@
-% \begin{macro}{\expand@font@defaults}
-% \begin{macro}{\rm@def@ult}
-% \begin{macro}{\sf@def@ult}
-% \begin{macro}{\tt@def@ult}
-% \begin{macro}{\md@def@ult}
-% \begin{macro}{\bf@def@ult}
-%
-% The family specific defaults are fully expanded, i.e., they are
-% defined via \cs{edef} inside \cs{DeclareFontSeriesDefault}.
-% However, the overall defaults, e.g., \cs{bfdefault} may have been
-% redefined by the user and thus may not be fully expanded. So to
-% enable reliable comparison we make expanded versions of
-% them. That we rerun each time. The alternative would be to only
-% allow for changes before begin document.
-% \begin{macrocode}
-\def\expand@font@defaults{%
- \edef\rmdef@ult{\rmdefault}%
- \edef\sfdef@ult{\sfdefault}%
- \edef\ttdef@ult{\ttdefault}%
-% \end{macrocode}
-% The series defaults may contain some surplus \texttt{m} that we
-% need to drop here.
-% \changes{v3.1j}{2020/02/25}{Drop surplus ``m'' from \cs{bfdef@ult}
-% and \cs{mddef@ult} (gh/291)}
-% \begin{macrocode}
- \series@maybe@drop@one@m\bfdefault\bfdef@ult
- \series@maybe@drop@one@m\mddefault\mddef@ult
-% \end{macrocode}
-% Formats that set up parallel fonts, e.g., for Japanese, can use
-% this hook to add additional code here.
-% \changes{v3.1m}{2020/04/06}{Hook added (gh/306)}
-% \begin{macrocode}
- \@expandfontdefaultshook
-}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-
-
-
-% \begin{macro}{\bfseries}
-% This document command switches to the bold series.
-% \begin{macrocode}
-\DeclareRobustCommand\bfseries{%
- \not@math@alphabet\bfseries\mathbf
-% \end{macrocode}
-% In the original NFSS definition it then called \cs{fontseries}
-% with the value \cs{bfdefault}. In the new scheme we have more
-% alternatives and therefore check if the current family
-% (\cs{f@family}) is the current \cs{rmdef@ult}, \cs{sfdef@ult} or
-% \cs{ttdef@ult} and the select the correct family default in that case.
-% \changes{v3.1i}{2020/02/18}{Make the \cs{ifx} selection outside
-% of \cs{fontseries} argument so that it is not done several times}
-% \begin{macrocode}
- \expand@font@defaults
-% \end{macrocode}
-% If \cs{bfdefault} and \cs{befdefault@previous} are different then
-% the default got changed directly through the legacy interface
-% (i.e., via \cs{def} or \cs{renewcommand}. In that case we reset
-% all meta family defaults so that the document behaves like it was
-% the case before the new mechanism was introduced.
-% \changes{v3.1k}{2020/03/19}{Support legacy use of \cs{bfdefault}
-% and \cs{mddefault} (gh/306)}
-% \begin{macrocode}
- \ifx\bfdefault\bfdefault@previous\else
-% \end{macrocode}
-% We add \cs{@empty} and then let \cs{bfdefault@previous} to
-% \cs{bfdefault} so that we can detect any further change.
-% \begin{macrocode}
- \expandafter\def\expandafter\bfdefault
- \expandafter{\bfdefault\@empty}%
- \let\bfseries@previous\bfdefault
-% \end{macrocode}
-% And we reset the meta family defaults (\cs{bfdef@ult} is an
-% expanded version of \cs{bfdefault}.
-% \begin{macrocode}
- \let\bfseries@rm\bfdef@ult
- \let\bfseries@sf\bfdef@ult
- \let\bfseries@tt\bfdef@ult
-% \end{macrocode}
-%
-% Formats that set up parallel fonts, e.g., for Japanese, can use
-% this hook to add resets here.
-% \changes{v3.1m}{2020/04/06}{Hook added (gh/306)}
-% \begin{macrocode}
- \@setbfseriesdefaultshook
- \fi
-% \end{macrocode}
-%
-% \begin{macrocode}
- \ifx\f@family\rmdef@ult \fontseries\bfseries@rm
- \else\ifx\f@family\sfdef@ult \fontseries\bfseries@sf
- \else\ifx\f@family\ttdef@ult \fontseries\bfseries@tt
-% \end{macrocode}
-% If not \cs{bfdefault} is used.
-% \begin{macrocode}
- \else \fontseries\bfdefault
- \fi\fi\fi
- \selectfont
-}
-% \end{macrocode}
-% \end{macro}
-
-
-
-% \begin{macro}{\mdseries}
-% This document command switches to the medium series.
-% \changes{v3.1i}{2020/02/18}{Make the \cs{ifx} selection outside
-% of \cs{fontseries} argument so that it is not done several times}
-% \changes{v3.1k}{2020/03/19}{Support legacy use of \cs{bfdefault}
-% and \cs{mddefault} (gh/306)}
-% \begin{macrocode}
-\DeclareRobustCommand\mdseries{%
- \not@math@alphabet\mdseries\relax
- \expand@font@defaults
- \ifx\mddefault\mddefault@previous\else
- \expandafter\def\expandafter\mddefault\expandafter{\mddefault\@empty}%
- \let\mdseries@previous\mddefault
- \let\mdseries@rm\mddef@ult
- \let\mdseries@sf\mddef@ult
- \let\mdseries@tt\mddef@ult
-% \end{macrocode}
-%
-% Formats that set up parallel fonts, e.g., for Japanese, can use
-% this hook to add resets here.
-% \changes{v3.1m}{2020/04/06}{Hook added (gh/306)}
-% \begin{macrocode}
- \@setmdseriesdefaultshook
- \fi
- \ifx\f@family\rmdef@ult \fontseries\mdseries@rm
- \else\ifx\f@family\sfdef@ult \fontseries\mdseries@sf
- \else\ifx\f@family\ttdef@ult \fontseries\mdseries@tt
- \else \fontseries\mddefault
- \fi\fi\fi
- \selectfont
-}
-% \end{macrocode}
-% \end{macro}
-
-
-% \begin{macro}{\rmfamily}
-% Here are the document level commands for changing the main font
-% families, or rather, here is a documented outline of the code,
-% the actual code is then streamlined and somewhat generalized.
-%\begin{verbatim}
-%\DeclareRobustCommand\rmfamily{%
-% \not@math@alphabet\rmfamily\mathrm
-%\end{verbatim}
-% If families are changed then we have to do a bit more work.
-% In the original NFSS implementation
-% a family change kept encoding, series shape and size unchanged
-% but now we can't any
-% longer simply reuse the current series value. Instead we may have
-% to change it from one family default to the next.
-%\begin{verbatim}
-% \expand@font@defaults
-%\end{verbatim}
-% We have to do the testing while the current family is still
-% unchanged but we have to do the adjustment of the series after it
-% got changed (because the new family might has different sets
-% ofshapes available and we certainly don't want to see
-% substituation going on. So we use \cs{target@series@value} to
-% hold the target series (if any).
-%\begin{verbatim}
-% \let\target@series@value\@empty
-%\end{verbatim}
-% Thus, if the current family is the sans family
-%\begin{verbatim}
-% \ifx\f@family\sfdef@ult
-%\end{verbatim}
-% and if we using the medium series of the sans family
-%\begin{verbatim}
-% \ifx\f@series\mdseries@sf
-%\end{verbatim}
-% then lets switch to the medium series for the serif family
-%\begin{verbatim}
-% \let\target@series@value\mdseries@rm
-%\end{verbatim}
-% and if we use the bold series of the sans family switch to the
-% bold default of the serif family:
-%\begin{verbatim}
-% \else\ifx\f@series\bfseries@sf \let\target@series@value\bfseries@rm
-%\end{verbatim}
-% However, the sans family may not have any specific defaults set,
-% so we also compare with the overall defaults.
-%\begin{verbatim}
-% \else\ifx\f@series\mddef@ult \let\target@series@value\mdseries@rm
-% \else\ifx\f@series\bfdef@ult \let\target@series@value\bfseries@rm
-%\end{verbatim}
-% If neither test was true we leave the series alone. This way a
-% special manual setting such as \verb=\fontseries{lc}= is not
-% undone if the family changes (of course there may not be any
-% support for it in the new family but then the NFSS
-% substitution kicks in and sorts it out).
-%\begin{verbatim}
-% \fi\fi\fi\fi
-%
-%\end{verbatim}
-% We need to do the same if the current family is the typewriter family:
-%\begin{verbatim}
-% \else\ifx\f@family\ttdef@ult
-% \ifx\f@series\mdseries@tt \let\target@series@value\mdseries@rm
-% \else\ifx\f@series\bfseries@tt \let\target@series@value\bfseries@rm
-% \else\ifx\f@series\mddef@ult \let\target@series@value\mdseries@rm
-% \else\ifx\f@series\bfdef@ult \let\target@series@value\bfseries@rm
-% \fi\fi\fi\fi
-% \fi\fi
-%\end{verbatim}
-% With these preparations for series out of the way we can now
-% change the font family to \cs{rmdefault}.
-%\begin{verbatim}
-% \fontfamily\rmdefault
-%\end{verbatim}
-%
-% If \cs{target@series@value} is still empty there is nothing more
-% to do other than selecting the new family. However, if not then
-% we should update the font series now as well. But there is one
-% further subtle issue. We may not have loaded an \texttt{.fd} file
-% for our target font family yet. In the past that was done in
-% \cs{selectfont} if necessary but since we are now doing all the
-% comparisons in \cs{fontseries} we need to make sure that the font
-% family specifications are already loaded prior to calling
-% \cs{fontseries}.
-%\begin{verbatim}
-% \ifx\target@series@value\@empty \else
-% \maybe@load@fontshape
-%\end{verbatim}
-% Updating the series in this case means directly changing
-% \cs{f@series} to the target value. We don't want to go through
-% \cs{fontseries} because that would apply the mappings and then
-% \texttt{bx + b} would keep \texttt{bx} instead of changing to
-% \texttt{b} as desired.
-% as
-%\begin{verbatim}
-% \let\f@series\target@series@value
-% \fi
-% \selectfont}
-%\end{verbatim}
-%
-% So now for the real definition: most of the code above gets
-% delegated to a helper command \cs{prepare@family@series@update}
-% so that the definition becomes again fairly short. In addition we
-% add a hook, mainly for our Japanese friends so that the code can
-% be extended prior to the call to \cs{selectfont}.
-%
-% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook}
-% \begin{macrocode}
-\DeclareRobustCommand\rmfamily{%
- \not@math@alphabet\rmfamily\mathrm
-% \end{macrocode}
-% This holds all the code discussed above, first argument is the
-% meta family, i.e., \texttt{rm} in this case, and second argument
-% is the default family name, e.g., \texttt{cmr} indirectly
-% accessed via \cs{rmdefault}. This is calling \cs{fontfamily} and
-% if necessary \cs{fontseries} as outline above.
-% \begin{macrocode}
- \prepare@family@series@update{rm}\rmdefault
-% \end{macrocode}
-% Then comes the hook code (by default a no-op) and finally the call
-% to \cs{selectfont}.
-% \begin{macrocode}
- \@rmfamilyhook
- \selectfont}
-% \end{macrocode}
-%
-% \begin{macro}{\sffamily}
-% \begin{macro}{\ttfamily}
-% The definitions for \cs{sffamily} and \cs{ttfamily} are similar,
-% the differences are only in what font families get checked.
-% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook}
-% \begin{macrocode}
-\DeclareRobustCommand\sffamily{%
- \not@math@alphabet\sffamily\mathsf
- \prepare@family@series@update{sf}\sfdefault
- \@sffamilyhook
- \selectfont}
-% \end{macrocode}
-%
-% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook}
-% \begin{macrocode}
-\DeclareRobustCommand\ttfamily{%
- \not@math@alphabet\ttfamily\mathtt
- \prepare@family@series@update{tt}\ttdefault
- \@ttfamilyhook
- \selectfont}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-%
-% \begin{macro}{\@expandfontdefaultshook}
-% \begin{macro}{\@setbfseriesdefaultshook}
-% \begin{macro}{\@setmdseriesdefaultshook}
-% \begin{macro}{\@rmfamilyhook}
-% \begin{macro}{\@sffamilyhook}
-% \begin{macro}{\@ttfamilyhook}
-% By default the hooks do nothing.
-% \begin{macrocode}
-\let\@expandfontdefaultshook\@empty
-\let\@setbfseriesdefaultshook\@empty
-\let\@setmdseriesdefaultshook\@empty
-% \end{macrocode}
-%
-% \begin{macrocode}
-\let\@rmfamilyhook\@empty
-\let\@sffamilyhook\@empty
-\let\@ttfamilyhook\@empty
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
%
%
%
@@ -767,7 +447,7 @@
% \begin{itemize}
% \item \cs{bfseries} is called for a family using \texttt{bx}
% (e.g., CMR)
-% \item Switch to a font family that is none of the the meta
+% \item Switch to a font family that is none of the meta
% families, e.g., via \verb=\fontfamily{ptm}\selectfont=
% \item Then none of the real meta families, match but the final
% \verb=\@elt{??}= will.
@@ -944,16 +624,19 @@
% \cs{DeclareFontSeriesDefault} interface.
% \begin{macrocode}
\ifx\bfseries@rm@kernel\bfseries@rm
- \expandafter\in@\expandafter{\rmdefault}{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
+ \expandafter\in@\expandafter{\rmdefault}%
+ {cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
\ifin@ \else \def\bfseries@rm{b}\fi\fi
% \end{macrocode}
% Same approach for \cs{bfseries@sf} and \cs{bfseries@tt}:
% \begin{macrocode}
\ifx\bfseries@sf@kernel\bfseries@sf
- \expandafter\in@\expandafter{\sfdefault}{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
+ \expandafter\in@\expandafter{\sfdefault}%
+ {cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
\ifin@ \else \def\bfseries@sf{b}\fi\fi
\ifx\bfseries@tt@kernel\bfseries@tt
- \expandafter\in@\expandafter{\ttdefault}{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
+ \expandafter\in@\expandafter{\ttdefault}%
+ {cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
\ifin@ \else \def\bfseries@tt{b}\fi\fi
% \end{macrocode}
%
@@ -1033,9 +716,431 @@
%<latexrelease>\let\mdseries@rm\@undefined
%<latexrelease>\let\mdseries@sf\@undefined
%<latexrelease>\let\mdseries@tt\@undefined
-%<latexrelease>\let\expand@font@defaults\@undefined
%<latexrelease>\expandafter\let\csname ver@mweights.sty\endcsname\@undefined
%<latexrelease>
+%<latexrelease>\let\@meta@family@list\@undefined
+%<latexrelease>\let\prepare@family@series@update\@undefined
+%<latexrelease>\let\update@series@target@value\@undefined
+%<latexrelease>
+% \end{macrocode}
+% This is always called in \cs{document} so don't make it undefined.
+% \begin{macrocode}
+%<latexrelease>\let\init@series@setup\relax
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease> {\bfseries}{Custom series with hooks}%
+% \end{macrocode}
+
+
+% \begin{macro}{\expand@font@defaults}
+% \begin{macro}{\rm@def@ult}
+% \begin{macro}{\sf@def@ult}
+% \begin{macro}{\tt@def@ult}
+% \begin{macro}{\md@def@ult}
+% \begin{macro}{\bf@def@ult}
+%
+% The family specific defaults are fully expanded, i.e., they are
+% defined via \cs{edef} inside \cs{DeclareFontSeriesDefault}.
+% However, the overall defaults, e.g., \cs{bfdefault} may have been
+% redefined by the user and thus may not be fully expanded. So to
+% enable reliable comparison we make expanded versions of
+% them. That we rerun each time. The alternative would be to only
+% allow for changes before begin document.
+% \begin{macrocode}
+\def\expand@font@defaults{%
+ \edef\rmdef@ult{\rmdefault}%
+ \edef\sfdef@ult{\sfdefault}%
+ \edef\ttdef@ult{\ttdefault}%
+% \end{macrocode}
+% The series defaults may contain some surplus \texttt{m} that we
+% need to drop here.
+% \changes{v3.1j}{2020/02/25}{Drop surplus ``m'' from \cs{bfdef@ult}
+% and \cs{mddef@ult} (gh/291)}
+% \begin{macrocode}
+ \series@maybe@drop@one@m\bfdefault\bfdef@ult
+ \series@maybe@drop@one@m\mddefault\mddef@ult
+% \end{macrocode}
+% Formats that set up parallel fonts, e.g., for Japanese, can use
+% this hook to add additional code here.
+% \changes{v3.1m}{2020/04/06}{Hook added (gh/306)}
+% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface}
+% \begin{macrocode}
+ \UseHook{expand@font@defaults}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+
+
+% \begin{macro}{\bfseries}
+% This document command switches to the bold series.
+% \begin{macrocode}
+\DeclareRobustCommand\bfseries{%
+ \not@math@alphabet\bfseries\mathbf
+% \end{macrocode}
+% In the original NFSS definition it then called \cs{fontseries}
+% with the value \cs{bfdefault}. In the new scheme we have more
+% alternatives and therefore check if the current family
+% (\cs{f@family}) is the current \cs{rmdef@ult}, \cs{sfdef@ult} or
+% \cs{ttdef@ult} and the select the correct family default in that case.
+% \changes{v3.1i}{2020/02/18}{Make the \cs{ifx} selection outside
+% of \cs{fontseries} argument so that it is not done several times}
+% \begin{macrocode}
+ \expand@font@defaults
+% \end{macrocode}
+% If \cs{bfdefault} and \cs{befdefault@previous} are different then
+% the default got changed directly through the legacy interface
+% (i.e., via \cs{def} or \cs{renewcommand}. In that case we reset
+% all meta family defaults so that the document behaves like it was
+% the case before the new mechanism was introduced.
+% \changes{v3.1k}{2020/03/19}{Support legacy use of \cs{bfdefault}
+% and \cs{mddefault} (gh/306)}
+% \begin{macrocode}
+ \ifx\bfdefault\bfdefault@previous\else
+% \end{macrocode}
+% We add \cs{@empty} and then let \cs{bfdefault@previous} to
+% \cs{bfdefault} so that we can detect any further change.
+% \begin{macrocode}
+ \expandafter\def\expandafter\bfdefault
+ \expandafter{\bfdefault\@empty}%
+ \let\bfseries@previous\bfdefault
+% \end{macrocode}
+% And we reset the meta family defaults (\cs{bfdef@ult} is an
+% expanded version of \cs{bfdefault}.
+% \begin{macrocode}
+ \let\bfseries@rm\bfdef@ult
+ \let\bfseries@sf\bfdef@ult
+ \let\bfseries@tt\bfdef@ult
+% \end{macrocode}
+%
+% Formats that set up parallel fonts, e.g., for Japanese, can use
+% this hook to add resets here. Not that this hook is only run when
+% resets are necessary.
+% \changes{v3.1m}{2020/04/06}{Hook added (gh/306)}
+% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface}
+% \begin{macrocode}
+ \UseHook{bfseries/defaults}%
+ \fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \ifx\f@family\rmdef@ult \fontseries\bfseries@rm
+ \else\ifx\f@family\sfdef@ult \fontseries\bfseries@sf
+ \else\ifx\f@family\ttdef@ult \fontseries\bfseries@tt
+% \end{macrocode}
+% If not \cs{bfdefault} is used.
+% \begin{macrocode}
+ \else \fontseries\bfdefault
+ \fi\fi\fi
+% \end{macrocode}
+% This hook in contrast is always executed.
+% \begin{macrocode}
+ \UseHook{bfseries}%
+ \selectfont
+}
+% \end{macrocode}
+% \end{macro}
+
+
+
+% \begin{macro}{\mdseries}
+% This document command switches to the medium series.
+% \changes{v3.1i}{2020/02/18}{Make the \cs{ifx} selection outside
+% of \cs{fontseries} argument so that it is not done several times}
+% \changes{v3.1k}{2020/03/19}{Support legacy use of \cs{bfdefault}
+% and \cs{mddefault} (gh/306)}
+% \begin{macrocode}
+\DeclareRobustCommand\mdseries{%
+ \not@math@alphabet\mdseries\relax
+ \expand@font@defaults
+ \ifx\mddefault\mddefault@previous\else
+ \expandafter\def\expandafter\mddefault\expandafter{\mddefault\@empty}%
+ \let\mdseries@previous\mddefault
+ \let\mdseries@rm\mddef@ult
+ \let\mdseries@sf\mddef@ult
+ \let\mdseries@tt\mddef@ult
+% \end{macrocode}
+%
+% Formats that set up parallel fonts, e.g., for Japanese, can use
+% this hook to add resets here.
+% \changes{v3.1m}{2020/04/06}{Hook added (gh/306)}
+% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface}
+% \begin{macrocode}
+ \UseHook{mdseries/defaults}%
+ \fi
+ \ifx\f@family\rmdef@ult \fontseries\mdseries@rm
+ \else\ifx\f@family\sfdef@ult \fontseries\mdseries@sf
+ \else\ifx\f@family\ttdef@ult \fontseries\mdseries@tt
+ \else \fontseries\mddefault
+ \fi\fi\fi
+ \UseHook{mdseries}%
+ \selectfont
+}
+% \end{macrocode}
+% \end{macro}
+
+
+% \begin{macro}{\rmfamily}
+% Here are the document level commands for changing the main font
+% families, or rather, here is a documented outline of the code,
+% the actual code is then streamlined and somewhat generalized.
+%\begin{verbatim}
+%\DeclareRobustCommand\rmfamily{%
+% \not@math@alphabet\rmfamily\mathrm
+%\end{verbatim}
+% If families are changed then we have to do a bit more work.
+% In the original NFSS implementation
+% a family change kept encoding, series shape and size unchanged
+% but now we can't any
+% longer simply reuse the current series value. Instead we may have
+% to change it from one family default to the next.
+%\begin{verbatim}
+% \expand@font@defaults
+%\end{verbatim}
+% We have to do the testing while the current family is still
+% unchanged but we have to do the adjustment of the series after it
+% got changed (because the new family might has different sets
+% ofshapes available and we certainly don't want to see
+% substituation going on. So we use \cs{target@series@value} to
+% hold the target series (if any).
+%\begin{verbatim}
+% \let\target@series@value\@empty
+%\end{verbatim}
+% Thus, if the current family is the sans family
+%\begin{verbatim}
+% \ifx\f@family\sfdef@ult
+%\end{verbatim}
+% and if we using the medium series of the sans family
+%\begin{verbatim}
+% \ifx\f@series\mdseries@sf
+%\end{verbatim}
+% then lets switch to the medium series for the serif family
+%\begin{verbatim}
+% \let\target@series@value\mdseries@rm
+%\end{verbatim}
+% and if we use the bold series of the sans family switch to the
+% bold default of the serif family:
+%\begin{verbatim}
+% \else\ifx\f@series\bfseries@sf \let\target@series@value\bfseries@rm
+%\end{verbatim}
+% However, the sans family may not have any specific defaults set,
+% so we also compare with the overall defaults.
+%\begin{verbatim}
+% \else\ifx\f@series\mddef@ult \let\target@series@value\mdseries@rm
+% \else\ifx\f@series\bfdef@ult \let\target@series@value\bfseries@rm
+%\end{verbatim}
+% If neither test was true we leave the series alone. This way a
+% special manual setting such as \verb=\fontseries{lc}= is not
+% undone if the family changes (of course there may not be any
+% support for it in the new family but then the NFSS
+% substitution kicks in and sorts it out).
+%\begin{verbatim}
+% \fi\fi\fi\fi
+%
+%\end{verbatim}
+% We need to do the same if the current family is the typewriter family:
+%\begin{verbatim}
+% \else\ifx\f@family\ttdef@ult
+% \ifx\f@series\mdseries@tt \let\target@series@value\mdseries@rm
+% \else\ifx\f@series\bfseries@tt \let\target@series@value\bfseries@rm
+% \else\ifx\f@series\mddef@ult \let\target@series@value\mdseries@rm
+% \else\ifx\f@series\bfdef@ult \let\target@series@value\bfseries@rm
+% \fi\fi\fi\fi
+% \fi\fi
+%\end{verbatim}
+% With these preparations for series out of the way we can now
+% change the font family to \cs{rmdefault}.
+%\begin{verbatim}
+% \fontfamily\rmdefault
+%\end{verbatim}
+%
+% If \cs{target@series@value} is still empty there is nothing more
+% to do other than selecting the new family. However, if not then
+% we should update the font series now as well. But there is one
+% further subtle issue. We may not have loaded an \texttt{.fd} file
+% for our target font family yet. In the past that was done in
+% \cs{selectfont} if necessary but since we are now doing all the
+% comparisons in \cs{fontseries} we need to make sure that the font
+% family specifications are already loaded prior to calling
+% \cs{fontseries}.
+%\begin{verbatim}
+% \ifx\target@series@value\@empty \else
+% \maybe@load@fontshape
+%\end{verbatim}
+% Updating the series in this case means directly changing
+% \cs{f@series} to the target value. We don't want to go through
+% \cs{fontseries} because that would apply the mappings and then
+% \texttt{bx + b} would keep \texttt{bx} instead of changing to
+% \texttt{b} as desired.
+% as
+%\begin{verbatim}
+% \let\f@series\target@series@value
+% \fi
+% \selectfont}
+%\end{verbatim}
+%
+% So now for the real definition: most of the code above gets
+% delegated to a helper command \cs{prepare@family@series@update}
+% so that the definition becomes again fairly short. In addition we
+% add a hook, mainly for our Japanese friends so that the code can
+% be extended prior to the call to \cs{selectfont}.
+%
+% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook}
+% \begin{macrocode}
+\DeclareRobustCommand\rmfamily{%
+ \not@math@alphabet\rmfamily\mathrm
+% \end{macrocode}
+% This holds all the code discussed above, first argument is the
+% meta family, i.e., \texttt{rm} in this case, and second argument
+% is the default family name, e.g., \texttt{cmr} indirectly
+% accessed via \cs{rmdefault}. This is calling \cs{fontfamily} and
+% if necessary \cs{fontseries} as outline above.
+% \begin{macrocode}
+ \prepare@family@series@update{rm}\rmdefault
+% \end{macrocode}
+% Then comes the hook code (by default a no-op) and finally the call
+% to \cs{selectfont}.
+% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface}
+% \begin{macrocode}
+ \UseHook{rmfamily}%
+ \selectfont}
+% \end{macrocode}
+%
+% \begin{macro}{\sffamily}
+% \begin{macro}{\ttfamily}
+% The definitions for \cs{sffamily} and \cs{ttfamily} are similar,
+% the differences are only in what font families get checked.
+% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook}
+% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface}
+% \begin{macrocode}
+\DeclareRobustCommand\sffamily{%
+ \not@math@alphabet\sffamily\mathsf
+ \prepare@family@series@update{sf}\sfdefault
+ \UseHook{sffamily}%
+ \selectfont}
+% \end{macrocode}
+%
+% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook}
+% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface}
+% \begin{macrocode}
+\DeclareRobustCommand\ttfamily{%
+ \not@math@alphabet\ttfamily\mathtt
+ \prepare@family@series@update{tt}\ttdefault
+ \UseHook{ttfamily}%
+ \selectfont}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{macro}{rmfamily,sffamily,ttfamily,normalfont,expand@font@defaults,
+% bfseries,bfseries/defaults,mdseries,mdseries/defaults}
+% Declare the hooks used above.
+% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface}
+% \begin{macrocode}
+\NewHook{rmfamily}
+\NewHook{sffamily}
+\NewHook{ttfamily}
+\NewHook{normalfont}
+\NewHook{expand@font@defaults}
+\NewHook{bfseries}
+\NewHook{bfseries/defaults}
+\NewHook{mdseries}
+\NewHook{mdseries/defaults}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@rmfamilyhook}
+% \begin{macro}{\@sffamilyhook}
+% \begin{macro}{\@ttfamilyhook}
+% These four hooks have legacy versions used in 2020/02/02 so we
+% should support them until they aren't any longer used.
+% \begin{macrocode}
+\let\@rmfamilyhook\@empty
+\let\@sffamilyhook\@empty
+\let\@ttfamilyhook\@empty
+\let\@defaulfamilyhook\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macrocode}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2020/02/02}%
+%<latexrelease> {\bfseries}{Custom series with hooks}%
+%<latexrelease>
+%<latexrelease>\def\expand@font@defaults{%
+%<latexrelease> \edef\rmdef@ult{\rmdefault}%
+%<latexrelease> \edef\sfdef@ult{\sfdefault}%
+%<latexrelease> \edef\ttdef@ult{\ttdefault}%
+%<latexrelease> \edef\bfdef@ult{\bfdefault}%
+%<latexrelease> \edef\mddef@ult{\mddefault}%
+%<latexrelease> \edef\famdef@ult{\familydefault}%
+%<latexrelease>}
+%<latexrelease>
+%<latexrelease>\DeclareRobustCommand\bfseries{%
+%<latexrelease> \not@math@alphabet\bfseries\mathbf
+%<latexrelease> \expand@font@defaults
+%<latexrelease> \ifx\f@family\rmdef@ult \fontseries\bfseries@rm
+%<latexrelease> \else\ifx\f@family\sfdef@ult \fontseries\bfseries@sf
+%<latexrelease> \else\ifx\f@family\ttdef@ult \fontseries\bfseries@tt
+%<latexrelease> \else \fontseries\bfdefault
+%<latexrelease> \fi\fi\fi
+%<latexrelease> \selectfont
+%<latexrelease>}
+%<latexrelease>
+%<latexrelease>\DeclareRobustCommand\mdseries{%
+%<latexrelease> \not@math@alphabet\mdseries\relax
+%<latexrelease> \expand@font@defaults
+%<latexrelease> \ifx\f@family\rmdef@ult \fontseries\mdseries@rm
+%<latexrelease> \else\ifx\f@family\sfdef@ult \fontseries\mdseries@sf
+%<latexrelease> \else\ifx\f@family\ttdef@ult \fontseries\mdseries@tt
+%<latexrelease> \else \fontseries\mddefault
+%<latexrelease> \fi\fi\fi
+%<latexrelease> \selectfont
+%<latexrelease>}
+%<latexrelease>
+%<latexrelease>\DeclareRobustCommand\rmfamily{%
+%<latexrelease> \not@math@alphabet\rmfamily\mathrm
+%<latexrelease> \prepare@family@series@update{rm}\rmdefault
+%<latexrelease> \@rmfamilyhook
+%<latexrelease> \selectfont}
+%<latexrelease>\DeclareRobustCommand\sffamily{%
+%<latexrelease> \not@math@alphabet\sffamily\mathsf
+%<latexrelease> \prepare@family@series@update{sf}\sfdefault
+%<latexrelease> \@sffamilyhook
+%<latexrelease> \selectfont}
+%<latexrelease>\DeclareRobustCommand\ttfamily{%
+%<latexrelease> \not@math@alphabet\ttfamily\mathtt
+%<latexrelease> \prepare@family@series@update{tt}\ttdefault
+%<latexrelease> \@ttfamilyhook
+%<latexrelease> \selectfont}
+%<latexrelease>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\bfseries}{Custom series with hooks}%
+%<latexrelease>
+%<latexrelease>\let\expand@font@defaults\@undefined
+%<latexrelease>
%<latexrelease>\DeclareRobustCommand\bfseries
%<latexrelease> {\not@math@alphabet\bfseries\mathbf
%<latexrelease> \fontseries\bfdefault\selectfont}
@@ -1052,20 +1157,9 @@
%<latexrelease> {\not@math@alphabet\ttfamily\mathtt
%<latexrelease> \fontfamily\ttdefault\selectfont}
%<latexrelease>
-%<latexrelease>\let\@expandfontdefaultshook\@undefined
-%<latexrelease>\let\@setbfseriesdefaultshook\@undefined
-%<latexrelease>\let\@setmdseriesdefaultshook\@undefined
%<latexrelease>\let\@rmfamilyhook\@undefined
%<latexrelease>\let\@sffamilyhook\@undefined
%<latexrelease>\let\@ttfamilyhook\@undefined
-%<latexrelease>\let\@meta@family@list\@undefined
-%<latexrelease>\let\prepare@family@series@update\@undefined
-%<latexrelease>\let\update@series@target@value\@undefined
-%<latexrelease>
-% \end{macrocode}
-% This is always called in \cs{document} so don't make it undefined.
-% \begin{macrocode}
-%<latexrelease>\let\init@series@setup\relax
%<latexrelease>
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
@@ -1110,7 +1204,10 @@
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2020/10/01}%
-%<latexrelease> {\IfFontSeriesContext}{Font series context}%
+%<latexrelease> {\IfFontSeriesContextTF}{Font series context}%
+% \end{macrocode}
+%
+% \begin{macrocode}
\DeclareRobustCommand\IfFontSeriesContextTF[1]{%
\expand@font@defaults
% \end{macrocode}
@@ -1217,7 +1314,7 @@
%
% \begin{macrocode}
%<latexrelease>\IncludeInRelease{0000/00/00}%
-%<latexrelease> {\IfFontSeriesContext}{Font series context}%
+%<latexrelease> {\IfFontSeriesContextTF}{Font series context}%
%<latexrelease>
%<latexrelease>\let\IfFontSeriesContextTF\@undefined
%<latexrelease>\let\test@font@series@context\@undefined
@@ -1668,8 +1765,14 @@
\edef\f@shape{\shapedefault}%
% \end{macrocode}
%
+% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface}
+% \begin{macrocode}
+ \UseHook{normalfont}%
+% \end{macrocode}
+% This is the old name for the hook introduced in 2020/02/02.
+% It will be removed in one of the future releases!
% \begin{macrocode}
- \@defaultfamilyhook
+ \@defaultfamilyhook % hookname from 2020/02 will vanish
\selectfont}
% \end{macrocode}
%
@@ -1684,7 +1787,7 @@
% By default the hooks do nothing.
% \changes{v3.1h}{2020/02/10}{Add \cs{@defaultfamilyhook} to \cs{normalfont} (gh/269)}
% \begin{macrocode}
-\let\@defaultfamilyhook\@empty
+\let\@defaultfamilyhook\@empty %FMi sort out
% \end{macrocode}
% \end{macro}
%