Luatex (or rather the luaotfload
Lua module) has its own font searching code which is naturally kpathsearch-aware and will find system fonts and fonts in texlive both by filename and by the internal font name such as CMU Serif
.
xetex uses the system font cache (fc-cache on linux and cygwin, and I think comes with a local copy of fc-cache on windows) it can find system and texlive fonts by filename but can only find fonts by font name if they are known to the system (eg via fc-cache).
You could load CMU Serif by filename
\setmainfont{cmunrm.otf}
For some fonts that is no problem and a convenient way to load fonts but the disadvantage of loading by filename is that fontspec can then not automatically infer variants such as bold and small caps, these can be specified individually to fontspec but for a large collection like CMU that is a pain.
Easier is to make the fonts available to the system, so xetex can load them by name. For example on my windows/cygwin setup I can just drag copies to c:/windows/fonts
, on a Mac you could install the fonts in /Library/Fonts
.
Or on systems using fc-cache you can tell fc-cache
to look in the texlive directories. If you save a file that looks like
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/usr/local/texlive/2016/texmf-dist/fonts/opentype</dir>
</fontconfig>
as
/etc/fonts/conf.d/09-texlive.conf
then run
sudo fc-cache -fsv
xetex will find the fonts.
The config file is a version of the file supplied in texlive as
/fonts/conf/texlive-fontconfig.conf
but restricted to opentype (the original had two extra lines for truetype and type1)
After all those preliminaries
\documentclass[a4paper]{article}
\usepackage{fontspec}
\setmainfont{CMU Serif}
%\setmainfont{cmunrm.otf}
\begin{document}
\begin{center}
{\bfseries Bold }
{\scshape Small Caps}
{\bfseries\scshape Bold Small Caps}
\end{center}
\end{document}
produces

(Thanks to egreg for help with some of the details here)
\usepackage[T1]{fontenc}
with\usepackage{fontspec}
and use a font which has bold smallcaps, e.g.\setmainfont{CMU Serif}
.CMU Serif
, and that I would like to use the default font, which I like so much.\usepackage[T1]{fontenc}
those font were available? Is it impossible to have them usingXeLaTeX
?\usepackage[T1]{fontenc}
in pdfLaTeX selects thecm-super
fonts. Unfortunately, T1 encoded fonts have the wrong mapping to be used with XeLaTeX. If in any way possible, you should use CMU Serif which is a slightly modified version ofcm-super
but with correct mapping.