resolve_font_file
Mojo function 🡭
resolve_font_file
fn def resolve_font_file(family: String, slant: FontSlant = FontSlant.NORMAL, weight: FontWeight = FontWeight.NORMAL) -> StringResolve family/slant/weight to an absolute font file path.
Generic and metric aliases are expanded, and an unrecognized family falls back through the default sans list, so this raises only on a machine with no installed fonts.
Scans the font directories on every call; build one FontDatabase
(or FontCache) to resolve more than a handful of fonts.
Args:
- family (
String): Font family name or generic alias (e.g. “sans-serif”). - slant (
FontSlant): Requested upright/italic/oblique style. - weight (
FontWeight): Requested normal/bold weight.
Returns:
String: The matched font’s absolute file path.
Raises:
Error: no font files were found on this machine.