I was struggling to use OpenSans in a document, I tried using the \setsansfont command as follows

\setmainfont{TeX Gyre Termes} % OK
\setsansfont{Open Sans}       % ERROR!

But it gave me the following errors:

Package fontspec Error: The font "Open Sans" cannot be found. ]
Package fontspec Error: The font "Open Sans" cannot be found. ]
Package fontspec Error: The font "Open Sans" cannot be found. ]
Font TU/OpenSans(0)/m/n/45="Open Sans" at 45.0pt not loadable: Metric (TFM) file or installed font not found. ^^I^^I}
Font TU/OpenSans(0)/m/n/28="Open Sans" at 28.0pt not loadable: Metric (TFM) file or installed font not found. ^^I^^I}
Font TU/OpenSans(0)/b/n/28="Open Sans" at 28.0pt not loadable: Metric (TFM) file or installed font not found. ^^I^^I}
Font TU/OpenSans(0)/b/n/11="Open Sans" at 11.0pt not loadable: Metric (TFM) file or installed font not found. ^^I^^I}

3 Answers 3


You should be able to do this with:


On LuaLaTeX or XeLaTeX, the documentation says that this will set the OpenType version of Open Sans as the sans-serif font.

If you want to be able to switch to Open Sans, but set another sans-serif font, you can load the package as above, with the options you want, \setsansfont to something else, and use the \fosfamily command to select Open Sans.

  • Thanks. It works well, btw it also makes \setsansfont{Open Sans} work, if I wanted to add open sans not as the defaultsans but in small text decorations it can be archived with \newfontfamily{\OSans}{Open Sans} \DeclareTextFontCommand{\OpenSans}{\OSans} and \OpenSans{text....} will do the trick. Commented Sep 26, 2021 at 22:53
  • @MiguelAvila Didn’t realize that’s what you wanted. The package provides a \fosfamily command for that.
    – Davislor
    Commented Sep 26, 2021 at 23:46

The cause is that XeLaTeX is expecting the font to be installed in the system but it can't be found. So, what you have to do in order to specify XeLaTeX the font is to use the option list provided in the \setsansfont command as follows:

\setmainfont{TeX Gyre Termes}

    Extension = .ttf,

It works now because:

  • Open Sans in my case is stored with .ttf format
  • It happens that we have to specify the font file names, for example: OpenSans-Regular.ttf
  • The Open Sans family is composed of various styles, so, in order to load those styles you must specify which ones you are loading.

Note: This answer assumes that you are using Overleaf or MiKTeX with the opensans package installed or TeXLive with fonts-extra

Hope it helps you!

  • 2
    The first part is a bit misleading: The original code is not necessarily expecting a tfm font, it also would use a ttf or otf font. But XeTeX only considers system fonts when searching with the font name instead of the file name, so it would only work if the font were installed as a system font and not just for TeX Live. Commented Sep 26, 2021 at 4:11
  • @MarcelKrüger Thanks to point it out, I didn't know it was so. I came to that conclusion by reading the error log. Commented Sep 26, 2021 at 5:56
  • 3
    Right, the error message is rather misleading. It's basically a historical artifact: If the new ways of looking for fonts in XeTeX (searching by font name and file name) do not find anything, they fall back to the old TFM loader. (That's necessary since the primitive TeX interface for both tyoes of fonts is the same, so XeTeX doesn't know what kind of font you are trying to load.) Now if no TFM font is found either, the old TFM code is printing the old TFM error message which was written for a system which didn't know any other fonts. Commented Sep 26, 2021 at 6:16
  • 1
    also texlive comes with a fontconfig file so that fontconfig (and so xetex) will find fonts in the texlive tree by name. Commented Sep 26, 2021 at 9:21

As the other answers have said you can access the font by filename but the original code will work without error if xetex is configured suitably.

enter image description here



\setmainfont{TeX Gyre Termes} % OK
\setsansfont{Open Sans}       % No ERROR!


ABC xyz \textsf{ABC xyz}


As explained in the texlive manual xetex used fontconfig to locate fonts called by the internal font name. By default fontconfig looks in your system font directories but does not know about texlive fonts. Texlive is distributed with a fontconfig configuration file that you may use to configure config. The details depend on how your system font searching is set up but in my case I have copied a slightly edited version of that file to


so that it contains

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">

which means that my (cygwin) xetex will find all the texlive and Windows system fonts in addition to all the cygwin supplied fonts.

  • In my case this file doesn't exist, I think it was cause of the problem. By other side, LuaLaTeX found the font with the use of \setsansfont{Open Sans}. Commented Sep 26, 2021 at 22:44
  • @MiguelAvila yes that is what I meant, you need to make that file (the location may vary depending on your system fontconfig). Texlive supplies a fontconfig file for that purpose installed at /usr/local/texlive/2021/texmf-var/fonts/conf/texlive-fontconfig.conf or equivalent place but it is not added to the fontconfig by default you need to do that post install. Luatex does not use fontconfig so does not require this setuo Commented Sep 27, 2021 at 6:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .