[Tex/LaTex] XeLaTeX + \setmainfont{CMU Serif} produces wrong characters

characterscomputer-modernfontsfontspecxetex

When I'm compiling with XeLaTeX and I use \setmainfont{CMU Serif}, the resulting characters are off by one. This means that an a becomes a b, a 1 becomes a 2, etc.

\documentclass{article}

\usepackage{fontspec}

\setmainfont{CMU Serif}


\begin{document}
Test test2

12345
\end{document}

Wrong output

However, when I use \setmainfont{cmunrm.otf}, using the filename, the output is correct:

Correct output

When I use \setmainfont{CMU Sans Serif}, the output is also correct, but if I use \setmainfont{CMU Serif Extra}, for example, the output is wrong again, so it seems that there's something wrong with the Serif CMU fonts?

What causes this, and how can I solve it?

Edit: The console output after running xelatex -output-driver="xdvipdfmx -v" test.tex is at http://pastebin.com/nb19aPuc.The log at http://pastebin.com/qgSC07YY. Interesting stuff seems to begin around line 349.

The output of fc-list | grep 'CMU Serif' (http://pastebin.com/BNWzyRkH) seems to suggest that there's not something wrong with the installation of the font.

I'm running MikTex 2.9 on Windows 10 x64, with all packages updated to the latest version (at least, according to the MikTex update tool).

Best Answer

Probably type1 fonts are used as native fonts. The old xdvipdfmx was broken for native type1 fonts. In the upcoming xdvipdfmx, which will be in TeX Live 2016, the bugs are fixed. In any case, even in the case of the new xdvipdfmx in which the bugs are fixed, I recommend you to hide

C:/MiKTeX-2.9/fonts/type1

for fontconfig. If you hide the type1 fonts, you will obtain required results even by using the broken xdvipdfmx.