[latex3-commits] [git/LaTeX3-latex3-latex2e] nfssaxes: implementing mweights.sty (more or less) (9c9fc68b)

Frank Mittelbach frank.mittelbach at latex-project.org
Mon Oct 7 23:49:30 CEST 2019


Repository : https://github.com/latex3/latex2e
On branch  : nfssaxes
Link       : https://github.com/latex3/latex2e/commit/9c9fc68b48274f2cb2ab4570c36de746041fec26

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

commit 9c9fc68b48274f2cb2ab4570c36de746041fec26
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Mon Oct 7 23:49:30 2019 +0200

    implementing mweights.sty (more or less)


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

9c9fc68b48274f2cb2ab4570c36de746041fec26
 base/nfssaxes.tex          | 223 ++++++++++++++++++++++++++++++++++++++++++++-
 base/testfiles/tlb0130.lvt |   2 +-
 2 files changed, 223 insertions(+), 2 deletions(-)

diff --git a/base/nfssaxes.tex b/base/nfssaxes.tex
index 380840e5..03c4f7de 100644
--- a/base/nfssaxes.tex
+++ b/base/nfssaxes.tex
@@ -359,7 +359,7 @@
 
 
 % \section{Supporting nested emphasis}
-
+%
 %    By default \LaTeXe{} supports two levels of nested emphasis: if
 %    the current font has an upright shape then it switches to
 %    \cs{itshape} otherwise to \cs{eminnershape} (which defaults to
@@ -521,3 +521,224 @@
 
 
 
+% \section{Custom series settings for main document families}
+%
+%    One problem with the \NFSS{} approach of handling the series axis
+%    turned out to be that (especially with respect to ``boldness'')
+%    different font families implemented different strategies. For
+%    example, with Computer Modern fonts you normally only have
+%    \texttt{bx} whereas most PostScript fonts offered only \texttt{b}
+%    but not \texttt{bx}. As a result \LaTeX's standard setting for
+%    \cs{bfdefault} didn't work with such fonts, but if it got changed
+%    to produce \texttt{b}, then that didn't work with Computer Modern
+%    if the fonts got combined (e.g., using Computer Modern Typewriter
+%    with such fonts).
+%
+%    The solution back then was to provide substitution rules in the
+%    font \textt{.fd} such that if a \texttt{bx} series got requested
+%    the \texttt{b} series got used. While this works in that
+%    particular case, it isn't a very
+%    general solution. For example, if you happen to have a font family that
+%    has several weights you may want to typeset  the whole document
+%    in a somewhat lighter or darker font but if you then modify
+%    \cs{mddefault} to allow for this, then of course your change only
+%    works with that particular family but not with the typewriter
+%    or sans serif family you also want to use.
+%
+%    A better solution was provided by the \texttt{mweights} package by
+%    Bob Tennent that offers defaults on the level of the three main
+%    font families in the document: for ``rm'', ``sf'' and ``tt'' so
+%    that font packages could define defaults for the sans serif
+%    document font by providing \cs{bfseries at sf} which then was used
+%    when \cs{bfseries} got executed and the current family was the
+%    \cs{sffamily}.
+%
+%  \DescribeMacro\DeclareFontSeriesDefault
+%    We now support this concept directly from within \LaTeX{} and for
+%    use in font packages (or the document preamble) we offer
+%    \cs{DeclareSeriesDefault}. This declaration takes three
+%    arguments:
+%   \begin{description}
+%   \item[document family interface:] Can either be \texttt{rm},
+%    \texttt{sf} or \texttt{tt}.
+%   \item[document series interface:] Can be \textt{md} or
+%    \texttt{bf}.
+%   \item[series value:] This is the value that is going to be used
+%    with the combination is requested.
+%  \end{description}
+%
+%    For example, \verb=DeclareFontSeriesDefault{rm}{bf}{sb}= would
+%    use \texttt{sb} (semi-bold) when \cs{rmfamily} \cs{bfseries} is
+%    asked for.
+
+%  \begin{macro}{\DeclareFontSeriesDefault}
+%    
+%    \begin{macrocode}
+\def\DeclareFontSeriesDefault#1#2#3{%
+  \ifcsname #2series@#1\endcsname          % supported are
+                                           % \[md/bf]series@[rm/sf/tt]
+    \expandafter\edef
+       \csname #2series@#1\endcsname{#3}%                     
+  \else
+     \@latex at error{Wrong syntax for \string\DeclareFontSeriesDefault}%
+        {First argument must be 'rm', 'sf', or 'tt'. \MessageBreak
+         Second argument must be 'md'  or 'bf'.}
+  \fi
+}
+%    \end{macrocode}
+%  \end{macro}
+
+
+
+
+
+\def\mweights at init{%
+  \edef\rmdef at ult{\rmdefault}%
+  \edef\sfdef at ult{\sfdefault}%
+  \edef\ttdef at ult{\ttdefault}%
+  \edef\bfdef at ult{\bfdefault}%
+  \edef\mddef at ult{\mddefault}%
+  \edef\famdef at ult{\familydefault}%
+}
+
+
+%    We initialize things at the end of the format. Later on they may
+%    get overwritten in the preamble or a package
+%    \cs{DeclareFontSeriesDefault}.
+
+\edef\mdseries at rm{\mddefault}
+\edef\bfseries at rm{\bfdefault}
+\edef\mdseries at sf{\mddefault}
+\edef\bfseries at sf{\bfdefault}
+\edef\mdseries at tt{\mddefault}
+\edef\bfseries at tt{\bfdefault}
+
+\AtBeginDocument{%
+  \mweights at init
+%    \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
+  \fi\fi\fi
+}%
+
+
+\DeclareRobustCommand\bfseries{%
+  \mweights at init
+  \not at math@alphabet\bfseries\mathbf
+  \fontseries{%
+    \ifx\f at family\rmdef at ult
+      \bfseries at rm
+    \else
+      \ifx\f at family\sfdef at ult
+        \bfseries at sf
+      \else
+        \ifx\f at family\ttdef at ult
+          \bfseries at tt
+        \else
+          \bfdefault
+        \fi
+      \fi
+    \fi
+  }%
+  \selectfont
+}
+
+
+\DeclareRobustCommand\mdseries{%
+  \mweights at init
+  \not at math@alphabet\mdseries\relax
+  \fontseries{%
+    \ifx\f at family\rmdef at ult
+      \mdseries at rm
+    \else
+      \ifx\f at family\sfdef at ult
+        \mdseries at sf
+      \else
+        \ifx\f at family\ttdef at ult
+          \mdseries at tt
+        \else
+          \mddefault
+        \fi
+      \fi
+    \fi
+  }%
+  \selectfont
+}
+
+
+\DeclareRobustCommand\rmfamily{%
+  \mweights at init
+  \not at math@alphabet\rmfamily\mathrm
+  % change the current series before changing the family
+  \ifx\f at family\sfdef at ult
+       \ifx\f at series\mdseries at sf       \fontseries\mdseries at rm
+       \else\ifx\f at series\bfseries at sf  \fontseries\bfseries at rm
+       \else\ifx\f at series\mddef at ult    \fontseries\mdseries at rm
+       \else\ifx\f at series\bfdef at ult    \fontseries\bfseries at rm
+       \fi\fi\fi\fi
+%
+  \else\ifx\f at family\ttdef at ult
+       \ifx\f at series\mdseries at tt       \fontseries\mdseries at rm
+       \else\ifx\f at series\bfseries at tt  \fontseries\bfseries at rm
+       \else\ifx\f at series\mddef at ult    \fontseries\mdseries at rm
+       \else\ifx\f at series\bfdef at ult    \fontseries\bfseries at rm
+       \fi\fi\fi\fi
+%
+  \fi\fi
+  \fontfamily\rmdefault\selectfont}
+
+
+\DeclareRobustCommand\sffamily{%
+  \mweights at init
+  \not at math@alphabet\sffamily\mathsf
+  % change the current series before changing the family
+  \ifx\f at family\rmdef at ult
+       \ifx\f at series\mdseries at rm       \fontseries\mdseries at sf
+       \else\ifx\f at series\bfseries at rm  \fontseries\bfseries at sf
+       \else\ifx\f at series\mddef at ult    \fontseries\mdseries at sf
+       \else\ifx\f at series\bfdef at ult    \fontseries\bfseries at sf
+       \fi\fi\fi\fi
+%
+  \else\ifx\f at family\ttdef at ult
+       \ifx\f at series\mdseries at tt       \fontseries\mdseries at sf
+       \else\ifx\f at series\bfseries at tt  \fontseries\bfseries at sf
+       \else\ifx\f at series\mddef at ult    \fontseries\mdseries at sf
+       \else\ifx\f at series\bfdef at ult    \fontseries\bfseries at sf
+       \fi\fi\fi\fi
+%
+  \fi\fi
+  \fontfamily\sfdefault\selectfont}
+
+
+\DeclareRobustCommand\ttfamily{%
+  \mweights at init
+  \not at math@alphabet\ttfamily\mathtt
+  % change the current series before changing the family
+  \ifx\f at family\rmdef at ult
+       \ifx\f at series\mdseries at rm       \fontseries\mdseries at tt
+       \else\ifx\f at series\bfseries at rm  \fontseries\bfseries at tt
+       \else\ifx\f at series\mddef at ult    \fontseries\mdseries at tt
+       \else\ifx\f at series\bfdef at ult    \fontseries\bfseries at tt
+       \fi\fi\fi\fi
+%
+  \else\ifx\f at family\rmdef at ult
+       \ifx\f at series\mdseries at rm       \fontseries\mdseries at tt
+       \else\ifx\f at series\bfseries at rm  \fontseries\bfseries at tt
+       \else\ifx\f at series\mddef at ult    \fontseries\mdseries at tt
+       \else\ifx\f at series\bfdef at ult    \fontseries\bfseries at tt
+       \fi\fi\fi\fi
+%
+  \fi\fi
+  \fontfamily\ttdefault\selectfont}
+
+
+
+% pretend that mweights already got loaded \ldots
+
+\expandafter\let\csname ver at mweights.sty\endcsname\fmtversion
+
+
+% ^^A Possible issue with tudscr.cls -- needs checking
diff --git a/base/testfiles/tlb0130.lvt b/base/testfiles/tlb0130.lvt
index 54c52da8..76ca3ce4 100644
--- a/base/testfiles/tlb0130.lvt
+++ b/base/testfiles/tlb0130.lvt
@@ -47,13 +47,13 @@
 \setlength{\textheight}{22cm}
 \pagestyle{empty}
 
+
 \OMIT
 
 \begin{document}
 
 \TIMO
 
-\makeatletter
 
 $\psi_{n'}^{k}$
 





More information about the latex3-commits mailing list