# kpathsea/fontspec does not recognize a font whose name has a space in it

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.

-
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
@alfC Sometimes fonts in linux don't get registered and you need to load them using the filename. See Figuring out Xetex fonts under Debian perhaps? – Alan Munn Sep 10 at 20:57

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.

-