# Why does xelatex need fontspec to output non-ASCII characters?

I thought the point of XeTeX was to allow Unicode to work out of the box (in addition to leveraging system fonts). So how come the following does not output anything unless I use the fontspec package?

\documentclass{article}
\usepackage{fontspec}  % must be present
\begin{document}
éʡ
\end{document}


The first character is U+00E7 (present in Latin-1) and the second is U+02A1.

XeTeX allows easy access to system fonts, but none of the standard formats (here the LaTeX format) load these. Indeed, it's not possible to save system fonts into a format: they have to be loaded when used. As such, when you run xelatex you get almost the same preloaded code as you do with latex or pdflatex (there are a few changes to deal with assigning codes to an extended set of characters). The standard TeX fonts don't have coverage of all of Unicode, so the characters you want to print are simply not available.

It's not absolutely necessary to use fontspec to use system fonts with XeLaTeX: you can load the font directly using the \font primitive, which is extended by XeTeX. However, using fontspec makes life a lot easier. With the standard settings, fontspec will load the Latin Modern font, which includes a lot wider glyph coverage than LaTeX 'out of the box'. It's important to note that you will see only see the glyphs that the font includes: a classic issue is that most western fonts don't cover Chinese, etc., so you need an appropriate font here.

No, you don't have to use fontspec, but you must change the default Computer Modern fonts. CM fonts do not contain these characters, use a Unicode font instead.

Example:

\documentclass{article}
\font\1="Times New Roman" % For windows
\begin{document}
\1
éʡ
\end{document}


You need a font that have the characters you want since, unlike most desktop applications, XeTeX does not do automatic font fall back when a requested character is missing from the current font (for good reasons). One of the side effects of loading fontspec is that is makes Latin Modern fonts the default which has wider Unicode coverage than the original Computer Modern fonts, but there is no (and unlikely there will ever be) font that covers the whole Unicode.

• Hmm. Isn't Unifont precisely that (a font covering all of unicode?) – Clément Aug 6 '16 at 5:05
• @Clément: Unifont covers only Basic Multilingual Plane, that is only a part of Unicode (though the most commonly used one), and it does not provide much for good typography. Actually you can’t have more than 0xFFFF glyphs in an OpenType/TrueType font, so by definition no modern font format can cover all of Unicode. – Khaled Hosny Oct 2 '16 at 23:15