[librsvg/rustify-rsvg-convert: 74/78] Compute the full geometry of the export_id element, not just the size




commit 6818e84a23b581f0498e5985066bcf282b6447bc
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Feb 2 15:22:05 2021 -0600

    Compute the full geometry of the export_id element, not just the size

 src/bin/rsvg-convert.rs | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index 43cd4644..2ea761d6 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -1,6 +1,7 @@
 #[macro_use]
 extern crate clap;
 
+use cairo;
 use gio::prelude::*;
 use gio::{
     Cancellable, FileCreateFlags, FileExt, InputStream, OutputStream, UnixInputStream,
@@ -416,7 +417,8 @@ impl Converter {
 
             let renderer = CairoRenderer::new(&handle).with_dpi(self.dpi.0, self.dpi.1);
 
-            let natural_size = self.natural_size(&renderer, input)?;
+            let geometry = self.natural_geometry(&renderer, input)?;
+            let natural_size = Size::new(geometry.width, geometry.height);
 
             let strategy = match (self.width, self.height) {
                 // when w and h are not specified, scale to the requested zoom (if any)
@@ -457,10 +459,14 @@ impl Converter {
         Ok(())
     }
 
-    fn natural_size(&self, renderer: &CairoRenderer, input: &Input) -> Result<Size, Error> {
+    fn natural_geometry(
+        &self,
+        renderer: &CairoRenderer,
+        input: &Input,
+    ) -> Result<cairo::Rectangle, Error> {
         renderer
             .legacy_layer_geometry(self.export_id.as_deref())
-            .map(|(ink_r, _)| Size::new(ink_r.width, ink_r.height))
+            .map(|(ink_r, _)| ink_r)
             .map_err(|e| match e {
                 RenderingError::IdNotFound => error!(
                     "File {} does not have an object with id \"{}\")",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]