[librsvg/rustify-rsvg-convert: 12/14] rsvg-convert: Get the legacy document size as rsvg-convert.c does




commit 01d195cacf51f667bc492e93b5f8767ccb4e8e66
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Nov 6 13:25:08 2020 -0600

    rsvg-convert: Get the legacy document size as rsvg-convert.c does
    
    This does not handle sub-items yet.

 src/bin/rsvg-convert/main.rs | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/bin/rsvg-convert/main.rs b/src/bin/rsvg-convert/main.rs
index 89250d40..2f2e8b61 100644
--- a/src/bin/rsvg-convert/main.rs
+++ b/src/bin/rsvg-convert/main.rs
@@ -8,6 +8,7 @@ mod size;
 mod surface;
 
 use cssparser::Color;
+use librsvg::rsvg_convert_only::LegacySize;
 use librsvg::{CairoRenderer, Loader, RenderingError, SvgHandle};
 
 use crate::cli::Args;
@@ -39,10 +40,13 @@ fn load_stylesheet(args: &Args) -> std::io::Result<Option<String>> {
     }
 }
 
-fn get_size(_handle: &SvgHandle, renderer: &CairoRenderer, args: &Args) -> Option<Size> {
-
-    match renderer
-        .intrinsic_size_in_pixels()
+fn get_size(
+    _handle: &SvgHandle,
+    renderer: &CairoRenderer,
+    args: &Args,
+) -> Result<Size, RenderingError> {
+    renderer
+        .legacy_document_size_in_pixels()
         .map(|(w, h)| Size::new(w, h).scale(args.zoom()))
 }
 
@@ -71,7 +75,7 @@ fn main() {
 
         if target.is_none() {
             let size = get_size(&handle, &renderer, &args)
-                .unwrap_or_else(|| exit!("Could not get dimensions for file {}", input));
+                .unwrap_or_else(|e| exit!("Error rendering SVG {}: {}", input, e));
 
             target = {
                 let output = Stream::new(args.output())


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