docs: add comprehensive documentation

This commit is contained in:
2025-07-10 18:05:28 -05:00
parent 1b3f6c8864
commit 96dcbcc318
7 changed files with 92 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
use resvg::usvg::fontdb;
use resvg::{tiny_skia, usvg};
/// Errors that can occur during SVG rasterization.
#[derive(Debug, Clone)]
pub struct RenderError {
pub message: Option<String>,
@@ -21,6 +22,7 @@ pub struct Rasterizer {
}
impl Rasterizer {
/// Creates a new rasterizer and loads available fonts.
pub fn new() -> Self {
let mut fontdb = fontdb::Database::new();
fontdb.load_system_fonts();
@@ -33,6 +35,7 @@ impl Rasterizer {
Self { font_db: fontdb }
}
/// Converts SVG data to PNG.
pub fn render(&self, svg_data: Vec<u8>) -> Result<Vec<u8>, RenderError> {
let tree = {
let opt = usvg::Options {