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 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.

share|improve this question
    
And welcome to TeX.SE! –  ℝaphink Jun 9 '11 at 14:52
    
It works fine for me (windows, miktex 2.9). \setmainfont{Artbrush.ttf} includes Artbrush.ttf from the current folder (it doesn't work if I use the font name instead of the file name). But it is possible that it doesn't work in TeXLive. On the other side your TeXLive is quite old and so probably also your fontspec. Perhaps you need the ExternalLocation option or something like this. –  Ulrike Fischer Jun 9 '11 at 15:11
    
See also this question: Load fonts that are in a ./fonts directory –  Alan Munn Jun 9 '11 at 16:34

2 Answers 2

up vote 11 down vote accepted

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.

share|improve this answer
    
Is the manual wrong then? –  ℝaphink Jun 9 '11 at 15:14
    
@Raphink: No. The document on CTAN is quite new, but the package in your computer may be old. You can look at the manual in your own computer to see how fontspec works in that version. (At /usr/share/texmf-texlive/doc/..., I'm not sure.) BTW, the use of brackets is low-level XeTeX syntax. –  Leo Liu Jun 9 '11 at 15:21
    
Although the brackets did not work, your comment pointed me in the right direction. The correct syntax on my system is \setmainfont[ExternalLocation]{GARA.TTF}. If you add the hint with the documentation to your answer, I'll accept it. –  TheFogger Jun 9 '11 at 15:52
1  
@TheFogger ebian and Ubuntu still contain TeX Live 2009. fontspec has been significantly improved since then. If you want updated packages, I would recommend to install TeX Live directly from TUG instead of using the Debian packages. That way you can always get current package versions by running sudo tlmgr update --all. –  Caramdir Jun 9 '11 at 15:58
    
@TheFogger: We use brackets for this purpose in ctex package since May 2009 (TeX Live 2008) until now. I've just tested fontspec v1.18 in TUG's TeX Live 2009 on an Ubuntu vitual machine, and this syntax still works on my computer. I guess there're still some questions, but I can't point out where it is. –  Leo Liu Jun 9 '11 at 16:32

You have to install the font in your system:

$ sudo mkdir -p /usr/local/share/fonts # Create directory if it doesn't exist
$ sudo cp GARA.TTF /usr/local/share/fonts/ # Copy the font there
$ sudo fc-cache /usr/local/share/fonts/ # Update font cache
$ fc-list | grep -i garamond # Check it's there

and it should work, using the font name as given in fc-list. For example, if fc-list says:

$ fc-list | grep -i garamond
Garamond LT:style=Italic
Garamond LT:style=Regular

Then use:

\setmainfont{Garamond LT}
share|improve this answer
    
Having to install the font would be unfortunate. I do not want to install the fonts, because I may have to compile the document on different systems. The fontspec documentation [mirror.ctan.org/macros/latex/contrib/fontspec/fontspec.pdf] states on page 6 that you can also load the fonts from the current directory, or any directory in fact. –  TheFogger Jun 9 '11 at 15:03
    
Ah, I hadn't read that part of the manual :-) That said, I get the same error as you with a TTF. –  ℝaphink Jun 9 '11 at 15:12

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.