Example how to use arbitrary Google Fonts in a LaTeX document (using modern lualatex)
You need this in LaTeX? Then read on.
-
Find your favorite font on Google Fonts
-
Download the font using the "Download family" button in the upper right corner in the font's details view.
-
Unpack the font files and move them to inside the
~/.fonts/
directory (so inside your home directory). It is okay to organize the ttf files in subdirectories or to keep them if they were in subfolders inside the archive. -
Optionally you can update the font index manually:
luaotfload-tool --update
If you don't do this,
lualatex
will execute it on demand on first compilation using the new font. -
Import the
fontspec
package in your tex file and set the font for your document in the preamble:\usepackage{fontspec} \setmainfont{OpenSans}[ Extension = .ttf, UprightFont = *-Regular, BoldFont={*-Bold}, ItalicFont={*-Italic}, BoldItalicFont={*-BoldItalic} ] %\setsansfont... %\setmonofont...
Define the font types you need. Sans and mono fonts are optional, but use the same syntax. For more details see the fontspec documentation.
(see fonts.tex)
-
Compile:
lualatex fonts
-
See result PDF and enjoy.
For steps 3, 4, and 6 see fonts.sh.
This guide should work on Linux and MacOS X, and it should be possible to adapt for Windows easily.
- Font names instead of filenames are possible though not easy to acquire.
- When using font names the asterisk (*) is replaced by the base font name when defining bold and italic variants (via StackOverflow)