Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Series changes (a version of #1396) #1583

Merged
merged 33 commits into from
Dec 17, 2024
Merged

Series changes (a version of #1396) #1583

merged 33 commits into from
Dec 17, 2024

Conversation

FrankMittelbach
Copy link
Member

@FrankMittelbach FrankMittelbach commented Dec 13, 2024

Internal housekeeping

Status of pull request

  • Ready to merge

Checklist of required changes before merge will be approved

  • [n/a] Test file(s) added
  • Version and date string updated in changed source files
  • Relevant \changes entries in source included
  • Relevant changes.txt updated
  • Rollback provided (if necessary)?
  • ltnewsX.tex (and/or latexchanges.tex) updated

This is a slightly adjusted version of #1396 because that pull request would be difficult to merge after all several changes to ltfssaxes.dtx. It contains the pull request #1582 as the two are somewhat interwined.

base/ltfssaxes.dtx Outdated Show resolved Hide resolved
@cfr42
Copy link
Contributor

cfr42 commented Dec 14, 2024

Is it possible to predict the chosen rules? In most cases, the reasoning is obvious, but it is not always clear why weight is given priority over width in some cases but not in others (or the other way around).

I also wonder how easy it would be to enable users to \Show whether a rule applies and, if so, what it is. (Most users wouldn't use it, but the same is true for most aids to diagnosis.)

[I am somewhat tempted to remove code which subverts the series change rules from nfssext-cfr if the format is new enough, but I don't understand the reasons for the rule choices at the moment.]

@FrankMittelbach
Copy link
Member Author

Is it possible to predict the chosen rules? In most cases, the reasoning is obvious, but it is not always clear why weight is given priority over width in some cases but not in others (or the other way around).

it is pretty difficult to come up with consistent defaults when a falback is required. Could be that during all this editing some leftovers are still there.

My basic guiding principle for the few cases with the forth argument non-empty was

  • bold is something that is typically used in headings so if some form of bold is requested you don't want to loose it altogether, so for semibold, extrabold and ultrabold if that doesn't exist we try just bold as a nearby neighbor

  • bx is swapped with b if not existing to account for \bfdefault being bx while only CM and LM and a few others have bx rather than b.

  • of course, one could argue, that something like {c}{bx} -> {bx} or {b} could be better {c}{bx} -> {bc}`, i.e., always interpreting "bx" as a bad 2e name for "b" but then you loose the ability to really specify "bx" meaning go to "bold extended"

  • using bx as a fallback for b makes little sense for anything other than "m" because if we are in, say, "c" then this font family is most certainly having a "b" if it has any bold at all.

I guess that's all behind the current choices.

I also wonder how easy it would be to enable users to \Show whether a rule applies and, if so, what it is. (Most users wouldn't use it, but the same is true for most aids to diagnosis.)

maybe. but it is already logged if a substitution happens ie if the 4th argument is used rather than the 3rd if I remember correctly, but I can have a look to see if some "debugging" cna be easily implemented.

[I am somewhat tempted to remove code which subverts the series change rules from nfssext-cfr if the format is new enough, but I don't understand the reasons for the rule choices at the moment.]

Copy link
Contributor

@user227621 user227621 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firstly, a few minor comments (another review will follow)

base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
Copy link
Contributor

@user227621 user227621 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more minor comments (another review will follow)

base/changes.txt Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
Copy link
Contributor

@user227621 user227621 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fully implement the "stay with some sort of bold if a request for sb, eb or ub cannot be fulfilled" logic, the following rules are missing.

(another review will follow)

base/ltfssaxes.dtx Show resolved Hide resolved
base/ltfssaxes.dtx Show resolved Hide resolved
base/ltfssaxes.dtx Show resolved Hide resolved
base/ltfssaxes.dtx Show resolved Hide resolved
base/ltfssaxes.dtx Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Show resolved Hide resolved
@FrankMittelbach
Copy link
Member Author

I also wonder how easy it would be to enable users to \Show whether a rule applies and, if so, what it is. (Most users wouldn't use it, but the same is true for most aids to diagnosis.)

something like this?

\documentclass{article}

%\input{test2e}

\usepackage[debugshow]{tracefnt}

\makeatletter


\DeclareRobustCommand\selectfont
        {%
    \ifx\f@linespread\baselinestretch \else
      \set@fontsize\baselinestretch\f@size\f@baselineskip \fi
    \ifx\delayed@f@adjustment\@empty
    \else
      \typeout{-----> Try changing font series in \noexpand\selectfont}%
      \let\f@shape@saved\f@shape
      \let\f@series@saved\f@series
      \delayed@f@adjustment
      \maybe@load@fontshape
      \ifcsname \f@encoding/\f@family/\f@series/\f@shape \endcsname
      \else
        \typeout{>>>> Font face \f@encoding/\f@family/\f@series/\f@shape\space
	   does not exit ^^J%
	   \@spaces\@spaces Retry with
	   \noexpand\f@series = '\f@series@saved' and
	   \noexpand\f@shape = '\f@shape@saved'
	   }%
        \let\f@shape\f@shape@saved
        \let\f@series\f@series@saved
        \let\delayed@merge@font@shape\merge@font@shape
        \let\delayed@merge@font@series\merge@font@series
        \delayed@f@adjustment
        \let\delayed@merge@font@shape\merge@font@shape@without@substitution
        \let\delayed@merge@font@series\merge@font@series@without@substitution
      \fi
      \let\delayed@f@adjustment\@empty
    \fi
    \@forced@seriesfalse
    \xdef\font@name{%
      \csname\curr@fontshape/\f@size\endcsname}%
    \pickup@font
    \font@name
    \UseHook{selectfont}%
    \size@update
    \enc@update
    \typeout{-----> Series after \noexpand\selectfont is '\f@series'}%
    }


\DeclareRobustCommand\fontseries[1]{%
  \expandafter \let \expandafter \reserved@a
        	      \csname series@\f@series @#1\endcsname
  \typeout{-----> \noexpand\fontseries request with '#1'^^J%
   	      \@spaces\@spaces
               Current font series: '\f@series'^^J%
  	      \@spaces\@spaces
	      \ifx  \reserved@a \relax
 	         No rule for '\f@series' + '#1'
		 --> try '#1' unconditionally
	      \else
  	         Rule: '\f@series' + '#1'
		 --> 
	         '\expandafter \@firstoftwo \reserved@a'
	         \if!\expandafter \@secondoftwo \reserved@a!\else
	            \space (\expandafter \@secondoftwo \reserved@a)
		 \fi
	       \fi
	}%
    \@forced@seriesfalse
    \expandafter\def\expandafter\delayed@f@adjustment\expandafter
        {\delayed@f@adjustment\delayed@merge@font@series{#1}}}

\DeclareRobustCommand\fontseriesforce[1]{%
  \expandafter \let \expandafter \reserved@a
        	      \csname series@\f@series @#1\endcsname
  \typeout{-----> \noexpand\fontseriesforce request with '#1'^^J%
  	      \@spaces\@spaces
               Current font series: '\f@series'^^J%
  	      \@spaces\@spaces
	      \ifx  \reserved@a \relax
 	         No rule for '\f@series' + '#1'
		 --> try '#1' unconditionally
	      \else
  	         Rule: '\f@series' + '#1'
		 --> 
	         '\expandafter \@firstoftwo \reserved@a'
	         \if!\expandafter \@secondoftwo \reserved@a!\else
	            \space (\expandafter \@secondoftwo \reserved@a)
		 \fi
	       \fi
	}%
    \@forced@seriestrue
    \expandafter\def\expandafter\delayed@f@adjustment\expandafter
      {\delayed@f@adjustment\edef\f@series{#1}}}


\let\delayed@merge@font@series\merge@font@series@without@substitution


\def\merge@font@series#1{%
  \typeout{---> Attempt to switch with fallback for \f@series\space + #1}%
  \expandafter\expandafter\expandafter
  \merge@font@series@
    \csname series@\f@series @#1\endcsname
    {#1}%
    \@nil
}
\def\merge@font@series@#1#2#3\@nil{%
  \def\reserved@a{#3}%
  \ifx\reserved@a\@empty
    \typeout{-->> Attempt to switch to '#2' (ignore current series - no rule)}%
    \set@target@series{#2}%
  \else
    \typeout{-->> Attempt to switch to '#1'}%
    \edef\reserved@a{\f@encoding /\f@family /#1/\f@shape}%
     \ifcsname \reserved@a \endcsname
       \set@target@series{#1}%
    \else
       \typeout{-->> ... failed; attempt to switch to '#2' (fallback)}%
       \ifcsname \f@encoding /\f@family /#2/\f@shape \endcsname
         \set@target@series{#2}%
         \@font@shape@subst@warning
       \else
         \typeout{-->> ... failed; attempt to switch to '#3' (ignore current series)}%
         \set@target@series{#3}%
         \@font@shape@subst@warning
       \fi
    \fi
  \fi
  \typeout{->>> \noexpand\f@series now '\f@series'}%
}


\def\merge@font@series@without@substitution#1{%
  \typeout{---> Attempt to switch without using fallback for \f@series\space + #1}%
  \expandafter\expandafter\expandafter
  \merge@font@series@without@substitution@
    \csname series@\f@series @#1\endcsname
    {#1}%
    \@nil
}


\def\merge@font@series@without@substitution@#1#2#3\@nil{%
  \def\reserved@a{#3}%
  \ifx\reserved@a\@empty
    \typeout{-->>  Switch unconditionally to '#2' (ignore current series)}%
    \set@target@series{#2}%
  \else
    \typeout{-->> Switch unconditionally to '#1'}%
    \set@target@series{#1}%
  \fi
  \typeout{->>> \noexpand\f@series now '\f@series'}%
}


\makeatother

\begin{document}

%\START

\bfseries A
\fontseries{c}\selectfont B
\fontseries{zzz}\selectfont C
\bfseries D\tracingnone

\newpage
%\OMIT
\end{document}

After cleanup and some integration with tracefnt perhaps.

Copy link
Contributor

@user227621 user227621 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some rewordings

base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
@user227621
Copy link
Contributor

Three further comments:

  • The copyright notice in ltfssaxes.dtx is outdated: Copyright (C) 2019-2020 Frank Mittelbach
  • An incomplete sentence at the beginning of ltfssaxes.dtx: "This file contains the implementation for handling extra axes splitting the series and the values into sub-categories. selection commands."
  • The rollback data needs to be regenerated because of added/deleted/changed rules.

Copy link
Contributor

@user227621 user227621 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve alignment

base/ltfssaxes.dtx Outdated Show resolved Hide resolved
@cfr42
Copy link
Contributor

cfr42 commented Dec 15, 2024

something like this?

That's more elaborate than I had in mind, but, yes, that would be useful, I think.

On line 24: exit -> exist.

Thanks.

Copy link
Contributor

@car222222 car222222 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not checked: approx. one million? Change Rules . . .
so I cannot guarantee that all the alignments are spot on!

A few wording changes are either essential, or recommended.

base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
@cfr42
Copy link
Contributor

cfr42 commented Dec 15, 2024

I think using a more probable series in the fourth argument makes more sense than repeating the series from the first, unless there is some guarantee that the first actually exists.

Probably I'm missing something here, but there is certainly no general guarantee that the current font name reflects the actual font series (or shape etc.). After \fontseries{zzz}\selectfont, the current font series is zzz. So if you add a rule like

\DeclareFontSeriesChangeRule {zzz}{eb}{eb}{zzz}

because zzz is a better approximation for eb than b, that doesn't mean you will actually get a better approximation for eb in the typeset result.

Co-authored-by: user227621 <[email protected]>
@FrankMittelbach
Copy link
Member Author

I think using a more probable series in the fourth argument makes more sense than repeating the series from the first, unless there is some guarantee that the first actually exists.

Probably I'm missing something here, but there is certainly no general guarantee that the current font name reflects the actual font series (or shape etc.). After \fontseries{zzz}\selectfont, the current font series is zzz. So if you add a rule like

\DeclareFontSeriesChangeRule {zzz}{eb}{eb}{zzz}

because zzz is a better approximation for eb than b, that doesn't mean you will actually get a better approximation for eb in the typeset result.

Given that one doesn't know what 'zzzz' it is hard to say if that is a good rule or not, but if the user wanted 'zzz' and now wants to switch to 'eb' and 'eb' doesn't exist then your rule says stay with the series you are in, so it is not an unreasonable rule even for that case. Of course, if you want to ensure that there is always some "boldness" as the result and using 'b' is a better choice (which is what I wrote earlier).

But the statement wasn't that any arbitray zzzz is good approximation for eb, the argument was that ebuc is a better approroximation to ubuc than b or buc.

@cfr42
Copy link
Contributor

cfr42 commented Dec 15, 2024

But the statement wasn't that any arbitray zzzz is good approximation for eb, the argument was that ebuc is a better approroximation to ubuc than b or buc.

Yes, but the current series being ebuc doesn't guarantee this, does it? Because you don't know whether it is actually ebuc or not.

@cfr42
Copy link
Contributor

cfr42 commented Dec 15, 2024

But, thinking about this again, maybe the rules do now guarantee the current font is the best available substitute, even if it is not what it says on the tin?

@FrankMittelbach
Copy link
Member Author

But the statement wasn't that any arbitray zzzz is good approximation for eb, the argument was that ebuc is a better approroximation to ubuc than b or buc.

Yes, but the current series being ebuc doesn't guarantee this, does it? Because you don't know whether it is actually ebuc or not.

No it does not, i.e., if somebody did \fontseries{ebuc} in one go an this didn't exist, but as I tried to explain in my other reply, if ubuc and ebuc doesn't exist trying the latter one more time doesn't really hurt. Any such fallback is only helping so much and if you are making an important document then you better make sure that all that is requested as font faces is really to your liking and if not do some adjustments.

@cfr42
Copy link
Contributor

cfr42 commented Dec 16, 2024

No it does not, i.e., if somebody did \fontseries{ebuc} in one go an this didn't exist, but as I tried to explain in my other reply, if ubuc and ebuc doesn't exist trying the latter one more time doesn't really hurt.

Sorry. I do not really understand how to navigate GitHub replies as the link always just dumps me at the top of the page.

Any such fallback is only helping so much and if you are making an important document then you better make sure that all that is requested as font faces is really to your liking and if not do some adjustments.

Well, yes. I don't really have a view on what the rule should be. I just wasn't convinced by the reason for changing your initial proposal. Indeed, there is a limit to what you can do. I keep track of fake fonts and it still isn't always clear what to do.

@FrankMittelbach
Copy link
Member Author

No it does not, i.e., if somebody did \fontseries{ebuc} in one go an this didn't exist, but as I tried to explain in my other reply, if ubuc and ebuc doesn't exist trying the latter one more time doesn't really hurt.

Sorry. I do not really understand how to navigate GitHub replies as the link always just dumps me at the top of the page.

you are not the only one. I find that difficult too and largely rely on the additional mails I get as well

Any such fallback is only helping so much and if you are making an important document then you better make sure that all that is requested as font faces is really to your liking and if not do some adjustments.

Well, yes. I don't really have a view on what the rule should be. I just wasn't convinced by the reason for changing your initial proposal. Indeed, there is a limit to what you can do. I keep track of fake fonts and it still isn't always clear what to do.

I'm not 100% convinced either, but my current feeling is that is not a bad idea the way it is now. Maybe it has to be revisited at some point if mre real life usage shows what works best.

@user227621 any more comments from you (you still request changes)?

base/ltfssaxes.dtx Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
@user227621
Copy link
Contributor

And the (hopefully) final comment: In line 244, replace

%    Only a few entries have ``alternative'' values and perhaps most of
%    them should get dropped. Or maybe not \ldots{} needs some thought
%    perhaps.

with

%    Only a few entries have ``alternative'' values.

(I think we've thought about it enough now.)

@FrankMittelbach
Copy link
Member Author

unless I overlooked something I think this PR is done from my side

Copy link
Contributor

@user227621 user227621 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could remove the unnecessary <----- comments in the rollback section (they just produce overfull boxes). Otherwise, I think this PR is ready.

base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
base/ltfssaxes.dtx Outdated Show resolved Hide resolved
@FrankMittelbach
Copy link
Member Author

thanks @car222222, @cfr42 and @car222222 for helping to get this done

@FrankMittelbach FrankMittelbach merged commit 176699b into develop Dec 17, 2024
86 checks passed
@FrankMittelbach FrankMittelbach deleted the series-changes branch December 17, 2024 14:12
@FrankMittelbach
Copy link
Member Author

thanks @car222222, @cfr42 and @car222222 for helping to get this done

correction: thanks @user227621 ... !

@user227621
Copy link
Contributor

@FrankMittelbach You're welcome.

@cfr42
Copy link
Contributor

cfr42 commented Dec 17, 2024

You don't need to thank me for sticking my nose in where it wasn't wanted. ;)

@FrankMittelbach
Copy link
Member Author

You don't need to thank me for sticking my nose in where it wasn't wanted. ;)

any constructive feedback is wanted (by me at least). Doesn't necessarily me I follow a suggestion (though often enough I do), but just tihnk about it or clarify, if something is not clear, is a Good Thing (TM). And it resulted, for example, in some draft code for debugging which eventually wil be useful, once integrated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants