Documentation/Fonts/How to Install and Use a Custom Font in LaTeX
Fonts

How to Install and Use a Custom Font in LaTeX

Sometimes the built-in LaTeX font packages aren't enough — you need a specific corporate font, a designer typeface, or a font you've downloaded. With XeLaTeX or LuaLaTeX and the fontspec package, you can use any TrueType (.ttf) or OpenType (.otf) font installed on your system or placed in your project folder. Bibby AI supports XeLaTeX compilation natively, so you can upload custom fonts to your project and use them immediately — no server configuration required, unlike Overleaf which restricts font file uploads on free plans.

Install the Font and Set Up fontspec

Place your font files in the project directory (or install system-wide) and load them with fontspec. This requires compiling with XeLaTeX or LuaLaTeX:

% Compile with: xelatex or lualatex
\documentclass{article}
\usepackage{fontspec}

% Use a system-installed font by name
\setmainfont{Garamond}
\setsansfont{Fira Sans}
\setmonofont{Fira Code}

\begin{document}
This text is in Garamond. {\sffamily This is Fira Sans.}

{\ttfamily This is Fira Code for listings.}
\end{document}

Load Font Files from Your Project Directory

If the font isn't installed system-wide, point fontspec to the .ttf or .otf files in your project using the Path option:

\documentclass{article}
\usepackage{fontspec}

% Load from a 'fonts/' subfolder in your project
\setmainfont{MyCustomFont}[
    Path = ./fonts/,
    Extension = .otf,
    UprightFont = *-Regular,
    BoldFont = *-Bold,
    ItalicFont = *-Italic,
    BoldItalicFont = *-BoldItalic
]

\begin{document}
This uses your custom font. \textbf{Bold works.} \textit{Italic too.}
\end{document}

Configure OpenType Features

OpenType fonts support advanced features like ligatures, old-style numbers, and small caps. Enable them via fontspec options:

\documentclass{article}
\usepackage{fontspec}

\setmainfont{EB Garamond}[
    Ligatures = TeX,           % Enable TeX-style ligatures (-- → en-dash)
    Numbers = OldStyle,        % Use old-style (lowercase) numerals
    SmallCapsFont = {EB Garamond SC},
]

\begin{document}
Numbers: 0123456789. Ligatures: ``quotes'' and fi, ffl.

\textsc{Small Caps Text Here}.

En-dash: 10--20. Em-dash: yes---really.
\end{document}

💡 Tips

  • Always compile with xelatex or lualatex when using fontspec — pdflatex does not support it.
  • Place font files in a fonts/ subfolder and use the Path option for portability across machines.
  • If a font lacks a bold or italic variant, fontspec will synthesize one, but the result may look poor — check the log for warnings.
  • On Bibby AI, upload your .otf or .ttf files directly to the project and they'll be available to the compiler instantly.

Try This in Bibby AI

Write LaTeX faster with AI auto-complete and instant compilation.

Start Writing Free

Related Tutorials

How to Install and Use a Custom Font in LaTeX | Bibby AI