[Tex/LaTex] Weird spacing with DejaVu Sans Mono with MiKTeX’s XeLaTeX

fontspecletterspacingmiktextypewriterxetex

\documentclass{article}
\usepackage{fontspec}
    \setmainfont{DejaVu Serif}
    \setsansfont{DejaVu Sans}
    \setmonofont{DejaVu Sans Mono}
\begin{document}
Hello World!

\textsf{Hello World!}

\texttt{Hello World!}
\end{document}

compiled with XeLaTeX gives me this:

XeLaTeX output

Copying the output with SumatraPDF even shows regular space characters between the letters and a line break between the words:

Hello World!
Hello World!
H e l l o
W o r l d !

(Copying it with Adobe Reader XI Win, however, yields three identical lines.)

This problem doesn't occur with LuaLaTeX:

LuaLaTeX output

The OCR-layer-text for LuaLaTeX is flawless as well, using either PDF viewer.

I assume this is a XeTeX bug? Can I circumvent it somehow?

I'm using MiKTeX 2.9, and version 2.33 of the DejaVu fonts, which I think came preinstalled with Windows (7), at least I can't recall manually installing these fonts. This version seems to be the current version, at any rate.

P.S.: If someone can recommend another monospaced font for code that a) goes well with Linux Libertine and b) contains lowercase Greek letters, that'd be helpful, too. But that just as an aside :).

Best Answer

Have you tried specifying the fonts in more detail? I've tested the following in MiKTeX 2.9 without a problem.

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{
    Extension      = .ttf ,
    Ligatures      = TeX ,
    UprightFont    = * ,
    ItalicFont     = *-Oblique ,
    BoldFont       = *-Bold ,
    BoldItalicFont = *-BoldOblique
}
\setmainfont[ItalicFont = *-Italic, BoldItalicFont = *-BoldItalic]{DejaVuSerif}
\setsansfont{DejaVuSans}
\setmonofont{DejaVuSansMono}

\begin{document}
Hello World!

\textsf{Hello World!}

\texttt{Hello World!}
\end{document}

You do need to have the dejavu package installed.

Related Question