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.



\setmainfont{CMU Serif}

Test test2


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).

  • 2
    Welcome to TeX.SX! You seem to have a wrong font somewhere. Can you try running xelatex -output-driver="xdvipdfmx -v" file (where file is your file name, of course) and add the final part of the console output? Chances are that you'll be able to spot what goes wrong. What OS are you on? And what TeX distribution? – egreg Feb 27 '16 at 23:00
  • Thanks for the help :). See the edit for more information. – BrtH Feb 27 '16 at 23:15
  • There's nothing at the pastebin for the console output – egreg Feb 27 '16 at 23:27
  • Oh, strange. A new one: pastebin.com/CaHy2UFB. It's not all that interesting though. – BrtH Feb 27 '16 at 23:30
  • No, apparently the relevant information is not shown. Unfortunately I can't test MiKTeX. – egreg Feb 27 '16 at 23:32

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


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

  • 1
    Commenting out <dir>C:\MiKTeX-2.9\fonts\type1</dir> in C:\Users\username\AppData\Roaming\MiKTeX\2.9\fontconfig\config\localfonts.conf indeed solved the problem. Thanks! However, the file says "DO NOT EDIT THIS FILE! (...) Instead, edit the configuration file localfonts2.conf.". But the file localfonts2.conf only specifies extra folders to add, not folders to delete, as far as I can tell. Would you know of an option to permanently disable a folder? – BrtH Feb 28 '16 at 13:14

I checked your file. It works and gives the right result.

\setmainfont{CMU Serif Extra}
\noindent Test test2 \\
12345 \\
\setmainfont{CMU Serif}
Test test2 \\

Check: MiKTeX Options -> Formats -> xelatex (non exclude) -> Build. Further:

Update Formats, Refresh FNDB. There should be no errors. Else, try logging in as admin.

My setup: This is XeTeX, Version 3.14159265-2.6-0.99998 (MiKTeX 2.9.6500 64-bit)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.