Fonts

resvg_py uses platform-appropriate defaults and lets you override every generic font family or load custom font files.

Default fonts per OS

Generic family

Default font

Default (font_family)

Times New Roman

Serif (serif_family)

Times New Roman

Sans-serif (sans_serif_family)

Arial

Cursive (cursive_family)

Comic Sans MS

Fantasy (fantasy_family)

Impact

Monospace (monospace_family)

Courier New

Note

On platforms outside Windows, macOS, and Linux, CSS generic names (serif, sans-serif, cursive, fantasy, monospace) are used as fallback family names.

Loading custom fonts

resvg_py.svg_to_bytes(
    svg_string=svg,
    font_files=["/path/to/MyFont.ttf"],
)

Skipping system fonts

Warning

Setting skip_system_fonts=True without providing font_files or font_dirs will cause text to render as empty boxes.

resvg_py.svg_to_bytes(
    svg_string=svg,
    skip_system_fonts=True,
    font_files=["/path/to/MyFont.ttf"],
)

Tip

Skip system fonts in containerized or CI environments where the host font database is incomplete or missing entirely.

See also

API Reference – Full parameter list for all font-related arguments.