Expand description
SVG string → PNG bytes rasterization using resvg.
Uses resvg (pure Rust) for SVG parsing and rasterization. Supports density/DPI scaling, white background, and configurable padding.
§Font resolution
The shared font database is lazily initialized with system fonts
(Liberation Sans, DejaVu, etc. on Linux) on first use. Charts that
emit SVG <text> elements with named font-family values beyond
the system set (e.g. 'Instrument Serif', 'DM Sans') will silently
fail to render text unless those fonts are registered first.
To register additional fonts (e.g. compile-time embedded design-system
fonts), call init_font_database before the first render:
let dm_sans = include_bytes!("fonts/DMSans-Regular.ttf").to_vec();
chartml_render::init_font_database(vec![dm_sans]);If init_font_database is not called, the database initializes lazily
with system fonts only — existing consumers see no behavior change.
Functions§
- init_
font_ database - Initialize the font database with system fonts plus additional font data.
- svg_
to_ png - Rasterize an SVG string to PNG bytes.