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.

I can't seem to get XeLaTeX to load OpenType fonts using \fontspec. Section 4.2 of the fontspec documentation says that I need to load OpenType fonts by filename rather than font name, but when I compile the following:

\documentclass[letterpaper]{scrartcl}

    \usepackage{xltxtra}

    \fontspec[Path = /home/[MYHOME]/.fonts/]{lmroman10-regular.otf}
    \begin{document}

    0123456789.

    The quick brown fox jumped over the lazy dogs.

    ``firefly''

    \end{document}

XeLaTeX generates the following errors:

 [XeLaTeX] finished with exit code 1

./xelatexbase.tex:12:Undefined control sequence ... /home/[MYHOME]/.fonts/{lmroman10-regular.otf}

./xelatexbase.tex:12:Package xkeval Error: 'Path' undefined in families 'options' ... /home/[MYHOME]/.fonts/ 

I've verified that lmroman10-regular.otf is in /home/[MYHOME]/.fonts/. I must be doing something wrong with the Path argument, and I suspect it's something simple, but I don't see what.

I've posted the minimal example that generates this error, but documents using \fontspec with arguments that more closely track the examples in section 4 of the documentation do the same. The document compiles when I comment out \fontspec.

This on Ubuntu 10.10 with the latest full installation of TexLive from the repositories.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

It works for me with a fully updated Tex Live 2010. Do not use the Ubuntu texlive packages when you want to use fontspec (or any other modern packages). The version in Ubuntu are now more than a year and a half old, and thus have many bugs that have long since been fixed. Install TeX Live directly.

There are a few other things worth pointing out:

  • The manual says (in section 4.2)

    [You may have fonts outside of] your system’s font directories.

    As ~/.fonts is a system font directory, you can load fonts by name from there.

  • I think fontspec loads the Latin Modern fonts by default. If you want to load them explicitly it is more convenient to load them from your systems TEXMF tree (TeX Live should include those fonts).

  • \fontspec in the preamble doesn't affect anything, as it changes the current font, and there is no current font in the preamble. Use \setmainfont instead.
  • In summary, to load the LM Roman 10 font explicitly from the TeX Live font dirs you should use

    \setmainfont[
      Extension = .otf,
      UprightFont = *-regular,
      BoldFont = *-bold,
      ItalicFont = *-italic,
      BoldItalicFont = *-bolditalic,
    ]{lmroman10}
    

    Note that the TeX Live font directories are searched automatically. You should probably do analogous things with \setsansfont and \setmonofont. Also, you will probably want to add the Ligatures=TeX option.

[Remark: XeLaTeX from MikTeX and LuaLaTeX on all systems can load fonts from the TEXMF tree by name.]

share|improve this answer
    
Thanks very much. The direct install sounds like the answer. I'll try it right away. And you're right, Latin Modern is loaded by default. I used Latin Modern here because I took the remark in Section 4.2 about the need to specify OpenType fonts by filename even if they were present in the TeX distribution to apply to OpenType fonts in system font directories as well. If I don't have to specify OpenType fonts in the system directories by filename, that's great, though I want to make sure I can if I need to. For now, even the \setmainfont example above spits out xkeyval errors. –  Tom Mar 22 '11 at 4:50

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.