[Tex/LaTex] \fontspec or \setmainfont do not load fonts from current directory

fontspeclinuxxetex

I am trying to use GARA.TFF (Garamond) in my latex document. \setmainfont can not find the font when I try to load it from the current directory. Here is the document:

\documentclass{article}
\usepackage{fontspec}
\begin{document}
    \setmainfont{GARA.TTF}
    Testfont
\end{document}

Directory contents:

drwxr-xr-x 2 reuter ids_s   4096 2011-06-09 16:39 .
drwxr-xr-x 4 reuter ids_s   4096 2011-06-09 16:38 ..
-rw-r--r-- 1 reuter ids_s 198072 2004-04-02 21:06 GARA.TTF
-rw-r--r-- 1 reuter ids_s    115 2011-06-09 16:39 test.tex

Output of xelatex test.tex:

[...]
fontspec.cfg loaded.
(/usr/share/texmf-texlive/tex/xelatex/fontspec/fontspec.cfg))
No file test.aux.

kpathsea: Running mktextfm GARA
/usr/share/texmf/web2c/mktexnam: Could not map source abbreviation G for GARA.
/usr/share/texmf/web2c/mktexnam: Need to update /usr/share/texmf-texlive/fonts/map/fontname/special.map?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input GARA
This is METAFONT, Version 2.718281 (TeX Live 2009/Debian)


kpathsea: Running mktexmf GARA
! I can't find file `GARA'.
<*> \mode:=ljfour; mag:=1; nonstopmode; input GARA

Please type another input file name
! Emergency stop.
<*> \mode:=ljfour; mag:=1; nonstopmode; input GARA

Transcript written on mfput.log.
grep: GARA.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input GARA' failed to make GARA.tfm.
kpathsea: Appending font creation commands to missfont.log.
! Font \zf@basefont=GARA.TTF at 10.0pt not loadable: Metric (TFM) file or insta
lled font not found.
\zf@fontspec ...ntname \zf@suffix " at \f@size pt 
                                                  \unless \ifzf@icu \zf@set@...
l.7 \setmainfont{GARA.TTF}

? 

I am at a loss. Is it supposed to strip the extension? I can succesfully load fonts that are installed. \setmainfont{Arial} works like a charm.

This is on Kubuntu, by the way.

Best Answer

It seems that you use a little old version of fontspec. Then try

\setmainfont{"[GARA.TTF]"} % with brackets, with or without quotes

The brackets means “use font file name.” This should work, like XeTeX primitive

\font\1="[GARA.TTF]" \1

In old versions of fontspec, one must use ExternalLocation option to specify a font with it's file name:

\setmainfont[ExternalLocation]{GARA.TTF}
% or something like \setmainfont[ExternalLocation=/usr/share/fonts/]{GARA.TTF}

This option can also used as Path in newer versions, and it is not necessary if no path is specified.