[latex3-commits] [git/LaTeX3-latex3-latex2e] nfssaxes: still working on getting the logic right (8f3f68c9)

Frank Mittelbach frank.mittelbach at latex-project.org
Tue Oct 22 10:58:45 CEST 2019


Repository : https://github.com/latex3/latex2e
On branch  : nfssaxes
Link       : https://github.com/latex3/latex2e/commit/8f3f68c91a0547dfea724011089239d46758dbce

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

commit 8f3f68c91a0547dfea724011089239d46758dbce
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Tue Oct 22 10:58:45 2019 +0200

    still working on getting the logic right


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

8f3f68c91a0547dfea724011089239d46758dbce
 base/nfssaxes.tex                          | 78 +++++++++++++++++++++++++-----
 base/testfiles-search/tlb-nfssaxes-006.lvt | 45 +++++++++++++++++
 base/testfiles-search/tlb-nfssaxes-006.tlg | 20 ++++++++
 3 files changed, 132 insertions(+), 11 deletions(-)

diff --git a/base/nfssaxes.tex b/base/nfssaxes.tex
index cdc64d0a..e9d37f0e 100644
--- a/base/nfssaxes.tex
+++ b/base/nfssaxes.tex
@@ -1273,6 +1273,14 @@
                                              % \[md/bf]series@[rm/sf/tt]
       \expandafter\edef
          \csname #2series@#1\endcsname{#3}%                     
+%    \end{macrocode}
+%
+%    If the interface is used we remove the frozen kernel
+%    default. This way, we know that something was explicitly set up
+%    (even if the setup has the same value as the default).
+%    \begin{macrocode}
+      \expandafter\let
+         \csname #2series@#1 at kernel\endcsname\@undefined
     \else
        \@latex at error{Wrong syntax for \string\DeclareFontSeriesDefault}%
           {Optional first argument must be 'rm', 'sf', or 'tt'. \MessageBreak
@@ -1292,7 +1300,7 @@
 %  \begin{macro}{\bfseries at rm}
 %  \begin{macro}{\bfseries at sf}
 %  \begin{macro}{\bfseries at tt}
-%    We initialize the family specific defaulst at the end of the
+%    We initialize the family specific default at the end of the
 %    format generation. Later on they may get overwritten in the
 %    preamble or a package via \cs{DeclareFontSeriesDefault} (or
 %    possibly directly).
@@ -1313,9 +1321,16 @@
 %    \end{macrocode}
 %    
 %    \begin{macrocode}
-\edef\bfseries at rm{bx}        
-\edef\bfseries at sf{bx}
-\edef\bfseries at tt{bx}
+\def\bfseries at rm{bx}    
+\def\bfseries at sf{bx}
+\def\bfseries at tt{bx}
+%    \end{macrocode}
+%
+%    Frozen version of the kernel defaults so we can see if they have changed.
+%    \begin{macrocode}
+\let\bfseries at rm@kernel\bfseries at rm
+\let\bfseries at sf@kernel\bfseries at sf
+\let\bfseries at tt@kernel\bfseries at tt
 %    \end{macrocode}
 %
 %    The default for the medium series is \texttt{m} and this will be
@@ -1500,7 +1515,15 @@
 %    \begin{macrocode}
   \ifx\target at series@value\@empty \else
     \begingroup\try at load@fontshape\endgroup
-    \fontseries\target at series@value
+%    \end{macrocode}
+%    Updating the series in this case means directly changing
+%    \cs{f at 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{macrocode}
+    \let\f at series\target at series@value
   \fi
   \selectfont}
 %    \end{macrocode}
@@ -1530,7 +1553,7 @@
   \fontfamily\sfdefault
   \ifx\target at series@value\@empty \else
     \begingroup\try at load@fontshape\endgroup
-    \fontseries\target at series@value
+    \let\f at series\target at series@value
   \fi
   \selectfont}
 %    \end{macrocode}
@@ -1556,7 +1579,7 @@
   \fontfamily\ttdefault
   \ifx\target at series@value\@empty \else
     \begingroup\try at load@fontshape\endgroup
-    \fontseries\target at series@value
+    \let\f at series\target at series@value
   \fi
   \selectfont}
 %    \end{macrocode}
@@ -1573,6 +1596,43 @@
 
 %  \begin{macro}{\AtBeginDocument}
 %    
