I use the following code to set up the font:
\setmainfont{texgyrecursor-regular.otf}[Ligatures=NoCommon]
However, when I use the font name TeX Gyre Cursor instead of the file name texgyrecursor-regular.otf, fontspec will give an error:
kpathsea:make_tex: Invalid fontname `TeX Gyre Cursor', contains ' '
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "TeX Gyre Cursor" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.4 ...infont{TeX Gyre Cursor}[Ligatures=NoCommon]
kpathsea:make_tex: Invalid fontname `TeX Gyre Cursor', contains ' '
kpathsea:make_tex: Invalid fontname `TeX Gyre Cursor', contains ' '
kpathsea:make_tex: Invalid fontname `TeX Gyre Cursor/BI', contains ' '
kpathsea:make_tex: Invalid fontname `TeX Gyre Cursor', contains ' '
kpathsea:make_tex: Invalid fontname `TeX Gyre Cursor/B', contains ' '
kpathsea:make_tex: Invalid fontname `TeX Gyre Cursor', contains ' '
kpathsea:make_tex: Invalid fontname `TeX Gyre Cursor/I', contains ' '
kpathsea:make_tex: Invalid fontname `TeX Gyre Cursor', contains ' '
I use XeLaTeX on Linux. By the way, when compiling on Windows, there will not be this error.
MWE:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Cursor}[Ligatures=NoCommon]
\begin{document}
Hello, world!
\end{document}
Another related question is that, when font name and file name are both OK, which one is better? Is there any differences on compiling efficiency?
fontspeccan't find the font, but can't find the font via its family nameTeX Gyre Cursor... – stone-zeng Jul 22 '17 at 15:37fontconfigcan find them. What doesfc-match "TeX Gyre Cursor"give? If it fails to find the font, then the font is not in a directoryfontconfigsearches and you cannot call the font by family name in Xe/LuaTeX. – cfr Jul 22 '17 at 17:46