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.

Using XeLaTeX and the fontspec package, I am experiencing problems using fonts whose name includes the space character. Here is a simple example:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\begin{document}\end{document}

gives, upon xelatex the error:

kpathsea: Invalid fontname `Times New Roman', contains ' '

I have used this font before and previously working examples ceased to work when I re-installed my operating system (Ubuntu 11.04) and TeXlive2011.

share|improve this question
1  
This error usually arises when fontspec fails to find the font at all. Are you sure that the font is available still on your system? (Can you use it a regular application like Open Office?) –  Alan Munn Feb 1 '12 at 4:11
    
The font is indeed missing on OpenOffice. The error message is quite misleading. –  Yossi Gil Feb 1 '12 at 5:40
    
On my system, fontspec gives a very helpful error right after the error you mention. Maybe you're not seeing the whole thing. It clearly says fontspec error: "font-not-found" (etc.) –  Alan Munn Feb 1 '12 at 5:43
    
I've turned my comments into an answer. –  Alan Munn Feb 1 '12 at 5:49
    
@Marc: It is a good advice to avoid file names with spaces, but the problem here is about a font name. This font name is simply a string stored in the font and XeTeX can/should handle such names without problem. –  Ulrike Fischer Feb 1 '12 at 8:43
show 2 more comments

1 Answer

up vote 4 down vote accepted

The error you are seeing usually arises when fontspec can't find the font at all. It is usually accompanied by the following more helpful error generated by fontspec itself:

kpathsea: Invalid fontname `A Funny Font', contains ' '


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
./kpathsea-test.tex:4: fontspec error: "font-not-found"
! 
! The font "A Funny Font" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.4 \setmainfont{A Funny Font}

Maybe your editing environment is hiding some of the console output from you.

Any font that is usable on your system in a regular application (e.g. Open Office) should be found by fontspec. So you should check to see if "Times New Roman" is actually available on your system after your OS update.

share|improve this answer
add comment

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.