diff options
author | Karl Berry <karl@freefriends.org> | 2020-05-27 21:43:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-05-27 21:43:57 +0000 |
commit | 2823ef13b9166bb2c78fe4822b9e6809c3924240 (patch) | |
tree | f25f9139e7661767ce1717fba72b91c2b69b5dd0 /Master/texmf-dist/source/latex-dev/base/ltfssini.dtx | |
parent | 9e5ce7919f1c53214d619ba6c4dc040a5bdd19ba (diff) |
latex-dev (27may20)
git-svn-id: svn://tug.org/texlive/trunk@55299 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex-dev/base/ltfssini.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex-dev/base/ltfssini.dtx | 322 |
1 files changed, 303 insertions, 19 deletions
diff --git a/Master/texmf-dist/source/latex-dev/base/ltfssini.dtx b/Master/texmf-dist/source/latex-dev/base/ltfssini.dtx index 3947b4d9538..952025375b3 100644 --- a/Master/texmf-dist/source/latex-dev/base/ltfssini.dtx +++ b/Master/texmf-dist/source/latex-dev/base/ltfssini.dtx @@ -36,7 +36,7 @@ % % \ProvidesFile{ltfssini.dtx} - [2020/03/02 v3.1k LaTeX Kernel (NFSS Initialisation)] + [2020/05/19 v3.2a LaTeX Kernel (NFSS Initialisation)] % \iffalse \documentclass{ltxdoc} \begin{document} @@ -288,8 +288,16 @@ \ifx\reserved@a\@empty \ifcsname #2series\endcsname % supported are % \[md/bf]default +% \end{macrocode} +% Adding \cs{@empty} allows us to detect if the default gets +% redefined with \cs{renewcommand} or \cs{def} by the user. +% \changes{v3.1k}{2020/03/19}{Support legacy use of \cs{bfdefault} +% and \cs{mddefault} (gh/306)} +% \begin{macrocode} \expandafter\def - \csname #2default\endcsname{#3}% + \csname #2default\endcsname{#3\@empty}% + \expandafter\def + \csname #2default@previous\endcsname{#3\@empty}% \else % \end{macrocode} % @@ -381,6 +389,11 @@ % \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}. @@ -402,10 +415,19 @@ % \begin{macrocode} \series@maybe@drop@one@m\bfdefault\bfdef@ult \series@maybe@drop@one@m\mddefault\mddef@ult - \edef\famdef@ult{\familydefault}% +% \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} @@ -425,6 +447,41 @@ % 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 @@ -444,10 +501,26 @@ % 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 @@ -610,11 +683,20 @@ % \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 @@ -622,6 +704,9 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % % @@ -873,23 +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. -% \begin{macrocode} - \expand@font@defaults - \ifx\famdef@ult\rmdef@ult \rmfamily - \else\ifx\famdef@ult\sfdef@ult \sffamily - \else\ifx\famdef@ult\ttdef@ult \ttfamily - \fi\fi\fi +% +% 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@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@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} + \reset@font + \ifx\seriesdefault\seriesdefault@kernel + \mdseries + \let\seriesdefault\f@series + \fi }% % \end{macrocode} % \end{macro} @@ -948,6 +1052,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 @@ -963,9 +1070,166 @@ %<latexrelease>\EndIncludeInRelease %<*2ekernel> % \end{macrocode} +% +% +% +% \begin{macro}{\IfFontSeriesContextTF} +% +% With the ability for \cs{bfseries} or \cs{mdseries} to be mapped +% to different NFSS axis values it becomes important to have the +% ability to determine the current context as we can no longer look +% at \cs{f@series} to answer a question such as ``am I currently +% typsetting in a bold typeface?'' +% +% This is provided by the test \cs{IfFontSeriesContextTF}. It takes +% three arguments: +% \begin{itemize} +% \item +% The context we try to check (either \texttt{bf} for bold or +% \texttt{md} for medium, i.e., the same that can go into the +% first mandatory argument of \cs{DeclareFontSeriesDefault}), +% +% \item +% what to do if we are in this context (true case) and +% +% \item +% what to do if we are not (false case). +% \end{itemize} +% This allows you to define commands like \cs{IfBold}, e.g., +%\begin{verbatim} +% \newcommand\IfBold[2]{\IfSeriesContextTF{bf}{#1}{#2}} +%\end{verbatim} +% and then do +%\begin{verbatim} +% This is \IfBold{bold}{non-bold} text. +%\end{verbatim} +% and get the appropriate result. +% +% \changes{v3.2a}{2020/05/19}{Macros added (gh/335)} +% \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\IfFontSeriesContext}{Font series context}% +\DeclareRobustCommand\IfFontSeriesContextTF[1]{% + \expand@font@defaults +% \end{macrocode} +% In the beginning we haven't found the context we are loking for. +% \begin{macrocode} + \@font@series@contextfalse +% \end{macrocode} +% We store the requested context away for use in the tests. +% \begin{macrocode} + \def\requested@test@context{#1}% +% \end{macrocode} +% The next definition is there to ensure that get a final match +% during testing +% even if the current family is non of the meta families +% (\texttt{rm}, \texttt{sf} or \texttt{tt}). This will then +% basically tests if the current font family matches the overall default. +% \begin{macrocode} + \expandafter\edef\csname ??def@ult\endcsname{\f@family}% +% \end{macrocode} +% Then we run through the meta family list (currently containing +% just the three values) followed by the artifical meta family +% \texttt{??} and test each of them in turn using +% \cs{test@font@series@context} as the testing command. +% \begin{macrocode} + \let\@elt\test@font@series@context + \@meta@family@list + \@elt{??}% + \let\@elt\relax +% \end{macrocode} +% Following that we evaluate the status of +% \cs{if@font@series@context} to determine which of the remaining +% arguments (true/false case) we have to execute. +% \begin{macrocode} + \if@font@series@context + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} +% \end{macrocode} +% \end{macro} + + +% \begin{macro}{\test@font@series@context} +% This tests the context (stored in \cs{requested@test@context}) +% and updates the bookean if the right context is found. +% \begin{macrocode} +\def\test@font@series@context#1{% +% \end{macrocode} +% First task is to figure out whether the current family matches +% \cs{rmfamily}, \cs{sffamily}, etc.\ so in \cs{reserved@a} we +% store the value of \cs{rmdef@ult} (or whatever the given meta +% family is) and compare that to \cs{f@family}. +% \begin{macrocode} + \edef\reserved@a{\csname #1def@ult\endcsname}% + \ifx\f@family\reserved@a +% \end{macrocode} +% If they match we have found the right meta family so we don't +% need to test any of the remaining meta family and therefore +% change \cs{@elt} to \cs{@gobble}. +% \begin{macrocode} + \let\@elt\@gobble +% \end{macrocode} +% Now we have to test if \cs{f@series} matches the requested +% context (e.g., whether \cs{bfseries@rm} has that value if the +% current meta family is \texttt{rm} and we are looking for the +% \texttt{bf} context). +% \begin{macrocode} + \expandafter\ifx + \csname\requested@test@context series@#1\endcsname\f@series +% \end{macrocode} +% If yes we change the boolean and are done. +% \begin{macrocode} + \@font@series@contexttrue +% \end{macrocode} +% If not then maybe the reason is that nothing special was set up +% for that meta family so we also check now check if \cs{f@series} +% matches the overall default (e.g., \cs{bfdef@ult} if we are +% looking for the bold context). If that matches we change the boolean. +% \begin{macrocode} + \else + \expandafter\ifx + \csname\requested@test@context def@ult\endcsname\f@series + \@font@series@contexttrue + \fi\fi\fi +} +% \end{macrocode} +% \end{macro} + + +% \begin{macro}{\if@font@series@context} +% The boolean to signal if we found the requested font series context. +% \begin{macrocode} +\newif\if@font@series@context +% \end{macrocode} +% \end{macro} % % +% \begin{macrocode} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +% \end{macrocode} +% +% \begin{macrocode} +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\IfFontSeriesContext}{Font series context}% +%<latexrelease> +%<latexrelease>\let\IfFontSeriesContextTF\@undefined +%<latexrelease>\let\test@font@series@context\@undefined +%<latexrelease>\let\if@font@series@context\@undefined +%<latexrelease>\let\@font@series@contexttrue\@undefined +%<latexrelease>\let\@font@series@contextfalse\@undefined +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} + + + % % \section{Supporting nested emphasis} % @@ -1565,6 +1829,26 @@ % \end{macrocode} % % +% +% \begin{macro}{\seriesdefault} +% \begin{macro}{\seriesdefault@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@kernel}. +% \changes{v3.1n}{2020/04/13}{Handling \cs{seriesdefault} changes (gh/315)} +% \begin{macrocode} +\expandafter\def\expandafter\seriesdefault\expandafter{\seriesdefault\@empty} +\let\seriesdefault@kernel\seriesdefault +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% % \begin{macro}{\@acci} % \begin{macro}{\@accii} % \begin{macro}{\@acciii} |