Skip to content

Commit

Permalink
Hotfix declareencodingsubset (#1555)
Browse files Browse the repository at this point in the history
* hotfix to allow \DeclareEncodingsubset in .fd files

* working through expected differences ... part 1

* ... and part 2

* ... and part 3

* Update base/ltfssbas.dtx

Co-authored-by: Joseph Wright <[email protected]>

---------

Co-authored-by: Joseph Wright <[email protected]>
  • Loading branch information
FrankMittelbach and josephwright authored Nov 22, 2024
1 parent 07be1cc commit 706799b
Show file tree
Hide file tree
Showing 17 changed files with 253 additions and 172 deletions.
24 changes: 23 additions & 1 deletion base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@ not part of the distribution.
All changes above are only part of the development branch for the next release.
================================================================================

#########################
# 2024-11-01 PL1 Release
#########################

2024-11-19 Frank Mittelbach <[email protected]>

* lttextcomp.dtx:
Allow using \DeclareEncodingSubset in the document body so that it
can be placed into .fd file (gh/1518)

* cmfonts.fdd:
Add \DeclareEncodingSubset declarations in the .fd files for
ts1cmr, ts1cmss, ts1cmtt, and ts1cmvtt (gh/1518)

* ltfssbas.dtx:
Moved \DeclareEncodingSubset and \CheckEncodingSubset from
lttextcomp.dtx into this file

* fontdef.dtx:
Preload ts1cmr.fd, ts1cmss.fd, and ts1cmtt in the kernel
Drop unnessary \DeclareFontSubstitution declarations

#########################
# 2024-11-01 Release
#########################
Expand Down Expand Up @@ -42,7 +64,7 @@ All changes above are only part of the development branch for the next release.

2024-10-22 Ulrike Fischer <[email protected]>
* ltshipout.dtx: correct documentation (gh/1470).

2024-10-21 Matthew Bertucci <[email protected]>
* lthooks.dtx
Define \IfHookEmptyT, \IfHookEmptyF
Expand Down
21 changes: 20 additions & 1 deletion base/cmfonts.fdd
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
%<*driver, >
\ProvidesFile{cmfonts.drv}
%</driver, >
[2023/04/13 v2.5m Standard LaTeX font definitions]
[2024/11/19 v2.5n Standard LaTeX font definitions]
%
%<*driver>
\documentclass{ltxdoc}
Expand Down Expand Up @@ -751,6 +751,11 @@
\EC@family{TS1}{cmr}{bx}{sl}{tcbl}
%<!ec>\EC@family{TS1}{cmr}{m}{ui}{tcu}
%<ec>\EC@family{TS1}{cmr}{m}{ui}{tcui}
% \end{macrocode}
%
% \changes{v2.5n}{2024/11/19}{Add \cs{DeclareEncodingSubset} declaration}
% \begin{macrocode}
\DeclareEncodingSubset{TS1}{cmr}{0}
%</TS1cmr>
%<*TS1cmss>
\DeclareFontFamily{TS1}{cmss}{\hyphenchar\font\m@ne}
Expand All @@ -760,12 +765,22 @@
\EC@family{TS1}{cmss}{bx}{n}{tcsx}
\EC@family{TS1}{cmss}{bx}{it}{tcso}
\EC@family{TS1}{cmss}{bx}{sl}{tcso}
% \end{macrocode}
%
% \changes{v2.5n}{2024/11/19}{Add \cs{DeclareEncodingSubset} declaration}
% \begin{macrocode}
\DeclareEncodingSubset{TS1}{cmss}{0}
%</TS1cmss>
%<*TS1cmtt>
\DeclareFontFamily{TS1}{cmtt}{\hyphenchar\font\m@ne}
\EC@ttfamily{TS1}{cmtt}{m}{n}{tctt}
\EC@ttfamily{TS1}{cmtt}{m}{sl}{tcst}
\EC@ttfamily{TS1}{cmtt}{m}{it}{tcit}
% \end{macrocode}
%
% \changes{v2.5n}{2024/11/19}{Add \cs{DeclareEncodingSubset} declaration}
% \begin{macrocode}
\DeclareEncodingSubset{TS1}{cmtt}{0}
%</TS1cmtt>
% \end{macrocode}
% Again the italic shape is only available with release 1.3.
Expand All @@ -774,6 +789,10 @@
\DeclareFontFamily{TS1}{cmvtt}{}
\EC@ttfamily{TS1}{cmvtt}{m}{n}{tcvt}
\EC@ttfamily{TS1}{cmvtt}{m}{it}{tcvi}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareEncodingSubset{TS1}{cmvtt}{0}
%</TS1cmvtt>
% \end{macrocode}
%
Expand Down
48 changes: 34 additions & 14 deletions base/fontdef.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
%<driver, >\ProvidesFile{fontdef.drv}
% \fi
% \ProvidesFile{fontdef.dtx}
[2024/09/03 v3.0k LaTeX Kernel
[2024/11/19 v3.0l LaTeX Kernel
% \iffalse
%<text, > (Text font setup)
%<math, > (Math font setup)
Expand Down Expand Up @@ -260,7 +260,7 @@
\input {omsenc.def}
% \end{macrocode}
% Documents containing a lot of accented characters should really
% be using T1 fonts. We therefore load this last so that T1 encoding
% be using T1 fonts. We therefore load this after OT1 so that T1 encoding
% specific commands are executed as fast as possible (encoding
% files are no longer reloaded in \texttt{fontenc}.
% \changes{v3.0f}{2020/01/25}{Load t1enc.def last (gh/255)}
Expand All @@ -270,7 +270,7 @@
% \end{macrocode}
%
% \begin{macrocode}
\input{ts1enc.def}
\input {ts1enc.def}
% \end{macrocode}
%
%
Expand Down Expand Up @@ -349,7 +349,15 @@
\DeclareFontEncodingDefaults{}{}
% \end{macrocode}
%
% Then we define the default substitution for every encoding.
% The default font substitution for an encoding is defined in the
% corresponding \texttt{...enc.def} file so for \texttt{OT1},
% \texttt{T1}, and \texttt{TS1} this is already defined.
% \begin{macrocode}
%\DeclareFontSubstitution{T1}{cmr}{m}{n}
%\DeclareFontSubstitution{OT1}{cmr}{m}{n}
%\DeclareFontSubstitution{TS1}{cmr}{m}{n}
% \end{macrocode}
%
% This release of \LaTeXe{} assumes that the ec fonts are
% available. It is possible to change this to point to some other
% font family (e.g., Times with the appropriate encoding if it is
Expand All @@ -358,10 +366,6 @@
% sites. The substitution defaults can all be changed without
% losing portability as long as there are font shape definitions
% for the selected substitutions.
% \begin{macrocode}
\DeclareFontSubstitution{T1}{cmr}{m}{n}
\DeclareFontSubstitution{OT1}{cmr}{m}{n}
% \end{macrocode}
%
% For every encoding declaration, \LaTeXe{} will try to verify that
% the given substitution information makes sense, i.e.~that it is
Expand Down Expand Up @@ -391,6 +395,12 @@
\nfss@catcodes
\input {t1cmr.fd}
\input {ot1cmr.fd}
% \end{macrocode}
%
% \changes{v3.0l}{2024/11/19}{Preload the TS1 \texttt{ts1cmr.fd} file
% in all engines}
% \begin{macrocode}
\input {ts1cmr.fd}
\endgroup
% \end{macrocode}
%
Expand All @@ -411,19 +421,29 @@
\input {t1cmtt.fd}
\input {ot1cmss.fd}
\input {ot1cmtt.fd}
% \end{macrocode}
%
% \changes{v3.0l}{2024/11/19}{Preload the TS1 \texttt{.fd} file}
% \begin{macrocode}
\input {ts1cmss.fd}
\input {ts1cmtt.fd}
\endgroup
% \end{macrocode}
%
% \changes{v3.0j}{2024/06/24}{load ts1 cmr fd file in Unicode engines}
% Even though Unicode engines default to |lm| load |ts1cmr|
% as this may be used for fallback for TS1 encoding.
%
% We now load it in all engines above, so the next lines are no longer
% necessary. We keep them here if we stop loading other fd files in
% Unicode engines.
% \begin{macrocode}
\ifx\Umathcode\@undefined\else
\begingroup
\nfss@catcodes
\input {ts1cmr.fd}
\endgroup
\fi
%\ifx\Umathcode\@undefined\else
%\begingroup
%\nfss@catcodes
%\input {ts1cmr.fd}
%\endgroup
%\fi
% \end{macrocode}
%
% Even with all the precautions it is still possible that NFSS will
Expand Down
9 changes: 8 additions & 1 deletion base/ltfssaxes.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
%
%
\ProvidesFile{ltfssaxes.dtx}
[2024/02/08 v1.0i LaTeX Kernel (NFSS Axes handing)]
[2024/11/19 v1.0j LaTeX Kernel (NFSS Axes handing)]
% \iffalse
\documentclass{ltxdoc}
\begin{document}
Expand Down Expand Up @@ -70,10 +70,17 @@
%
% \changes{v1.0h}{2020/12/04}{Reorganized the rollback data}
%
% \begin{macrocode}
%<2ekernel>\message{NFSS axes,}
% \end{macrocode}
%
% Everything in the this file got introduced 2020/02/02, so we use large rollback
% chunks, only interrupted if necessary.
% \begin{macrocode}
%<*2ekernel|latexrelease>
% \end{macrocode}
%
% \begin{macrocode}
%<latexrelease>\IncludeInRelease{2020/02/02}%
%<latexrelease> {\DeclareFontSeriesChangeRule}{Series change rules}%
% \end{macrocode}
Expand Down
137 changes: 135 additions & 2 deletions base/ltfssbas.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
%
%
\ProvidesFile{ltfssbas.dtx}
[2024/06/17 v3.2m LaTeX Kernel (NFSS Basic Macros)]
[2024/11/19 v3.2n LaTeX Kernel (NFSS Basic Macros)]
% \iffalse
\documentclass{ltxdoc}
\begin{document}
Expand Down Expand Up @@ -157,12 +157,16 @@
% We define a number
% of macros that will be used later.
%
% \begin{macrocode}
%<*2ekernel>
\message{NFSS base,}
% \end{macrocode}
%
%
% \begin{macro}{\@nomath}
% |\@nomath| is used by most macros that will have no effect
% in math mode. It issues a warning message.
% \begin{macrocode}
%<*2ekernel>
\def\@nomath#1{\relax\ifmmode
\@font@warning{Command \noexpand#1invalid in math mode}\fi}
% \end{macrocode}
Expand Down Expand Up @@ -593,6 +597,135 @@
% \end{macro}
%
%
%
%
% \begin{macro}{\DeclareEncodingSubset}
%
% The declaration takes 3 mandatory arguments: an \emph{encoding}
% for which a subsetting is wanted (currently always \texttt{TS1},
% and most likely forever), the \emph{font family} for which we
% declare the subset and finally the \emph{subset} number, with a value between
% \texttt{0} (all of the encoding is supported) and \texttt{9} (many
% glyphs are missing).
%
% For \texttt{TS1} the numbers have been chosen in a way that most
% fonts can be fairly correctly categorized, but the default
% settings are always conservative, that is they may claim that
% fewer glyphs are supported than there actually are.
%
% As these days many font families are set up to end in \texttt{-LF}
% (lining figures), \texttt{-OsF} (oldstyle figures), etc.\ the
% declaration supports a shortcut: if the \emph{font family} name
% ends in \texttt{-*} then the star gets replaced by these common
% ending, e.g.,
%\begin{verbatim}
% \DeclareEncodingSubset{TS1}{Alegreya-*}{2}
%\end{verbatim}
% is the same as writing
%\begin{verbatim}
% \DeclareEncodingSubset{TS1}{Alegreya-LF}{2}
% \DeclareEncodingSubset{TS1}{Alegreya-OsF}{2}
% \DeclareEncodingSubset{TS1}{Alegreya-TLF}{2}
% \DeclareEncodingSubset{TS1}{Alegreya-TOsF}{2}
%\end{verbatim}
% If only some are needed then one can define them individually but
% in many cases all four are wanted, hence the shortcut.
%
%
% The coding of the declaration has no error checking as it is
% mostly for internal use.
% \begin{macrocode}
\def\DeclareEncodingSubset#1#2{%
\DeclareEncodingSubset@aux{#1}#2*\DeclareEncodingSubset@aux
}
% \end{macrocode}
%
% \begin{macrocode}
\def\DeclareEncodingSubset@aux#1#2*#3\DeclareEncodingSubset@aux#4{%
% \end{macrocode}
% if \verb=#3= is empty then there was no star, otherwise we
% define all four variants.
% \begin{macrocode}
\expandafter\ifx\expandafter X\detokenize{#3}X%
\@DeclareEncodingSubset{#1}{#2}{#4}%
\else
\@DeclareEncodingSubset{#1}{#2LF}{#4}%
\@DeclareEncodingSubset{#1}{#2TLF}{#4}%
\@DeclareEncodingSubset{#1}{#2OsF}{#4}%
\@DeclareEncodingSubset{#1}{#2TOsF}{#4}%
\fi
}
% \end{macrocode}
%
% The subset info is stored in a command with the name
% \texttt{\bslash}\emph{family}\texttt{:}\emph{subset} so if that
% already exists we change otherwise declare a subset.
% \begin{macrocode}
\def\@DeclareEncodingSubset#1#2#3{%
\@ifundefined{#1:#2}%
{\@font@info{Setting #2 sub-encoding to #1/#3}}%
{\@font@info{Changing #2 sub-encoding to #1/#3}}%
% \end{macrocode}
% This declaration should be usable in \texttt{.fd} files and
% therefore has to make its definition globally, because such files
% can get loaded in random places.
% \changes{v1.0g}{2022/08/07}{Make global declaration (gh/905)}
% \begin{macrocode}
\global\@namedef{#1:#2}{#3}}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\CheckEncodingSubset}
% The command |\CheckEncodingSubset| will check if the current font
% family has the right encoding subset to typeset a certain
% command. It takes five arguments as follows:
% first argument is either |\UseTextSymbol|, |\UseTextAccent|
% depending on whether or not the symbol is a text symbol or a text
% accent.

% The second argument is the encoding from which this symbol should
% be fetched.
%
% The third argument is either a fake accessor command or an error
% message. the code in that argument (if ever executed) receives
% two arguments: |#2| and |#5| of |\CheckEncodingSubset|.
%
% Argument four is the subset encoding id to test against: if this
% value is higher than the subset id of the current font family
% then we typeset the symbol, i.e., execute |#1{#2}#5| otherwise
% it runs |#3#5|, e.g., to produce an error message or fake the
% glyph somehow.
%
% Argument five is the symbol or accent command that is being
% checked.
%
% For usage examples see definitions in \texttt{lttextcomp.dtx}.
%
% \begin{macrocode}
\def\CheckEncodingSubset#1#2#3#4#5{%
\ifnum #4>%
\expandafter\ifx\csname #2:\f@family\endcsname\relax
0\csname #2:?\endcsname
\else
\csname #2:\f@family\endcsname
\fi
\relax
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{#1{#2}}{#3}%
#5%
}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\DeclarePreloadSizes}
% \begin{macrocode}
\def\DeclarePreloadSizes#1#2#3#4#5{%
Expand Down
Loading

0 comments on commit 706799b

Please sign in to comment.