Skip to content

Commit

Permalink
Remove String references
Browse files Browse the repository at this point in the history
  • Loading branch information
baseplate-admin committed May 10, 2024
1 parent 6d2c2a9 commit 8c8fb50
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,17 @@ fn resvg_magic(mut options: Opts, svg_string: String) -> Result<Vec<u8>, 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<String>,
Expand All @@ -212,18 +212,18 @@ fn svg_to_bytes(
// Fonts
languages: Option<Vec<String>>,
font_size: Option<u32>,
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<String>,
serif_family: Option<String>,
sans_serif_family:Option<String>,
cursive_family: Option<String>,
fantasy_family: Option<String>,
monospace_family:Option<String>,
font_files: Option<Vec<String>>,
font_dirs: Option<Vec<String>>,
// Effects based
shape_rendering: Option<&str>,
text_rendering: Option<&str>,
image_rendering: Option<&str>,
shape_rendering:Option<String>,
text_rendering: Option<String>,
image_rendering: Option<String>,

) -> PyResult<Vec<u8>> {
if log_information.unwrap_or(false) {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
};
Expand Down

0 comments on commit 8c8fb50

Please sign in to comment.