1

I'm using the Roboto light condensed font, and always get the following font warning:

Font shape OT1/cmr/lc/n' undefined(Font) using OT1/cmr/m/n' instead

An example document to generate the warning would be:

\documentclass{article}

\usepackage[sfdefault, light, condensed]{roboto} \usepackage[utf8]{inputenc}

\begin{document} Why does Roboto font give a warning? \end{document}

I am using pdflatex through TeXLive. Anyone any ideas on how to solve this?

dikdirk
  • 73

3 Answers3

1

With PDFLaTeX package roboto loads fontenc after changing some defaults but before changing the default family. So, while loading fontenc still cmr is the valid family. The package is one of the exceptions that are actually reloaded on every \usepackage or \RequirePackage. So the line

\usefont\encodingdefault\familydefault\seriesdefault\shapedefault

in the file is executed, even if you'd load the package yourself before roboto. And at this time \familydefault is still cmr. This results in a (in your case not needed) selection of a light condensed version of cmr, that does not exist.

You can simply ignore the warning. If you really, really have to avoid the warning, you can disable loading package fontenc inside roboto (and optionally load is yourself before the package):

\documentclass{article}
\usepackage{fontenc}
% NOTE: I DO NOT RECOMMEND TO DO THIS, BUT IT MAKES THE FONT WARNING GO AWAY.
\makeatletter
\disable@package@load{fontenc}
\makeatother
\usepackage[sfdefault, light, condensed]{roboto}
\makeatletter
\reenable@package@load{fontenc}
\makeatother
\begin{document}
Roboto font does not give a warning. Produces light condensed text.
\end{document}

But of course this is at your own risk!

cabohah
  • 11,455
  • 1
    Thnx. Found also another solution: \DeclareFontShape{\encodingdefault}{cmr}{lc}{n}{<->ssub*cmr/m/n}{}, here. It defines the font shape that is missing to prevent any warning. – dikdirk Apr 26 '23 at 15:33
  • @dikdirk Yes, if you also don't want a warning, if someone really tries to use a light condensed version of CMR, this would also be a solution. You can extend it to one more answer and even accept it, if you prefer this one. – cabohah Apr 26 '23 at 15:54
0

Compile with lualatex:

\documentclass{article}
% Compile using lualatex.
\usepackage[sfdefault, light, condensed]{roboto}
\begin{document}
    Roboto font does not give a warning. Produces light condensed text.
\end{document}
rallg
  • 2,379
0

Found also this workaround:

\DeclareFontShape{\encodingdefault}{cmr}{lc}{n}{<->ssub*cmr/m/n}{}
\usepackage[sfdefault, light, condensed]{roboto}

It sets the missing font (light condensed) for the default LaTeX computer modern font (cmr) to normal cmr.

As Roboto probably should not load cmr light condensed in the first place, it doesn't solve the root problem. But it prevents the warning in a safe way.

dikdirk
  • 73