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

changing bold series default to bx for all meta families fails #366

Closed
u-fischer opened this issue Aug 9, 2020 · 6 comments · Fixed by #375
Closed

changing bold series default to bx for all meta families fails #366

u-fischer opened this issue Aug 9, 2020 · 6 comments · Fixed by #375

Comments

@u-fischer
Copy link
Member

In the following example the test font has only a bx series, while times substitute b for bx. And this leads to the problem that the test font is not bold when it is selected after the series has been set.
In the original problem the test font isn't cmss, but a singalese font.

I tried to to set the default font series to bx, but this fails, only the version with the optional argument works as expected:
(Compiled with pdflatex-dev.)

\RequirePackage{latexbug}
\documentclass[12pt]{article}
\usepackage{times}
% a font only with bx series:
\def\test{\fontfamily{cmss}\selectfont}

\DeclareFontSeriesDefault{bf}{bx}    %fails
%\DeclareFontSeriesDefault[rm]{bf}{bx} %works

\begin{document}

\makeatletter
\bfseries \f@series~bold  \test not bold!

\end{document}

image

test-font.log

@FrankMittelbach
Copy link
Member

Well I tend to consider this "as works as (imperfectly) designed". NFSS handles variant bold only for "meta families" but not for any additional font that you may call in your document. And doing \fontfamily{cmss}\selectfont switches to an arbitrary font using low-level calls and there no bold checking happens.

Even setting \renewcommand\sfdefault{cmss} wouldn't change that; basically when you use \selectfontyou get what you ask for. Only when you the high-level \sffamily it makes an attempt to check on the bold status. Maybe that could have been done more generally, but as of now it only works with high-level commands for the 3 meta families "rm", "sf" and "tt", i.e. what is expected by users to use in their documents.

So to make this work you need to change the "sf" meta family to "cmss" (after loading times it is phv) and also use \sffamily not a low-level call.

@u-fischer
Copy link
Member Author

Well the main question is, why does it work with \DeclareFontSeriesDefault[rm]{bf}{bx} but not with \DeclareFontSeriesDefault{bf}{bx}? I had thought that resolving issue #306 meant the second sets the default for all three meta families.

@FrankMittelbach
Copy link
Member

That case works for a very simple reason (nothing to do with #306): if you make the default for \bfseries "bx" then calling
\bfseries tries to load Times with "bx" and that succeeds as the Times .fd has a substitution inside so it actually loads the "b" but keeps \f@series at "bx", thus the \test command will select cmss with "bx" and so it works.

Anyway, the 2010-10-01 format offers you a solution if you deal with fonts outside of the meta families:

\def\test{\IfFontSeriesContextTF{bf}%
   {\fontfamily{cmss}\fontseries{bx}}%
   {\fontfamily{cmss}\fontseries{m}}\selectfont}

that is you can test the bold status and do something based on the result.

@FrankMittelbach
Copy link
Member

Well the main question is, why does it work with \DeclareFontSeriesDefault[rm]{bf}{bx} but not with \DeclareFontSeriesDefault{bf}{bx}? I had thought that resolving issue #306 meant the second sets the default for all three meta families.

#306 deals with the question of what should happen if you change \bfdefault directly (old interface) and there everything is reset. When using \DeclareFontSeriesDefault then only the part specified is altered that is

\DeclareFontSeriesDefault{bf}{...}

only affects fonts that are not one of the meta families. Maybe that is wrong and it should do reset throughout, but the reason it is like this is that it is difficult to just set the default for anything outside the meta families and you don#t know what packages like times or ebgaramond or ... have done to the setup of the meta family. This is why all declararations only affect the part that hey deal with and not any other.

@u-fischer
Copy link
Member Author

\DeclareFontSeriesDefault{bf}{...} only affects fonts that are not one of the meta families.

Hm, ok so that is the misunderstanding. But how do you get "outside the meta families", so that \DeclareFontSeriesDefault{bf} has an effect?

@FrankMittelbach
Copy link
Member

Depends on what you mean by "\DeclareFontSeriesDefault{bf} has an effect. Its effect is that \bfseriesor \textbf takes this default if you typeset in a font that is none of the meta families and then call these commands. But if you go low-level with \selectfont then you switch to whatever font you ask for (including substitution if the combination family/series/shape does not exist) and the fontseries default is not looked at.

So if you want to typeset in such a font but in a way that the command called obeys the bold status, you need to use \IfFontSeriesContextTF in its definition.

@FrankMittelbach FrankMittelbach linked a pull request Aug 21, 2020 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants