Skip to content

Commit

Permalink
Fix some errors
Browse files Browse the repository at this point in the history
Update lib.rs
  • Loading branch information
baseplate-admin committed Jun 17, 2024
1 parent 1788360 commit 685afea
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Based on
* https://github.com/mrdotb/resvg_nif/blob/master/native/resvg/src/lib.rs
*/



use pyo3::prelude::*;
use resvg;

Expand Down Expand Up @@ -77,7 +79,7 @@ impl FitTo {
)
}
}
struct Opts {
struct Opts<'a> {
// font_size: u32,
serif_family: Option<String>,
sans_serif_family: Option<String>,
Expand All @@ -89,7 +91,7 @@ struct Opts {
font_dirs: Option<Vec<String>>,
// Abstract Classes
fit_to: FitTo,
usvg_opt: resvg::usvg::Options,
usvg_opt: resvg::usvg::Options<'a>,
// Renderers
skip_system_fonts: bool,
}
Expand Down Expand Up @@ -161,7 +163,7 @@ fn resvg_magic(mut options: Opts, svg_string: String) -> Result<Vec<u8>, String>
}

let tree = {
resvg::usvg::Tree::from_xmltree(&xml_tree, &options.usvg_opt, &fontdb)
resvg::usvg::Tree::from_xmltree(&xml_tree, &options.usvg_opt)
.map_err(|e| e.to_string())
}?;
Ok(render_svg(options, &tree)?.encode_png().unwrap())
Expand Down Expand Up @@ -329,6 +331,8 @@ fn svg_to_bytes(
image_rendering: _image_rendering,
default_size,
image_href_resolver: resvg::usvg::ImageHrefResolver::default(),
font_resolver: resvg::usvg::FontResolver::default(),
fontdb: std::sync::Arc::new(resvg::usvg::fontdb::Database::new()),
};


Expand Down

0 comments on commit 685afea

Please sign in to comment.