+%    \begin{macrocode}
+\AtBeginDocument{%
+%    \end{macrocode}
+%
+%    We only want \texttt{bx} in \cs{bfseries at rm} if the Roman font is
+%    Computer Modern or Latin Modern, otherwise it should be
+%    \texttt{b}. It was set to \texttt{bx} in the kernel so that any
+%    font use with the default families in the preamble get this
+%    value. Now at the real document start we check if the fonts have
+%    been changed. If there was a \cs{DeclareFontSeriesDefault}
+%    declaration or \cs{bfseries at rm} was directly altered then it
+%    differs from \cs{bfseries at rm@kernel} and we do nothing.
+%    Otherwise we check if \cs{rmdefault} is one of the CM/LM font
+%    families and if so we keep \texttt{bx} otherwise we change it to
+%    \texttt{b}.
+%
+%    This approach doesn't cover one case: CM/LM got changed to a
+%    different family that supports \texttt{bx}, but the support
+%    package for that family used \verb=\def\bfseries at rm{bx}= instead
+%    of using  \cs{DeclareFontSeriesDefault}. In that case the code
+%    here changes it to \texttt{b}. Solution: use the
+%    \cs{DeclareFontSeriesDefault} interface.
+%    \begin{macrocode}
+  \ifx\bfseries at rm@kernel\bfseries at rm
+    \expandafter\in@\expandafter{\rmdefault}{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
+    \ifin@ \else \def\bfseries at rm{b}\fi\fi
+%    \end{macrocode}
+%    Same approach for \cs{bfseries at sf} and \cs{bfseries at tt}:
+%    \begin{macrocode}
+  \ifx\bfseries at sf@kernel\bfseries at sf
+    \expandafter\in@\expandafter{\sfdefault}{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
+    \ifin@ \else \def\bfseries at sf{b}\fi\fi
+  \ifx\bfseries at tt@kernel\bfseries at tt
+    \expandafter\in@\expandafter{\ttdefault}{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
+    \ifin@ \else \def\bfseries at tt{b}\fi\fi
+%    \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
 %    adjust the series defaults accordingly, before starting
@@ -1580,11 +1640,7 @@
 %    \cs{ttfamily} depending on the situation which does that (as a
 %    sideeffect) for us.
 %    \begin{macrocode}
-\AtBeginDocument{%
   \expand at font@defaults
-%    \end{macrocode}
-%    
-%    \begin{macrocode}
   \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
diff --git a/base/testfiles-search/tlb-nfssaxes-006.lvt b/base/testfiles-search/tlb-nfssaxes-006.lvt
new file mode 100644
index 00000000..b9d3e4a5
--- /dev/null
+++ b/base/testfiles-search/tlb-nfssaxes-006.lvt
@@ -0,0 +1,45 @@
+\documentclass{article}
+
+\input{test2e}
+
+
+\makeatletter
+\def\showfont#1{\typeout{#1: \f at encoding/\f at family/\f at series/\f at shape}}
+\makeatother
+
+
+\renewcommand\sfdefault{qpl}    % Palatino (with "b")
+\renewcommand\ttdefault{lmtt}   
+
+
+\begin{document}
+
+\START
+
+\makeatletter
+ \show\bfseries at rm
+ \show\bfseries at sf
+ \show\bfseries at tt
+\makeatother
+
+             \showfont{start}
+
+\bfseries    \showfont{bfseries}
+
+\OMIT
+\sffamily
+\TIMO
+             \showfont{sffamily}
+
+\mdseries    \showfont{mdseries}
+
+\OMIT
+\ttfamily
+\TIMO
+             \showfont{ttfamily}
+
+\bfseries    \showfont{bfseries}
+
+\rmfamily    \showfont{rmfamily}
+
+\END
diff --git a/base/testfiles-search/tlb-nfssaxes-006.tlg b/base/testfiles-search/tlb-nfssaxes-006.tlg
new file mode 100644
index 00000000..7a06d086
--- /dev/null
+++ b/base/testfiles-search/tlb-nfssaxes-006.tlg
@@ -0,0 +1,20 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+> \bfseries at rm=macro:
+->bx.
+l. ... \show\bfseries at rm
+> \bfseries at sf=macro:
+->b.
+l. ... \show\bfseries at sf
+> \bfseries at tt=macro:
+->bx.
+l. ... \show\bfseries at tt
+start: OT1/cmr/m/n
+bfseries: OT1/cmr/bx/n
+sffamily: OT1/qpl/b/n
+mdseries: OT1/qpl/m/n
+ttfamily: OT1/lmtt/m/n
+LaTeX Font Info:    Font shape `OT1/lmtt/bx/n' in size <10> not available
+(Font)              Font shape `OT1/lmtt/b/n' tried instead on input line ...
+bfseries: OT1/lmtt/bx/n
+rmfamily: OT1/cmr/bx/n





More information about the latex3-commits mailing list