Loads an OTF/TTF font into MicroTeX's internal font registry. The font
can then be used as a math font via the math_font parameter of
latex_grob.
Details
For standard usage, supply only otf_path. If a matching
.clm2 file is present next to the OTF, it is used automatically.
Otherwise you must generate one first (see Generating a CLM
metrics file below).
Text fonts
Text inside \text{} is rendered using R's standard
text-rendering system. Control the font with
gp = gpar(fontfamily = "...") in latex_grob —
no font loading required. This function is only needed for adding
custom math fonts.
Generating a CLM metrics file
MicroTeX reads glyph metrics, the OpenType MATH table, and glyph
outlines from a binary companion file (.clm2) rather than from
the OTF directly. A converter script is bundled with the package at
system.file("otf2clm.py", package = "gridmicrotex"). It requires
FontForge's embedded Python (ffpython), since the standard
Python does not ship the fontforge module.
Typical usage from a shell, for a single font:
ffpython otf2clm.py --single path/to/font.otf true out_dir
Or to convert every OTF in a directory:
ffpython otf2clm.py --batch in_dir true out_dir
The true argument tells the converter to embed glyph outlines
(required for render_mode = "path"); pass false to
generate a smaller .clm1 file suitable only for
render_mode = "typeface". Run the script with no arguments to
see the full usage including font-style flags.
Place the generated .clm2 file next to the OTF (same stem) so
that load_font() finds it automatically, or pass it explicitly
via clm_path.