Documentation/Fonts/How to Use Google Fonts in LaTeX with XeLaTeX or LuaLaTeX
Fonts

How to Use Google Fonts in LaTeX with XeLaTeX or LuaLaTeX

Google Fonts offers hundreds of free, high-quality typefaces — and you can use any of them in LaTeX. The process involves downloading the font files and loading them with fontspec under XeLaTeX or LuaLaTeX. Popular choices like Roboto, Open Sans, Lato, and Source Serif Pro work beautifully in academic documents. Bibby AI supports XeLaTeX and LuaLaTeX out of the box, so you can upload Google Fonts to your project and start using them immediately — no installation needed.

Download and Set Up a Google Font

Download the font from fonts.google.com, place the files in your project, and load with fontspec:

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

% Load Google Fonts from your project's fonts/ directory
\setmainfont{Roboto}[
    Path = ./fonts/Roboto/,
    Extension = .ttf,
    UprightFont = *-Regular,
    BoldFont = *-Bold,
    ItalicFont = *-Italic,
    BoldItalicFont = *-BoldItalic
]

\setsansfont{Open Sans}[
    Path = ./fonts/OpenSans/,
    Extension = .ttf,
    UprightFont = *-Regular,
    BoldFont = *-Bold,
    ItalicFont = *-Italic,
    BoldItalicFont = *-BoldItalic
]

\begin{document}
\section{Using Google Fonts}
Body text in Roboto. {\sffamily Headings in Open Sans.}

\textbf{Bold}, \textit{italic}, and \textbf{\textit{bold italic}} all work.
\end{document}

Pair Google Fonts for Professional Typography

Set up a complete typographic system using complementary Google Fonts for headings, body, and code:

\documentclass{article}
\usepackage{fontspec}
\usepackage{titlesec}

% Serif body font
\setmainfont{Source Serif Pro}[
    Path = ./fonts/SourceSerifPro/,
    Extension = .otf,
    UprightFont = *-Regular,
    BoldFont = *-Bold,
    ItalicFont = *-Italic,
    BoldItalicFont = *-BoldItalic
]

% Sans-serif heading font
\setsansfont{Montserrat}[
    Path = ./fonts/Montserrat/,
    Extension = .ttf,
    UprightFont = *-Regular,
    BoldFont = *-Bold
]

% Monospace code font
\setmonofont{JetBrains Mono}[
    Path = ./fonts/JetBrainsMono/,
    Extension = .ttf,
    UprightFont = *-Regular,
    Scale = 0.85
]

% Use sans-serif for headings
\titleformat{\section}{\sffamily\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\sffamily\large\bfseries}{\thesubsection}{1em}{}

\begin{document}
\section{Professional Font Pairing}
Body in Source Serif Pro pairs beautifully with Montserrat headings.

{\ttfamily Code in JetBrains Mono.}
\end{document}

Use Google Fonts with Math Support

When using Google Fonts, you need a separate math font. Use unicode-math for full math support:

% Compile with: lualatex (recommended for unicode-math)
\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}

\setmainfont{Lato}[
    Path = ./fonts/Lato/,
    Extension = .ttf,
    UprightFont = *-Regular,
    BoldFont = *-Bold,
    ItalicFont = *-Italic
]

% Use a compatible math font
\setmathfont{TeX Gyre Termes Math}  % Free Times-like math font
% Other options: Latin Modern Math, STIX Two Math, Libertinus Math

\begin{document}
Text in Lato with full math: $\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}$

Inline: $\mathbb{R}^n$, $\sum_{k=0}^{\infty} a_k x^k$
\end{document}

💡 Tips

  • Download font files in .ttf or .otf format from fonts.google.com — the 'Download family' button gets all weights at once.
  • Always specify all font variants (Regular, Bold, Italic, BoldItalic) or fontspec will synthesize missing ones poorly.
  • Use Scale = MatchLowercase or a manual scale factor when mixing fonts of different visual sizes.
  • On Bibby AI, drag and drop font files into your project's file tree — they'll be available to XeLaTeX/LuaLaTeX instantly.

Try This in Bibby AI

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

Start Writing Free

Related Tutorials

How to Use Google Fonts in LaTeX with XeLaTeX or LuaLaTeX | Bibby AI