Custom font in Overleaf with pdfLaTeX compiler

fontsoverleafpdftextitlesec

I am creating a chapter report template in LaTeX that will be used by others, mostly in Overleaf. There are requirements for fonts, etc. that are in a Word template that I am coding into a LaTeX template.

There are a few questions on StackExchange here about how to use a custom font in Overleaf. Many suggest using the XeLaTeX compiler which is too slow. I want to use pdfLaTeX.

Overleaf has instructions here and here on how to use a custom font with pdfLaTeX, and and answer to LuaLaTeX + fontspec: Font not found also has some tips, but I am still stuck.

Code

\documentclass{report}
\usepackage{lipsum}

% from Overleaf example at https://www.overleaf.com/project/61800a1dd7200c9a50af629b
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\newcommand\customfont[1]{{\usefont{T1}{fonts/calibri}{m}{n} #1 }}


\title{template}
\author{none}
\date{November 2021}

\begin{document}

\maketitle

\chapter{Introduction}
\Huge\customfont{Custom Font Text!}

\section{Section}
\lipsum[1]

\subsection{Subsection}

\end{document}

Project Setup

enter image description here

Current Output

enter image description here

Expected Output

  1. I don't understand the missing number error. I am new to LaTeX and not sure what number is expected and where.
  2. The text reads "n/24.88n/ …"– I expected it to read "Custom Font Text!" and be in Calibri font, not the default font.
  3. Following text remained "Huge", and I expected it to return to the default

End Goal

I am trying to set the chapter and section headers to Calibri font, in Report document class, with pdfLaTeX compiler. I expect to use something like this in my preamble:

\usepackage{titlesec}
\titleformat{\chapter}{\customfont\fontsize{12}{14}\bfseries}{\thechapter}{1em}{}

Open to suggestions on a better way to do this. Thank you

Best Answer

Note also that calibri isn't licenced for use off windows (unless you have bought it) you can use the chrome OS font clone carlito which uses the same font metrics as calibri and has already been set up for use with pdflatex with the carlito package.

https://ctan.org/pkg/carlito

Related Question