From 191c6c362b07bdb2a12bd44fe43370636702e943 Mon Sep 17 00:00:00 2001 From: baseplate-admin <61817579+baseplate-admin@users.noreply.github.com> Date: Thu, 12 Dec 2024 18:25:31 +0600 Subject: [PATCH] add --- Cargo.toml | 2 +- src/rust/lib.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2dc3bee..7caa1f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" 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() };