# Xetex: use OTF font (MacPorts)

I have a problem using my own OTF fonts within a LaTeX document. I read I should compile the document with xelatex which I have installed on my Mac with MacPorts (package texlive-xetex)

My minimal document looks like this:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Arial}

\begin{document}
Lorem ipsum
\end{document}


Compiling it via xelatex test.tex I get the following errors:

This is XeTeX, Version 3.1415926-2.4-0.9998 (TeX Live 2012/MacPorts 2012_5)
restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, lo
(/opt/local/share/texmf-texlive-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/opt/local/share/texmf-texlive-dist/tex/latex/base/size10.clo))
(/opt/local/share/texmf-texlive-dist/tex/latex/fontspec/fontspec.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/expl3.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3names.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3bootstrap.sty))
(/opt/local/share/texmf-texlive-dist/tex/latex/etex-pkg/etex.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/graphics/color.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/latexconfig/color.cfg)
(/opt/local/share/texmf-texlive-dist/tex/xelatex/xetex-def/xetex.def))
(/opt/local/share/texmf-texlive-dist/tex/latex/graphics/graphics.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/graphics/trig.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/latexconfig/graphics.cfg))
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3basics.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3expan.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3tl.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3seq.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3int.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3quark.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3prg.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3clist.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3token.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3prop.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3msg.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3file.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3skip.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3keys.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3fp.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3box.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3coffins.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3color.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/l3kernel/l3luatex.sty))
(/opt/local/share/texmf-texlive-dist/tex/latex/l3packages/xparse/xparse.sty)
(/opt/local/share/texmf-texlive-dist/tex/latex/fontspec/fontspec-patches.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/base/fixltx2e.sty)
*************************************************
* LaTeX warning: "xparse/redefine-command"
*
* Redefining document command \oldstylenums with arg. spec. 'm' on line 107.
*************************************************
) (/opt/local/share/texmf-texlive-dist/tex/latex/fontspec/fontspec-xetex.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/base/fontenc.sty
(/opt/local/share/texmf-texlive-dist/tex/latex/euenc/eu1enc.def)
(/opt/local/share/texmf-texlive-dist/tex/latex/euenc/eu1lmr.fd)kpathsea: Invalid fontname [lmroman10-regular]', contains '['

! Font EU1/lmr/m/n/10=[lmroman10-regular]:mapping=tex-text at 10.0pt not loadab
relax
l.100 \fontencoding\encodingdefault\selectfont


What am I doing wrong? I also tried to specify the whole path to my font with \setmainfont[Path=/Absolute/Path/To/My/OTF/Font/]{file.otf} in the preamble.

Although I would prefer using pdftex instead of xelatex because I read that xelatex comes with some disadvantages and I do not want to install it on every computer I use it. Is there a good solution for using OTF fonts with pdftex?

-

What am I doing wrong?

The Minimum Working Example you provided is the correct way to use OpenType fonts with LaTeX. However, you're probably missing some part of TeX Live.

The solution would be one of the following:

• Install MacTeX.
• Install the following MacPorts packages: texlive-basic, texlive-fonts-extra and texlive-fonts-recommended.

I recommend the first option, but the second one should also work (if you really want to do this through MacPorts).

Is there a good solution for using OTF fonts with pdftex?

Unless you want to convert them to Type 1 fonts, I'm afraid not. Luckily there are a lot of people doing the converting for you. You can find a lot of fonts that can be used for pdfLaTeX in The LaTeX Font Catalogue.

-
I second this advice. I'm not quite sure why you've installed the MacPorts version of TeX; you'll probably have far fewer headaches with the regular MacTeX distribution. That being said, XeTeX assumes that your fonts are in the usual place for fonts on the Mac: either /Library/Fonts or ~/Library/Fonts`. But the error you're getting is because you're missing fonts in your distribution as Silex notes in the second bullet point. –  Alan Munn Jan 16 '13 at 1:42
You were right, I really was missing one of the packages you listed above. Thank you! :) –  Jan Mar 13 '13 at 14:38