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 ( |
|
Serif ( |
|
Sans-serif ( |
|
Cursive ( |
|
Fantasy ( |
|
Monospace ( |
Generic family |
Default font |
|---|---|
Default ( |
|
Serif ( |
|
Sans-serif ( |
|
Cursive ( |
|
Fantasy ( |
Anton |
Monospace ( |
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"],
)
resvg_py.svg_to_bytes(
svg_string=svg,
font_dirs=["/path/to/fonts/"],
)
resvg_py.svg_to_bytes(
svg_string=svg,
font_family="Inter",
monospace_family="Fira Code",
)
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.