emacs-diffs
[Top][All Lists]
Advanced

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

master ca8e37e: Fix SVG display again (bug#44655)


From: Alan Third
Subject: master ca8e37e: Fix SVG display again (bug#44655)
Date: Wed, 18 Nov 2020 18:08:08 -0500 (EST)

branch: master
commit ca8e37eaf64f23675fab36eadead4d3b613b8a1b
Author: Alan Third <alan@idiocy.org>
Commit: Alan Third <alan@idiocy.org>

    Fix SVG display again (bug#44655)
    
    * src/image.c (svg_load_image): Fall back to
    rsvg_handle_get_dimensions if we can't calculate the size of the
    image.
---
 src/image.c | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/src/image.c b/src/image.c
index 3858f3c..fdb7ef8 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9903,30 +9903,21 @@ svg_load_image (struct frame *f, struct image *img, 
char *contents,
       viewbox_width = viewbox.x + viewbox.width;
       viewbox_height = viewbox.y + viewbox.height;
     }
-#else
-  /* The function used above to get the geometry of the visible area
-     of the SVG are only available in librsvg 2.46 and above, so in
-     certain circumstances this code path can result in some parts of
-     the SVG being cropped.  */
-  RsvgDimensionData dimension_data;
-
-  rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
 
-  viewbox_width = dimension_data.width;
-  viewbox_height = dimension_data.height;
+  if (viewbox_width == 0 || viewbox_height == 0)
 #endif
+  {
+    /* The functions used above to get the geometry of the visible
+       area of the SVG are only available in librsvg 2.46 and above,
+       so in certain circumstances this code path can result in some
+       parts of the SVG being cropped.  */
+    RsvgDimensionData dimension_data;
 
-  if (viewbox_width == 0 || viewbox_height == 0)
-    {
-      /* We do not have any usable dimensions, so make some up.  The
-         values below are supposedly the default values most web
-         browsers use for SVGs with no set size.  */
-      /* FIXME: At this stage we should perhaps consider rendering the
-         image out to a bitmap and getting the dimensions from
-         that.  */
-      viewbox_width = 300;
-      viewbox_height = 150;
-    }
+    rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
+
+    viewbox_width = dimension_data.width;
+    viewbox_height = dimension_data.height;
+  }
 
   compute_image_size (viewbox_width, viewbox_height, img->spec,
                       &width, &height);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]