11

I've installed full TexLive 2011 using "install-tl" script in Ubuntu 12.04. When I was using TexLive 2009 from repositories the following file was compiled without any errors.

\documentclass{article}
% XeLaTeX
\usepackage{xltxtra}
\usepackage{xunicode}

% Fonts
\setmainfont{Arial}
\newfontfamily\cyrillicfont{Arial}
\setmonofont{Courier New}

% Lang
\usepackage{polyglossia}
\setmainlanguage{russian}
\setotherlanguage{english}

\begin{document}
English normal.  \texttt{English monospace}.

Русский обычный.  \texttt{Русский моноширинный}.  % Text in Russian
\end{document}

But XeLaTeX from TexLive 2011 gives this error:

ERROR: Package polyglossia Error:

--- TeX said --- The current roman font does not contain the Cyrillic script! Please define \cyrillicfont with \newfontfamily.

See the polyglossia package documentation for explanation. Type H for immediate help. ...

l.17 ...nglish normal. \texttt{English monospace} .

In spite of this error the output PDF is correct.

The error remains if comment out \setmonofont{Courier New}. Using Courier New as main font gives no error on normal text (without \texttt, \textbf and so on). Using DejaVu Sans Mono as monospaced font gives no error too.

I've been searching for solution few hours but there aren't any. Maybe this is a bug in Polyglossia or Fontspec?

1 Answer 1

16

Some fonts don't advertise their features correctly, as far as Polyglossia can understand them. In your case you have to announce that Courier New can be used also for cyrillic monospaced bits:

\newfontfamily{\cyrillicfonttt}{Courier New}

Notice also that if you should enclose English passages in suitable environment, or hyphenation won't be even attempted.

To give an example for languages that I know, assume that I'm writing a document in English with parts in Italian. The hyphenation rules for Italian are very different from the English rules: the Italian word "formidabile" is hyphenated for-mi-da-bi-le, while the English "formidable" is hyphenated for-mid-able.

XeTeX uses one set of hyphenation rules at a time, but it can switch between sets of rules. A passage in English when the current language is Russian will not be hyphenated at all, because the rules for Russian involve only the cyrillic characters. It's in principle possible to write hyphenation rules that treat properly English and Russian, because they use different parts of Unicode. But this would be impossible for Russian and Ukrainian; and if the document is in Russian, Italian and English, what set of rules would be used?

2
  • Thank you, this removes the error. Why does it work? I've looked at fontspec documentation but there is no information about \cyrillicfonttt. For short text in English I use \textenglish but have no idea why I have to do it :) Could you explain it too, please?
    – Kirill
    May 28, 2012 at 12:59
  • 4
    @Kirill The \<family>fonttt feature is explained on page 6 of the documentation of Polyglossia. I've added some words about "segregating languages".
    – egreg
    May 28, 2012 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .