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
load_font() to use it for math rendering.
Details
The font is also registered with the systemfonts package so it
can be selected for surrounding plot text via
gp = gpar(fontfamily = "...") without being installed
system-wide.
Text fonts
This function is only for math fonts (fonts with an
OpenType MATH table). Plain text fonts used inside \text{}
blocks are resolved automatically by systemfonts from the
gp$fontfamily argument — no 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()
#> [1] "DejaVu Sans" "Lete Sans Math" "STIX Two Math"
# }