2

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?

stone-zeng
  • 2,710
  • Is your fontspec up-to-date? – Ulrike Fischer Jul 22 '17 at 14:32
  • I use v2.6b, updated on 2017/07/16. – stone-zeng Jul 22 '17 at 15:05
  • 1
    Did you add the texmf trees to your fontconfig? https://www.tug.org/texlive/doc/texlive-en/texlive-en.html#x1-340003.4.4, https://tex.stackexchange.com/questions/257231/using-the-tex-live-fonts-in-xelatex – Ulrike Fischer Jul 22 '17 at 15:18
  • @UlrikeFischer The problem is not that fontspec can't find the font, but can't find the font via its family name TeX Gyre Cursor... – stone-zeng Jul 22 '17 at 15:37
  • 3
    Yes I know. Xelatex on linux can find fonts only by filename in the texmf trees if you don't add the trees to your font config. See the docu I linked too. – Ulrike Fischer Jul 22 '17 at 15:50
  • Unless you have the fonts also installed independently where fontconfig can find them. What does fc-match "TeX Gyre Cursor" give? If it fails to find the font, then the font is not in a directory fontconfig searches and you cannot call the font by family name in Xe/LuaTeX. – cfr Jul 22 '17 at 17:46

0 Answers0