[latexrefman] it switches from one encoding to another with the @code{\selectfont} or @code{\fontencoding} command

Vincent Belaïche vincent.belaiche at gmail.com
Sat Sep 18 19:43:32 CEST 2021


Hello,
If I look at the defintion of \fontencoding it contains something like

  \ifx \cf at encoding \f at encoding \let \enc at update \relax \else \let
\enc at update \@@enc at update \fi

which means that if the current encoding is already that asked for by
the considered \fontencoding command, then \enc at update is let-defined
to do nothing, and otherwise \enc at update is let-defined to do the tame
as \@@enc at update, ie do the real switch.

Then in \selectfont, the last thing in the definition is a call to \enc at update.

I other word, \fontencoding just configures what the next font
encoding switch would be if any, without doing any switch per se,
while \selectfont applies the font switch if any as configured by the
lateest \fontencoding. So \fontencoding is just like passing an
argument to the next \selectfont, it does not the real job.

This confirms that the wording is not right, and that we need to
replace « or » by « and », as you need both commands for anything
observable to occur (otherwise, yes something is occurring, but it
does not have any observable effect).

This analysis was confirmed by the small experiment that was attached
to one of my previous email with trying to set what <|> is typeset to,
either in OT1 or in T1.

  V.

Le mer. 15 sept. 2021 à 15:42, Hefferon, Jim S. <jhefferon at smcvt.edu> a écrit :
>
> My copy of the Companion says (edition 1, p 203) "The second argument contains any code (such as definitions) to be executed each time NFSS switches from one encoding to another using the \fontencoding command."  On p 188, it says "Font selection in NFSS is done in two steps * Some or all attributes are changed using the low-level commands \fontencoding ... * The font corresponding to this new setting is selected by calling the \selectfont command."
>
> So the wording seems right to me, but if these is any change it seems to me to involve omitting the mention of \selectfont.
>
> Jim
>
> ...........................................................
> Why are they not in jail?
>
> ________________________________________
> From: Vincent Belaïche <vincent.belaiche at gmail.com>
> Sent: Wednesday, September 15, 2021 8:57
> To: Karl Berry
> Cc: Hefferon, Jim S.; latexrefman
> Subject: Re: [latexrefman] it switches from one encoding to another with the @code{\selectfont} or @code{\fontencoding} command
>
> ⚠ External Sender ⚠
>
>
> Any feedback (I will replace « or » by « and » in my next commit to
> [en], last notice before doing that by end of this week, ok we can
> still undo if I am wrong) ?
>
>   V.
>
> Le lun. 6 sept. 2021 à 11:41, Vincent Belaïche
> <vincent.belaiche at gmail.com> a écrit :
> >
> > Dear Karl,
> > I did some experiment (attached). If you pass options to fontenc in
> > the order OT1, T1, the two last rows will output <|> instead of ¡—¿.
> > This shows that without \selectfont the encoding is not activated.
> >
> > Le dim. 5 sept. 2021 à 00:16, Karl Berry <karl at freefriends.org> a écrit :
> > >
> > >     My understanding is the \fontencoding does no immediate switching as
> > >     such,
> > >
> > > Yes it does. Maybe not at the user level, I'm not sure what the
> > > visible result is, but in the code the switch is made in \fontencoding.
> > >
> > >     it just sets the encoding to which the next \selectfont will
> > >     switch. So ``or'' should be replaced by ``and''.
> > >
> > > No it shouldn't.
> > >
> > > When I look at the actual definition of \fontencoding (in ltfssbas.dtx),
> > > the "text-setting" commands from \DeclareFontEncoding are executed:
> > >
> > > \DeclareRobustCommand\fontencoding[1]{%
> > > ..
> > >   \csname T@\f at encoding\endcsname
> > > ..
> > > }
> > >
> > > The \csname T@\f at encoding\endcsname cs is where the "text-setting"
> > > commands were saved.
> > >
> > > At a glance, I do not see them being executed as being part of
> > > \selectfont.
> > >
> > > So I suggest doing some experiments to find out the actual facts.
> > > Failing that, I suggest leaving it alone. -k



More information about the latexrefman mailing list.