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.
Stephen
  • 14,890
manish
  • 9,111
  • 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 06 '13 at 07:46
  • i m using pdflatex. So far it is best for me. – manish Feb 06 '13 at 08: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 06 '13 at 08:38

3 Answers3

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.

Xavier
  • 13,947
  • if i use lualtex, formatting gets changed. Everything looks unorganized and font still remain the same. – manish Feb 08 '13 at 01: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 08 '13 at 04:09
  • i have posted my question http://tex.stackexchange.com/questions/97288/lualatex-fontspec-font-not-found – manish Feb 08 '13 at 06: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 '13 at 01: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 '13 at 01:11
  • Is this compatible with latexmk? Thanks. – tommy.carstensen Nov 16 '17 at 17:03
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}
    
GJacobs
  • 81
  • 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 '21 at 13:20
  • Also make sure that you add the trailing slash when supplying the path if using this method. – Rich_Rich Mar 19 '24 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.