44

How can I use the Calibri font in LaTeX? I am using the following commands:

\usepackage{fontspec}
\setmainfont{Calibri}

I get the following error message:

!   Fatal fontspec error: "cannot-use-pdftex"
!   The fontspec package requires either XeTeX or LuaTeX to function.
!   You must change your typesetting engine to, e.g., "xelatex" or "lualatex"  
!   instead of plain "latex" or "pdflatex".
! 
!    See the fontspec documentation for further information.
3
  • 2
    The error message indicates that you should use XeTeX, LuaTeX or even XeLaTeX! I was once trying to do the same, but never managed to do so, without XeLaTeX. Which editor are you using?
    – Thanos
    Feb 6, 2013 at 7:46
  • i m using pdflatex. So far it is best for me.
    – manish
    Feb 6, 2013 at 8:36
  • 4
    Then you can't use fontspec and can't select the fonts which are only installed on your system. You have to stick to the fonts you install in LaTeX.
    – Juri Robl
    Feb 6, 2013 at 8:38

3 Answers 3

39

As others have pointed out in comments, to use system fonts (or any local .otf or .ttf font) easily, you need to use the fontspec package and compile your document with either xelatex or lualatex. pdflatex won't work, but switching to xelatex or lualatex shouldn't require any major change in your document other than converting to utf8 encoding and removing any \usepackage[...]{inputenc}.

FYI, lualatex is the official successor of pdflatex in LaTeX3, and I personally see very little reasons not to switch asap to lualatex. If you want to read more on the differences, these links might provide you some more background:

Now, if you really can't / do not want to switch to xelatex or lualatex, and if you are really brave, you can stay with pdflatex, convert your Calibri font to Type1 and make it available to TeX. The tedious process is explained here.

6
  • if i use lualtex, formatting gets changed. Everything looks unorganized and font still remain the same.
    – manish
    Feb 8, 2013 at 1:33
  • 1
    lualatex (not lualtex) should not change the formatting, and should change the font properly with the 2 lines you wrote in your question. Have a look at the log file for errors, and post another question if there is something else you don't understand. It's nearly impossible to help you without a MWE or your log file...
    – Xavier
    Feb 8, 2013 at 4:09
  • i have posted my question tex.stackexchange.com/questions/97288/…
    – manish
    Feb 8, 2013 at 6:47
  • The error message here is different, even when I compile with lualatex, the font is not found. I've downloaded the Calibri font and installed on Ubuntu with a double-click. Any hint?
    – juliohm
    Sep 20, 2013 at 1:00
  • The link above has the answer, just create a folder in /usr/share/fonts/truetype with all *.ttf files for Calibri.
    – juliohm
    Sep 20, 2013 at 1:11
8

Had the same problem and solved it in the following way:

  1. Obtain your properly licensed Calibri .ttf font files. For the Calibri-family these are four files: Regular calibri.ttf, Bold calibrib.ttf, Bold-Italic calibriz.ttf, ItalicFont calibrii.ttf.
  2. Place them in your OS's truetype font directory in their own folder. For Ubuntu the path would be "/usr/share/fonts/truetype/calibri/"
  3. As Xavier mentioned you use LuaLaTeX with the fontspec package to specify the Calibri font family:

    \usepackage{fontspec}
    \setmainfont[Path=/usr/share/fonts/truetype/calibri/,
        BoldItalicFont=calibriz.ttf,
        BoldFont      =calibrib.ttf,
        ItalicFont    =calibrii.ttf]{calibri.ttf}
    
2
  • 3
    Note that if you have Calibri installed correctly in your system (see fc-list), this is not needed and you should be able to just do \setmainfont{Calibri} and it will choose all the correct variants. But this is useful anyways if you use e.g. Overleaf or have the fonts in the CWD not globally.
    – phiresky
    May 18, 2021 at 13:20
  • Also make sure that you add the trailing slash when supplying the path if using this method.
    – Rich_Rich
    Mar 19 at 15:58
4

When switching to lualatex or XeTeX is not an option, there is a metrically compatible font named Carlito that can replace Calibri.

There is the package

\usepackage[sfdefault]{carlito}

that makes Carlito the default font.

You must log in to answer this question.

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