% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fonts.R
\name{load_font}
\alias{load_font}
\title{Load a math font from an OTF file}
\usage{
load_font(otf_path)
}
\arguments{
\item{otf_path}{Path to the OTF/TTF font file.}
}
\value{
Invisibly returns \code{NULL}.
}
\description{
Loads an OTF/TTF math font into MicroTeX's internal font registry. The
font's OpenType MATH table is parsed directly in C++ and the required
metrics are synthesised on the fly. You can download free math fonts like
Latin Modern Math (default math fonts in LaTeX) and load it with
\code{load_font()} to use it for math rendering.
}
\details{
The font is also registered with the \pkg{systemfonts} package so it
can be selected for surrounding plot text via
\code{gp = gpar(fontfamily = "...")} without being installed
system-wide.
}
\section{Text fonts}{

This function is only for \strong{math} fonts (fonts with an
OpenType MATH table). Plain text fonts used inside \code{\\text\{\}}
blocks are resolved automatically by \pkg{systemfonts} from the
\code{gp$fontfamily} argument --- no \code{load_font()} call required.
}

\examples{
\donttest{
  # Load a math font from a local OTF file. Here we point at the
  # bundled STIX font so the example is self-contained and loaded.
  # You don't need to load the bundled fonts to use them — they're registered
  # with systemfonts on first render — but this shows how to load a custom font.
  # in practice you would pass the path to any OTF with an OpenType MATH table.
  otf <- system.file("fonts", "STIXTwoMath-Regular.otf",
                     package = "gridmicrotex")
  load_font(otf)
  available_math_fonts()
}
}
\seealso{
\code{\link{available_math_fonts}}, \code{\link{latex_options}},
\code{\link{latex_grob}}
}
