Engineer in Tokyo

TIL: Modern Fonts with LaTeX

I recently learned that you can use modern fonts in LaTeX documents by using the fontspec package. This allows you to take advantage of modern system fonts like TrueType fonts when using XeLaTeX or LuaLaTeX.

You can use the Noto Sans variable font in your LaTeX document by including the following lines in your preamble. In my case I bundle the fonts in my repository so I include a path to them in the Path option.

\usepackage{fontspec}

\setmainfont[
    Path                = path/to/fonts/,
    Extension           = .ttf,
    BoldFont            = {NotoSans-VariableFont_wdth,wght},
    ItalicFont          = {NotoSans-Italic-VariableFont_wdth,wght},
    BoldItalicFont      = {NotoSans-Italic-VariableFont_wdth,wght},
    BoldFeatures={RawFeature={+axis={wght=bold}}},
    BoldItalicFeatures={RawFeature={+axis={wght=bold}}},
]{NotoSans-VariableFont_wdth,wght}