[Tex/LaTex] kpathsea/fontspec does not recognize a font whose name has a space in it

fontsfontspecxetex

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.

Best Answer

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.