Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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 :).

share|improve this question
    
I have no problem on my Mac. –  egreg Nov 28 '12 at 20:59
    
No problem here either (TeX Live on Linux). –  Khaled Hosny Nov 28 '12 at 22:03
    
A friend compiled my MWE on his MiKTeX 2.9 system and got the same result as I, so it might be MiKTeX-specific behavior? (Wouldn't surprise me for that kind of issue, intuitively.) –  doncherry Nov 28 '12 at 22:20
2  
I confirm the behavior with MiKTeX. It seems it is MiKTeX specific. –  Harish Kumar Nov 28 '12 at 22:41
    
I have no problem with MikTeX 2.9, Win 7 but fresh downloads from the SF page of DeJaVu project. –  percusse Nov 28 '12 at 23:50

2 Answers 2

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.

share|improve this answer
    
Silke, when the package dejavu not is installed, the font files will anyway only be found in the Windows fonts folder. The problem arises, when the package is installed, and perhaps no DejaVu font files in the Windows folder are existent. –  Speravir Nov 29 '12 at 19:13
    
Thanks! This works indeed, but I accepted my own answer because it solves the problem globally. (Also, sorry for the late response, I was pretty tied up the past weeks.) –  doncherry Dec 21 '12 at 22:21
up vote 2 down vote accepted

The problem turned out to be more or less the same as in \setmainfont{Linux Libertine O} uses pfb files instead of otf: XeLaTeX didn't even use the Windows fonts, but the ones in the texmf tree (which for some reason seem to be flawed). The solution is the same as for the other question: Tell MiKTeX not to use those.

Here's how to do that:

Open your localfonts2.conf file. You may have several versions of this file in different places; the one that works for me is in C:\Users\doncherry\AppData\Roaming\MiKTeX\2.9\fontconfig\config (“Admin” MiKTeX installation). The file should look like this:

<?xml version="1.0"?>
<fontconfig>
  <selectfont>
    <rejectfont>
      <glob>C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/dejavu/*</glob>
    </rejectfont>
  </selectfont>
</fontconfig>

With this configuration, everything works for me. According to Khaled Hosny, this specification will not be necessary anymore in the future, perhaps in MiKTeX 3.0.


Update:

While not using the Type1 fonts makes the problem go away, the Type 1 fonts still were buggy somehow. I contacted the author of the dejavu package; he identified the problem (too big Em Size) and said it would be fixed in a future version of the package.

share|improve this answer
    
The path written with a system variable: %APPDATA%\MiKTeX\2.9\fontconfig\config – and in a single user installation it is the same path. –  Speravir Dec 21 '12 at 22:45
    
Speaking of a new XeTeX version in MiKTeX: If we are lucky, we do not need to wait until MiKTeX 3.0, cf. my bug report XeLaTeX call strips parentheses in file name. –  Speravir Dec 21 '12 at 22:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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