diff --git a/src/rust/lib.rs b/src/rust/lib.rs index 8849da7..eca5883 100644 --- a/src/rust/lib.rs +++ b/src/rust/lib.rs @@ -180,17 +180,17 @@ fn resvg_magic(mut options: Opts, svg_string: String) -> Result, String> resources_dir = None, languages = vec![], font_size = 16, - font_family = "Times New Roman", - serif_family = "Times New Roman", - sans_serif_family = "Arial", - cursive_family = "Comic Sans MS", - fantasy_family = "Impact", - monospace_family = "Courier New", + font_family = "Times New Roman".to_owned(), + serif_family = "Times New Roman".to_owned(), + sans_serif_family = "Arial".to_owned(), + cursive_family = "Comic Sans MS".to_owned(), + fantasy_family = "Impact".to_owned(), + monospace_family = "Courier New".to_owned(), font_files = None, font_dirs = None, - shape_rendering = "geometric_precision", - text_rendering = "optimize_legibility", - image_rendering = "optimize_quality", + shape_rendering = "geometric_precision".to_owned(), + text_rendering = "optimize_legibility".to_owned(), + image_rendering = "optimize_quality".to_owned(), ))] fn svg_to_bytes( svg_string: Option, @@ -212,18 +212,18 @@ fn svg_to_bytes( // Fonts languages: Option>, font_size: Option, - font_family: Option<&str>, - serif_family: Option<&str>, - sans_serif_family: Option<&str>, - cursive_family: Option<&str>, - fantasy_family: Option<&str>, - monospace_family: Option<&str>, + font_family: Option, + serif_family: Option, + sans_serif_family:Option, + cursive_family: Option, + fantasy_family: Option, + monospace_family:Option, font_files: Option>, font_dirs: Option>, // Effects based - shape_rendering: Option<&str>, - text_rendering: Option<&str>, - image_rendering: Option<&str>, + shape_rendering:Option, + text_rendering: Option, + image_rendering: Option, ) -> PyResult> { if log_information.unwrap_or(false) { @@ -276,7 +276,7 @@ fn svg_to_bytes( } let _shape_rendering = match shape_rendering - .unwrap_or("geometric_precision") + .unwrap_or("geometric_precision".to_string()) .as_ref() { "optimize_speed" => resvg::usvg::ShapeRendering::OptimizeSpeed, @@ -286,7 +286,7 @@ fn svg_to_bytes( }; let _text_rendering = match text_rendering - .unwrap_or("optimize_legibility") + .unwrap_or("optimize_legibility".to_string()) .as_ref() { "optimize_speed" => resvg::usvg::TextRendering::OptimizeSpeed, @@ -296,7 +296,7 @@ fn svg_to_bytes( }; let _image_rendering = match image_rendering - .unwrap_or("optimize_quality") + .unwrap_or("optimize_quality".to_string()) .as_ref() { "optimize_quality" => resvg::usvg::ImageRendering::OptimizeQuality, @@ -320,7 +320,7 @@ fn svg_to_bytes( let usvg_options = resvg::usvg::Options { resources_dir: _resources_dir, dpi: dpi.unwrap_or(0) as f32, - font_family: font_family.unwrap_or("Times New Roman").to_string(), + font_family: font_family.unwrap_or("Times New Roman".to_string()), font_size: font_size.unwrap_or(16) as f32, languages: languages.unwrap_or(vec![]), shape_rendering: _shape_rendering, @@ -337,11 +337,11 @@ fn svg_to_bytes( background: _background, skip_system_fonts: skip_system_fonts.unwrap_or(false), fit_to, - serif_family:serif_family.map(|s|s.to_string()), - sans_serif_family:sans_serif_family.map(|s|s.to_string()), - cursive_family:cursive_family.map(|s|s.to_string()), - fantasy_family:fantasy_family.map(|s|s.to_string()), - monospace_family:monospace_family.map(|s|s.to_string()), + serif_family:serif_family, + sans_serif_family:sans_serif_family, + cursive_family:cursive_family, + fantasy_family:fantasy_family, + monospace_family:monospace_family, font_files, font_dirs, };