Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
baseplate-admin committed Dec 12, 2024
1 parent 48fba97 commit 191c6c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]

[dependencies]
log = "0.4.21"
pyo3 = "0.23.2"
pyo3 = "0.21.2"
resvg = { version = "0.42.0", features = ["raster-images", "text"] }
svgtypes = "0.15.1"

Expand Down
7 changes: 4 additions & 3 deletions src/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Based on
*/

use pyo3::prelude::*;
use resvg;
use resvg::{self, usvg::FontResolver};


#[derive(Clone, Copy, PartialEq, Debug)]
Expand Down Expand Up @@ -151,7 +151,6 @@ fn resvg_magic(mut options: Opts, svg_string: String) -> Result<Vec<u8>, 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();
}
Expand All @@ -161,7 +160,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 +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()
};


Expand Down

0 comments on commit 191c6c3

Please sign in to comment.