unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: "Matsievskiy S.V." <matsievskiysv@gmail.com>
Cc: 44655@debbugs.gnu.org
Subject: bug#44655: 28.0.50; Oversized SVG margin
Date: Sun, 15 Nov 2020 17:25:35 +0000	[thread overview]
Message-ID: <20201115172535.GA1370@breton.holly.idiocy.org> (raw)
In-Reply-To: <757bb5f2e5c43762717c5b1f8a0d3083c6e01607.camel@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 840 bytes --]

On Sun, Nov 15, 2020 at 11:59:11AM +0300, Matsievskiy S.V. wrote:
> Inserted into overlays SVG images have oversized bottom and right
> margins. This bug was
> introduced somewhere between 109eb1e7e29455418b40ca00bf5dad3e61e5fc78
> and a32fd9f64d06ccd07a9beaf6d6f1283f7a80edac

This is exactly what I expected when I made the last change: someone
would quickly find an SVG that doesn't work.

All I can think of to do is ignore the deprecation of
svg_handle_get_dimensions and continue using it. The release notes for
librsvg 2.46 state it's deprecated but still available.

Patch attached. Are we happy to continue using deprecated functions?

(I was looking through the librsvg bug tracker and it looks as though
they want to move away from depending on Cairo. Perhaps this means
things will improve for us in the future.)
-- 
Alan Third

[-- Attachment #2: 0001-Fix-SVG-display-again-bug-44655.patch --]
[-- Type: text/plain, Size: 2567 bytes --]

From 2408b2579ee9fbe831035b7784133863d91b77ab Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
Date: Sun, 15 Nov 2020 17:21:03 +0000
Subject: [PATCH] Fix SVG display again (bug#44655)

* src/image.c (svg_load_image): Fall back to a deprecated function if
we can't calculate the size of the image.
---
 src/image.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/image.c b/src/image.c
index 3858f3c41f..652605d9c8 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9903,27 +9903,34 @@ 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.
+
+       FIXME: The rsvg_handle_get_dimensions has been deprecated since
+       version 2.46 of librsvg, but is still available.  With some SVG
+       files (bug#44655) I can't find any other way to get sensible
+       dimensions from librsvg, so with 2.46 and above this is a last
+       ditch attempt.  Presumably at some point the function will be
+       removed and this will need to be changed.  */
+    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)
     {
       /* 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;
     }
-- 
2.26.1


  reply	other threads:[~2020-11-15 17:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-15  8:59 bug#44655: 28.0.50; Oversized SVG margin Matsievskiy S.V.
2020-11-15 17:25 ` Alan Third [this message]
2020-11-15 17:31   ` Eli Zaretskii
2020-11-15 17:33     ` Alan Third
2020-11-15 17:47       ` Eli Zaretskii
2020-11-15 17:56         ` Alan Third
2020-11-16 22:34         ` Lars Ingebrigtsen
2020-11-15 17:39   ` Matsievskiy S.V.
2020-11-15 17:52     ` Alan Third
2020-11-18 21:40       ` Matsievskiy S.V.
2020-11-18 23:08         ` Alan Third
2020-11-20  0:18           ` Andy Moreton
2020-11-20 15:02             ` Eli Zaretskii
2020-11-20 15:39               ` Andy Moreton
2021-11-05 19:28 ` Paul Eggert
2021-11-06 12:55   ` Alan Third
2021-12-03 18:45     ` Paul Eggert
2021-12-04 10:46       ` Alan Third
2021-12-04 11:00       ` Arash Esbati
2021-12-04 11:43         ` Eli Zaretskii
2021-12-04 12:05           ` Arash Esbati
2021-12-04 16:07             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201115172535.GA1370@breton.holly.idiocy.org \
    --to=alan@idiocy.org \
    --cc=44655@debbugs.gnu.org \
    --cc=matsievskiysv@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).