4

In the following MWE, "Lorem ipsum" should be light, but you get the regular weight.

%\RequirePackage[2019/10/01]{latexrelease}
\documentclass{article}
  
\begin{document}

\fontseries{l}\fontfamily{NotoSans-TLF}\selectfont Lorem ipsum

\end{document}

The warning says:

LaTeX Font Warning: Font shape `OT1/cmr/l/n' undefined
(Font)              using `OT1/cmr/m/n' instead on input line 6.

Apparently, LaTeX tries OT1/cmr/l/n (which doesn't exist), substitutes OT1/cmr/m/n, and finally you get OT1/NotoSans-TLF/m/n.

If you use \RequirePackage[2019/10/01]{latexrelease} (this cancels the NFSS changes of LaTeX 2020-02-02), you get the light series as expected.

Further observations:

  • If you ask for \fontseries{sb}, you get b instead.
  • If you ask for \fontseries{c}, you get m instead.
  • If you ask for ul, el, m, b, eb or ub, you get the requested font series. (This is very confusing because e. g. OT1/cmr/ul/n doesn't exist either)
  • If you use \fontfamily{NotoSans-TLF}\fontseries{l}\selectfont Lorem ipsum instead, you get the requested font series.
  • The same problem occurs with other fonts.

Update: This issue has been discussed at GitHub and classified as a bug. It will be fixed (along with other inconsistencies in the font selection mechanism) with the new LaTeX version 2021-06-01.

6

Font attributes are changed in the order

\fontencoding
\fontfamily
\fontshape
\fontseries
\fontsize

So what happens with your input is that first the shape is changed to l, which Computer Modern hasn't, so it's substituted with the default m.

Using the proper order the output is as expected:

\documentclass{article}

\begin{document}

\fontfamily{NotoSans-TLF}\fontseries{l}\selectfont Lorem ipsum

\end{document}

Most important is to have the family declaration at the beginning, because this will cause LaTeX to read the font definition file (if not already done) so the possible other attributes are known.


Important update

With the forthcoming 2021-06-01 release of the LaTeX kernel, the issue should no longer be of a concern. On the other hand, keeping a semantic order of declarations when changing font is usually better.

9
  • Thanks. Is it documented somewhere that the order \fontencoding\fontfamily\fontshape\fontseries\fontsize is required? I cannot find such an advice e. g. in fntguide.pdf. – user227621 Oct 26 '20 at 11:40
  • I’m pretty sure you want \fontfamily and \fontencoding before any of the others, in either order, and that series, shape and size come after, in any order. Please correct me if this is wrong? – Davislor Oct 26 '20 at 12:34
  • @Davislor Better; \fontencoding first, then \fontfamily and the rest in no particular order, although sticking to a precise one is better. – egreg Oct 26 '20 at 13:03
  • @egreg Maybe the same order they’re displayed in, then: series, shape, size? That’s easiest to keep straight. – Davislor Oct 26 '20 at 13:21
  • 1
    You can't always follow such an order. If you have e.g. a quote set in semibold and use there some greek or \texttt then you are switching encoding and family after the series and that should work too. – Ulrike Fischer Oct 26 '20 at 13:44
6

The difference between the ul and the l series is that the LaTeX kernel has a rule for the m/l switch:

\DeclareFontSeriesChangeRule {m}{l}{l}{m}

This rule means that if m (first argument) is the current series, and l is requested (second argument) then l is tried (third argument) and if it doesn't exist the series falls back to m (fourth argument).

As egreg wrote, you are trying to change the series while cmr is still active, and so, as it has no l-series, m is forced.

You can get a similar effect for ul if you declare a rule for it too:

\documentclass{article}

\begin{document}

{ \fontseries{ul}\fontfamily{NotoSans-TLF}\selectfont Lorem ipsum }

\DeclareFontSeriesChangeRule {m}{ul}{ul}{m}

{ \fontseries{ul}\fontfamily{NotoSans-TLF}\selectfont Lorem ipsum }

\end{document}  

enter image description here

You can avoid the fallback to m by removing the fourth argument from the rule:

\documentclass{article}

\DeclareFontSeriesChangeRule {m}{l}{l}{}
\begin{document}

\fontseries{l}\fontfamily{NotoSans-TLF}\selectfont Lorem ipsum 

\end{document}

enter image description here

3
  • In your comment to egreg's answer (who wrote that one has to follow a specific order when changing font attributes), you wrote: "You can't always follow such an order. If you have e. g. [...] then you are switching encoding and family after the series and that should work too." Does that mean that my MWE reveals kind of a bug in LaTeX? (The MWE worked as intuitively expected before 2020-02-02.) Or do you agree with egreg that this is a user error? – user227621 Nov 4 '20 at 8:56
  • no I don't think that there is a bug. Handling fonts with many series and weights is rather challenging, and the default settings can't fit to every possible font combination. If you start to use a font with more than the normal series you will perhaps have to adjust the rules along the lines I showed in my example. – Ulrike Fischer Nov 4 '20 at 9:10
  • With the new LaTeX version 2021-06-01, the workaround described here is no longer necessary. (See the note at the end of my edited answer.) – user227621 Jun 1 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.