[Tex/LaTex] Why does XeTeX not display basic Unicode characters

fontsunicodexetex

I have a document like this, but when I render it by invoking xelatex on it, the π character is displayed as a blank space:

\documentclass[13pt,oneside]{scrbook}
\usepackage{fontspec} % the problem remains, whether I use this or not

\begin{document}
\mainmatter
This is a paragraph with a PI (π) in it.
\end{document}

The relevant error message in the output seems to be:

LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <13> not available
(Font)              size <12> substituted on input line 1368.

I can work around this with the newunicode char package, but this is somewhat kludgy (I have to define every unicode character I want to use), and does not play well with fonts (when such characters appear in monospaced text, they will be typeset with the sans font because they are seen as math).

The problem seems to be that the font I'm using does not define the given character. Is it possible to have LaTeX automatically fall back to another, richer font in such a situation? Which font is known to cover a lot of characters? (I need some Greek letters, math symbols, arrows, and quote characters.) How about monospaced fonts?

Best Answer

Edit Here's egreg's (better) solution, for future reference, since this answer was accepted.

\RequirePackage{fix-cm}
\documentclass[fontsize=13pt,oneside]{scrbook}
\usepackage{fontspec}
\usepackage[Latin,Greek]{ucharclasses}

\newfontfamily\substitutefont{CMU Serif}
\setTransitionsForGreek{\begingroup\substitutefont}{\endgroup}

\begin{document}
\mainmatter
This is a paragraph with a PI (π) in it.
\end{document}

Here's the original message that I wrote, which does not use the \newfontfamily command.

Using ucharclasses:

\usepackage{ucharclasses}
  \setTransitionsFor{GreekAndCoptic}{\begingroup\fontspec{DejaVu Sans}[Scale=MatchLowercase]}{\endgroup}

(Of course, change DejaVu Sans to be any font on your system that has the desired characters.)