[latex3-commits] [git/LaTeX3-latex3-latex2e] nfssaxes: support \DeclareFontFamilySubstitution (f4cb3b3c)

Frank Mittelbach frank.mittelbach at latex-project.org
Tue Nov 26 19:00:29 CET 2019


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

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

commit f4cb3b3c0ed057ea7beb08d9d7e7971f35105725
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Tue Nov 26 19:00:29 2019 +0100

    support \DeclareFontFamilySubstitution


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

f4cb3b3c0ed057ea7beb08d9d7e7971f35105725
 base/nfssaxes.tex                          | 87 ++++++++++++++++++++++++++++++
 base/testfiles-search/tlb-nfssaxes-008.lvt | 32 +++++++++++
 base/testfiles-search/tlb-nfssaxes-008.tlg |  9 ++++
 3 files changed, 128 insertions(+)

diff --git a/base/nfssaxes.tex b/base/nfssaxes.tex
index e1178104..f49a0af0 100644
--- a/base/nfssaxes.tex
+++ b/base/nfssaxes.tex
@@ -686,7 +686,14 @@
 %    \end{macrocode}
 %  \end{macro}
 
+
+%  \begin{macro}{\maybe at load@fontshape}
+%    
+%    \begin{macrocode}
 \def\maybe at load@fontshape{\begingroup\try at load@fontshape\endgroup}
+%    \end{macrocode}
+%  \end{macro}
+
 
 %  \begin{macro}{\set at target@series}
 %  \begin{macro}{\series at drop@one at m}
@@ -1752,4 +1759,84 @@
 
 
 
+
+%  \begin{macro}{\DeclareFontFamilySubstitution}
+%    The idea for this macro is stolen from the \texttt{substitutefont}
+%    package, with some modifications and a new name.
+%
+%    Its purpose is to provide characters in a special encoding tht
+%    are not available in the current font family to be taken from a
+%    different family that is visually compatible (or not if you
+%    choose badly). For example, you can match the GFS Didot Greek
+%    characters with \TeX{} Gyre Pagella (Palatino) by specifying
+%\begin{verbatim}
+% \DeclareFontFamilySubstitution{LGR}{qpl}{udidot}
+%\end{verbatim}
+%    This way if you ask for the \texttt{LGR} encoding in for the
+%    \textt{qpl} family you get the characters from the
+%    \texttt{udidot} family substituted.
+%
+%    we need to ensure that the macro is defined with
+%    \cs{nfss at catcodes} in force (not quite sure why at the moment to
+%    be honest).
+%    \begin{macrocode}
+\begingroup
+\nfss at catcodes
+\gdef\DeclareFontFamilySubstitution#1#2#3{%
+%    \end{macrocode}
+%    We only provide a set of silent substitutions. The package also
+%    (re)declared the family, but this is incorrect in my eyes and it
+%    is better to handle that differently.
+%
+%    Of course the family \verb=#1#2.fd= may still needs loading at
+%    this point and so we arange for this.
+%    \begin{macrocode}
+% \DeclareFontFamily{#1}{#2}{}%
+ \begingroup
+   \fontencoding{#1}\fontfamily{#2}\try at load@fontshape
+                    \fontfamily{#3}\try at load@fontshape
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+   \DeclareFontShape{#1}{#2}{m}{it}{<->ssub * #3/m/it}{}%
+   \DeclareFontShape{#1}{#2}{m}{n}{<->ssub * #3/m/n}{}%
+   \DeclareFontShape{#1}{#2}{m}{sc}{<->ssub * #3/m/sc}{}%
+   \DeclareFontShape{#1}{#2}{m}{sl}{<->ssub * #3/m/sl}{}%
+%    \end{macrocode}
+%    These days a few more shapes might be around, so we declare those
+%    too. If they don't exist then after the first substitution normal
+%    fallbacks will happen.
+%    \begin{macrocode}
+   \DeclareFontShape{#1}{#2}{m}{sw}{<->ssub * #3/m/sw}{}%
+   \DeclareFontShape{#1}{#2}{m}{scit}{<->ssub * #3/m/scit}{}%
+   \DeclareFontShape{#1}{#2}{m}{scsl}{<->ssub * #3/m/scsl}{}%
+%    \end{macrocode}
+%    Same game with \texttt{b} and \texttt{bx}, for other weights you
+%    are on your own:
+%    \begin{macrocode}
+   \DeclareFontShape{#1}{#2}{b}{it}{<->ssub * #3/b/it}{}%
+   \DeclareFontShape{#1}{#2}{b}{n}{<->ssub * #3/b/n}{}%
+   \DeclareFontShape{#1}{#2}{b}{scit}{<->ssub * #3/b/scit}{}%
+   \DeclareFontShape{#1}{#2}{b}{scsl}{<->ssub * #3/b/scsl}{}%
+   \DeclareFontShape{#1}{#2}{b}{sc}{<->ssub * #3/b/sc}{}%
+   \DeclareFontShape{#1}{#2}{b}{sl}{<->ssub * #3/b/sl}{}%
+   \DeclareFontShape{#1}{#2}{b}{sw}{<->ssub * #3/b/sw}{}%
+   \DeclareFontShape{#1}{#2}{bx}{it}{<->ssub * #3/bx/it}{}%
+   \DeclareFontShape{#1}{#2}{bx}{n}{<->ssub * #3/bx/n}{}%
+   \DeclareFontShape{#1}{#2}{bx}{scit}{<->ssub * #3/bx/scit}{}%
+   \DeclareFontShape{#1}{#2}{bx}{scsl}{<->ssub * #3/bx/scsl}{}%
+   \DeclareFontShape{#1}{#2}{bx}{sc}{<->ssub * #3/bx/sc}{}%
+   \DeclareFontShape{#1}{#2}{bx}{sl}{<->ssub * #3/bx/sl}{}%
+   \DeclareFontShape{#1}{#2}{bx}{sw}{<->ssub * #3/bx/sw}{}%
+ \endgroup
+}
+\endgroup
+%    \end{macrocode}
+%  \end{macro}
+
+
+
+
+
+
 % ^^A Possible issue with tudscr.cls -- needs checking
diff --git a/base/testfiles-search/tlb-nfssaxes-008.lvt b/base/testfiles-search/tlb-nfssaxes-008.lvt
new file mode 100644
index 00000000..346f4311
--- /dev/null
+++ b/base/testfiles-search/tlb-nfssaxes-008.lvt
@@ -0,0 +1,32 @@
+\documentclass{article}
+
+\input{test2e}
+
+
+
+\makeatletter
+\def\showfont#1{\typeout{#1: \f at encoding/\f at family/\f at series/\f at shape}}
+\makeatother
+
+\usepackage[LGR,T1]{fontenc}
+
+\renewcommand\rmdefault{qpl}  % not yet loaded
+
+\DeclareFontFamilySubstitution{LGR}{qpl}{udidot}
+
+\begin{document}
+
+\START
+
+\showfont{start}
+
+\fontencoding{LGR}\selectfont
+
+\showfont{LGR}
+
+
+\fontencoding{T1}\selectfont
+
+\showfont{T1}
+
+\END
diff --git a/base/testfiles-search/tlb-nfssaxes-008.tlg b/base/testfiles-search/tlb-nfssaxes-008.tlg
new file mode 100644
index 00000000..68369e3c
--- /dev/null
+++ b/base/testfiles-search/tlb-nfssaxes-008.tlg
@@ -0,0 +1,9 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+start: T1/qpl/m/n
+LaTeX Font Info:    Font shape `LGR/qpl/m/n' in size <10> not available
+(Font)              Font shape `LGR/udidot/m/n' tried instead on input line ....
+LaTeX Font Info:    Font shape `LGR/udidot/m/n' will be
+(Font)              scaled to size 10.39993pt on input line ....
+LGR: LGR/qpl/m/n
+T1: T1/qpl/m/n





More information about the latex3-commits mailing list