# Using Courier New font when main language uses cyrillic script [duplicate]

If I set language that uses cyrillic script as the default one, I can't use font Courier New.

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{russian}
\setmonofont{Courier New}
\newfontfamily\cyrillicfont{Courier New}
\begin{document}
\texttt{русский язык}
\end{document}


The compiler is complaining:
! Package polyglossia Error: The current roman font does not contain the Cyrillic script! (polyglossia) Please define \cyrillicfont with \newfontfamily.

But, as you can see, Courier New is defined with \newfontfamily\cyrillicfont{Courier New}.

I compile with XeLaTeX.

Edit: polyglossia package is required.

## marked as duplicate by egreg fonts StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Apr 8 '18 at 14:18

• Maybe you can do an advanced search of some sorts in tug.dk/FontCatalogue. I've never used the catalogue, but it might be worth a shot. – thymaro Apr 5 '18 at 8:48

polyglossia is strict about scripts in fonts. So if a font doesn't have Cyrillic script defined, it won't allow you to use it. Particularly for Courier New:

% otfinfo -s Courier_New.ttf
arab            Arabic
arab.URD        Arabic/Urdu
hebr            Hebrew
latn            Latin
latn.LTH        Latin/Lithuanian
latn.ROM        Latin/Romanian


babel on the other hand doesn't bother about scripts, it just requires Cyrillic characters to be in place. The following code works fine:

\documentclass{article}
\usepackage{fontspec}
\usepackage[russian]{babel}
\setmonofont{Courier New}
\begin{document}
\texttt{русский язык}
\end{document}

• Thanks, but I need polyglossia (I think I don't need to explain why, since those reasons are irrelevant for this problem). I planned to use Courier New for code only (therefore no cyrillic script inside of \texttt{}, only latin, dismiss \texttt{русский язык}, it's just an example). But that's not possible either. So, if any of you know any other good font for code that supports cyrillic script, please recommend it as a replacement for Courier New. – Hanlon Apr 4 '18 at 16:08
• You could switch to English for code snippets. Something like \newcommand{\code}[1]{\textenglish{\texttt{#1}}}. – Sergei Golovan Apr 4 '18 at 16:13
• I tried \textenglish{\texttt{TEST}} but compiler says Undefined control sequence. l.8 \textenglish{\texttt{TEST}}. – Hanlon Apr 4 '18 at 16:21
• You'd have to add \setotherlanguage{english} to the preamble to define \textenglish. Unfortunately, Polyglossia still complains about Cyrillic script. So sorry, this doesn't work either. – Sergei Golovan Apr 4 '18 at 16:52
• Is there anything I can do to have text in some code format in my document? – Hanlon Apr 4 '18 at 17:01

Use \newfontfamily\cyrillicfonttt{Courier New}.

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{russian}
\setmainfont{Arial}
\newfontfamily\cyrillicfont{Arial}
\setmonofont{Courier New}
\newfontfamily\cyrillicfonttt{Courier New}
\begin{document}
\texttt{русский язык}
\end{document}