diff --git a/Cargo.toml b/Cargo.toml index 0cde560..7caa1f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,18 +12,18 @@ crate-type = ["cdylib"] [dependencies] log = "0.4.21" pyo3 = "0.21.2" -resvg = { version = "0.42.0", features = ["raster-images","text"] } +resvg = { version = "0.42.0", features = ["raster-images", "text"] } svgtypes = "0.15.1" [profile.release.package."*"] codegen-units = 1 -opt-level ='z' +opt-level = 'z' strip = true [profile.release] panic = "abort" codegen-units = 1 lto = "fat" -opt-level ='z' -strip = true \ No newline at end of file +opt-level = 'z' +strip = true diff --git a/src/rust/lib.rs b/src/rust/lib.rs index fdfc4d5..30d34ee 100644 --- a/src/rust/lib.rs +++ b/src/rust/lib.rs @@ -5,7 +5,7 @@ Based on */ use pyo3::prelude::*; -use resvg; +use resvg::{self, usvg::FontResolver}; #[derive(Clone, Copy, PartialEq, Debug)] @@ -151,7 +151,6 @@ fn resvg_magic(mut options: Opts, svg_string: String) -> Result, String> .descendants() .any(|n| n.has_tag_name(("http://www.w3.org/2000/svg", "text"))); - let mut fontdb = resvg::usvg::fontdb::Database::new(); if !options.skip_system_fonts { fontdb.load_system_fonts(); } @@ -161,7 +160,7 @@ fn resvg_magic(mut options: Opts, svg_string: String) -> Result, 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()) @@ -329,6 +328,8 @@ fn svg_to_bytes( image_rendering: _image_rendering, default_size, image_href_resolver: resvg::usvg::ImageHrefResolver::default(), + fontdb: resvg::usvg::fontdb::Database::new(), + font_resolver:FontResolver::default() };