# Undefined font shape with lualatex

I know that this is a quite common question, but looking for many threads about undefined font shape I didn't find any solution...

When I compile my document with lualatex I get 5 different warnings related to undefined font shapes substituted.

LaTeX Font Warning: Font shape TU/lmr/bx/sc' undefined
(Font)              using TU/lmr/bx/n' instead on input line 14.
--
LaTeX Font Warning: Font shape TU/lmroman12-italic.otf(0)/bx/n' undefined
(Font)              using TU/lmroman12-italic.otf(0)/m/n' instead on input line
--
LaTeX Font Warning: Font shape TU/lmroman12-italic.otf(0)/m/it' undefined
(Font)              using TU/lmroman12-italic.otf(0)/m/n' instead on input line
--
LaTeX Font Warning: Font shape TU/lmroman12-italic.otf(0)/bx/it' undefined
(Font)              using TU/lmroman12-italic.otf(0)/bx/n' instead on input lin
--
LaTeX Font Warning: Font shape TU/cmr/m/n' undefined
(Font)              using TU/lmr/m/n' instead on input line 25.
--
LaTeX Font Warning: Some font shapes were not available, defaults substituted.


Below is the minimal working example with my five warnings. Actually, I think there are 3 different error sources:

• a first one related to lmodern package: I believed that lmr includes maaaaany font shapes, in particular, all variations with lf/md/bf and up/it/sl/sc shapes ;
• the second one related to the way I define the font used for foreign language (maybe it's not the right place for this problem) ;
• a third one related to the use of cmr by the gnuplot cairolatex output.

Well, I'm interested in any idea to solve any of these problems.

\documentclass{memoir}

% Font packages
\usepackage{lmodern} % serif

% Define language
\usepackage{polyglossia}
\setmainlanguage[]{french}
\setotherlanguage[]{english}
% Define english font
\newfontfamily{\englishfont}{lmroman12-italic.otf} % Use italic font for foreign language

\begin{document}
\textsc{\textbf{TU/lmr/bx/sc $\to$ TU/lmr/bx/n}}

\textenglish{\textbf{TU/lmroman12-italic.otf(0)/bx/n $\to$ TU/lmroman12-italic.otf(0)/m/n}}

\textenglish{\textit{TU/lmroman12-italic.otf(0)/m/it $\to$ TU/lmroman12-italic.otf(0)/m/n}}

\textenglish{\textit{\textbf{TU/lmroman12-italic.otf(0)/bx/it $\to$ TU/lmroman12-italic.otf(0)/bx/n}}}

% Used including gnuplot cairolatex plots
\begingroup
\fontfamily{cmr}%
\selectfont
TU/cmr/m/n $\to$ TU/lmr/m/n
\endgroup
\end{document}

• Well, warnings about lmroman12-italic can be interpreted as 'don't pretend an italic font to be upright'. If you want any content of \textenglish{} to be italic by default, you could redefine \textenglish or patch it like the following: \usepackage{etoolbox} \pretocmd{\textenglish}{\itshape}{}{} instead. As for cmr, it haven't TU encoding support, heh. – Sergei Golovan Aug 10 '17 at 8:49
• Loading lmodern has no consequence on text fonts, because its settings would be overridden by fontspec; it still provides the setup for math fonts, though. – egreg Aug 10 '17 at 9:06
• For italic english text redefinition of \englishfont is the recommended way for polyglossia. Btw I managed to do what I want with this definition: \newfontfamily{\englishfont}{lmroman10}[ Extension=.otf, UprightFont=*-italic, BoldFont=*-bolditalic, ItalicFont=*-regular, BoldItalicFont=*-bold, SmallCapsFont=lmromancaps10-oblique] – AlexisBRENON Aug 10 '17 at 10:49
• \let\englishfont\itshape should be enough! See my edited answer – user2478 Aug 10 '17 at 12:01
• Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – samcarter_is_at_topanswers.xyz Jan 20 '18 at 14:23

Loading lmodern along with fontspec does nothing relevant for text fonts, because all it does in this respect is

\renewcommand{\rmdefault}{lmr}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}


which is done anyway by fontspec. It can make sense to load it nonetheless, because it also sets Latin Modern as the math font.

The warning

LaTeX Font Warning: Font shape TU/lmr/bx/sc' undefined
(Font)              using TU/lmr/bx/n' instead on input line 17.


is due to Latin Modern lacking boldface small caps. The last warning is due to cmr lacking a font definition file for TU, so LaTeX does the default substitution in this case, that is, changing the family name to \familydefault, which expands to \rmdefault and so to lmr.

The other three warnings derive from you defining \englishfont in an incorrect way.

\documentclass{memoir}

% Font packages
\usepackage{lmodern} % serif

% Define language
\usepackage{polyglossia}
\setmainlanguage[]{french}
\setotherlanguage[]{english}
% Define english font
\newfontfamily{\englishfont}{lmroman}[
Ligatures=TeX,
UprightFont=*10-italic,
ItalicFont=*10-italic,
BoldFont=*10-bolditalic,
BoldItalicFont=*10-bolditalic,
SmallCapsFont=*caps10-oblique,
]

\begin{document}

\textsc{\fontname\font}

\textsc{\textbf{\fontname\font}}

\textenglish{\textbf{\fontname\font}}

\textenglish{\textit{\fontname\font}}

\textenglish{\textit{\textbf{\fontname\font}}}

\textenglish{\textsc{\fontname\font}}

\end{document}


This will only raise one warning about the missing boldface small caps font.

• This is the solution I was looking. To fix the cmr related error use set terminal cairolatex font ',' in your gnuplot script to avoid any font definition in the resulting latex file. – AlexisBRENON Jan 22 '18 at 8:29

Use this definition:

\documentclass{memoir}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}[
SmallCapsFont=Latin Modern Roman Caps,
SmallCapsFeatures = { Letters=SmallCaps},
ItalicFeatures  = {SmallCapsFont=LMRomanCaps10-Oblique}
]
% Define language
\usepackage{polyglossia}
\setmainlanguage[]{french}
\setotherlanguage[]{english}
% Define english font
\let\englishfont\itshape

\begin{document}
\textsc{\textbf{TU/lmr/bx/sc $\to$ TU/lmr/bx/n}}

\textenglish{\textbf{TU/lmroman12-italic.otf(0)/bx/n}}

\textenglish{TU/lmroman12-italic.otf(0)/m/it}

\textenglish{\textbf{TU/lmroman12-italic.otf(0)/bx/it}}

\textenglish{\textsc{TU/lmroman12-italic.otf(0)/bx/it}}

\end{document}


As far as I know there is no Bold Small Caps for Latin Modern

• This only works if Latin Modern Roman is installed in the system font paths, doesn't it? Is there any way to rely on the lmodern package instead? – AlexisBRENON Aug 10 '17 at 9:04
• No, it works always with LuaTeX! – user2478 Aug 10 '17 at 9:08
• Well, thanks for the answer, but if it removes the warning, it doesn't generate bold small caps letters. No Bold Small Caps font are indeed available for Latin Modern and FakeBold are not supported by lualatex... – AlexisBRENON Aug 10 '17 at 10:46
• @Herbert can you update this to reflect the \fontfamily{cmr} part of the question also? – whatisit Nov 8 '17 at 20:28
• there is no need for cmr because the lmr is nearly the same and LAtin Modern is by loading fontspec the default font. – user2478 Nov 9 '17 at 10:12