24

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.
  • 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 '13 at 7:46
  • i m using pdflatex. So far it is best for me. – manish Feb 6 '13 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 '13 at 8:38
30

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.

  • if i use lualtex, formatting gets changed. Everything looks unorganized and font still remain the same. – manish Feb 8 '13 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 '13 at 4:09
  • i have posted my question tex.stackexchange.com/questions/97288/… – manish Feb 8 '13 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 '13 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 '13 at 1:11
2

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}
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.