[librsvg/rustify-rsvg-convert] rsvg-convert: return a Size from natural_size(), not a (w, h) tuple
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustify-rsvg-convert] rsvg-convert: return a Size from natural_size(), not a (w, h) tuple
- Date: Mon, 25 Jan 2021 22:11:27 +0000 (UTC)
commit 9349686aa17c3d7c3febbec5596302c7eeae6548
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jan 25 15:48:13 2021 -0600
rsvg-convert: return a Size from natural_size(), not a (w, h) tuple
src/bin/rsvg-convert.rs | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index 6ce42c32..fe9c8da5 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -397,8 +397,8 @@ impl Converter {
};
}
- fn natural_size(&self, renderer: &CairoRenderer, input: &Input) -> (f64, f64) {
- renderer
+ fn natural_size(&self, renderer: &CairoRenderer, input: &Input) -> Size {
+ let (w, h) = renderer
.legacy_layer_size(self.export_id.as_deref())
.unwrap_or_else(|e| match e {
RenderingError::IdNotFound => exit!(
@@ -407,11 +407,13 @@ impl Converter {
self.export_id.as_deref().unwrap()
),
_ => exit!("Error rendering SVG {}: {}", input, e),
- })
+ });
+
+ Size::new(w, h)
}
fn create_surface(&self, renderer: &CairoRenderer, input: &Input) -> Surface {
- let (natural_width, natural_height) = self.natural_size(renderer, input);
+ let natural_size = self.natural_size(renderer, input);
let strategy = match (self.width, self.height) {
// when w and h are not specified, scale to the requested zoom (if any)
@@ -430,7 +432,10 @@ impl Converter {
};
let final_size = strategy
- .apply(Size::new(natural_width, natural_height), self.keep_aspect_ratio)
+ .apply(
+ Size::new(natural_size.w, natural_size.h),
+ self.keep_aspect_ratio,
+ )
.unwrap_or_else(|| exit!("The SVG {} has no dimensions", input));
let output_stream = match self.output {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]