# Font shape undefined when using OpenType font and mathdesign

I'm trying to use Adobe Utopia fonts for text and mathdesign's utopia font for math. But with this sample document:

\documentclass{article}
\usepackage[utopia]{mathdesign}
\usepackage{fontspec}
\setmainfont{Utopia Std}
% \setmainfont{TeX Gyre Pagella} % Also doesn't work
\begin{document}
hello $world$
\end{document}


I get the warning:

LaTeX Font Warning: Font shape TU/mdput/m/n' undefined
(Font)              using TU/lmr/m/n' instead on input line 186.


even though the output looks fine. I searched a bit and found out that lmr is the Latin Modern font, but it doesn't appear anywhere in the document (as far as I could see). Using other fonts (for example TeX Gyre Pagella also doesn't work), and even if I don't use another font at all:

\documentclass{article}
\usepackage[utopia]{mathdesign}
\begin{document}
hello $world$
\end{document}


How to properly get rid of that warning?

• \usepackage[OT1]{fontenc} (before \usepackage{mathdesign}) removes the warning - but you can also just leave it. – Marijn Jan 29 at 17:14
• @Marijn Thanks, that helps with the second code, but as soon as I add fontspec (which I need), the warning returns... You say "just leave it": is that warning harmless? Where is it trying to use lmr? – LaTeXer Jan 29 at 19:22
• All right, I found an actual solution, but it’s a really ugly hack. – Davislor Jan 29 at 22:51

I found a way to suppress the error message (thanks, @egreg, for pointing out how the first idea didn’t work), but it’s an extremely ugly hack. I would honestly just ignore it as harmless.

\documentclass{article}
\usepackage[OT1,T1]{fontenc}
\usepackage[utopia, euro=false]{mathdesign}
\usepackage{substitutefont} % Ugly hack to suppress warning.
\substitutefont{TU}{mdput}{lmr} % Ugly hack to suppress warning.
\usepackage{fontspec}

\setmainfont{Lingua Franca}[NFSSFamily=mdput]

\begin{document}
hello $world$
\end{document}


Another workaround is to load unicode-math with STIX Two for the math symbols and Utopia (or a clone) for the letters. Here, I use the free Lingua Franca.

\documentclass{article}
\usepackage{unicode-math}

\defaultfontfeatures{Scale=MatchLowercase}

\setmainfont{Lingua Franca}[Scale = 1.0] % Or Utopia Std
\setmathfont{STIX Two Math}
\setmathfont{Lingua Franca Regular}[range=up,
Script=Default, script-features={}, sscript-features={}]
\setmathfont{Lingua Franca Italic}[range=it,
Script=Default, script-features={}, sscript-features={}]
\setmathfont{Lingua Franca Bold}[range=bfup,
Script=Default, script-features={}, sscript-features={}]
\setmathfont{Lingua Franca Bold Italic}[range=bfit,
Script=Default, script-features={}, sscript-features={}]

\begin{document}

Hello, $$\mathit{world}$$!

\end{document}


I added a few extra options to suppress harmless warning messages. I had a hunch you’d want me to.

• Not really. The warning is still there. – egreg Jan 29 at 17:56
• @egreg Thanks for checking. That’s odd. Without having the package to examine, my next idea would be substitutefont. If that works, I’ll edit my answer, and if it doesn’t, I might as well delete it. – Davislor Jan 29 at 19:09
• @Davislor Thanks for your answer! However I still get the warning with \documentclass{article} \usepackage[utopia]{mathdesign} \usepackage{fontspec} \setmainfont{Utopia Std}[NFSSFamily = mdput] \begin{document} hello $world$ \end{document}. Am I doing something wrong? I already tried changing the order of the packages – LaTeXer Jan 29 at 19:20
• @LaTeXer No, you aren’t doing anything wrong. The top user of this site, all-time, tried and it didn’t work for him either. it looks like my guess about what’s causing the problem is not correct. – Davislor Jan 29 at 19:48
• @Davislor Okay, thank you! I hope someone knows what is happening. Thank you for your time!! – LaTeXer Jan 29 at 20:08