GNU bug report logs - #64908
29.1; svg parse failure

Previous Next

Package: emacs;

Reported by: Daniel Vianna <dmlvianna <at> gmail.com>

Date: Fri, 28 Jul 2023 01:12:02 UTC

Severity: normal

Tags: unreproducible

Found in version 29.1

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

Full log


Message #49 received at 64908 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: David Ponce <da_vid <at> orange.fr>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 64908 <at> debbugs.gnu.org
Subject: Re: bug#64908: 29.1; svg parse failure
Date: Sat, 5 Aug 2023 10:58:26 +0100
[Message part 1 (text/plain, inline)]
On Sat, Aug 05, 2023 at 10:30:38AM +0200, David Ponce wrote:
> Hello,
> 
> I attached a better patch, because it is possible to have svg image
> definition that combines viewBox, and percentage of width/height, like
> in this example:
> 
> (insert-image
>   '(image :type svg :data
>      "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 22 22\" width=\"110%\" height=\"80%\">
>   <defs id=\"defs3051\">
>     <style type=\"text/css\" id=\"current-color-scheme\">
>       .ColorScheme-Text {
>         color:#232629;
>       }
>       </style>
>   </defs>
>  <path
>     style=\"fill:currentColor;fill-opacity:1;stroke:none\"
>     d=\"m7.707031 3l-.707031.707031 6.125 6.125 1.167969 1.167969-1.167969 1.167969-6.125 6.125.707031.707031 6.125-6.125 1.875-1.875-1.875-1.875-6.125-6.125\"
>     class=\"ColorScheme-Text\"
>     />
> </svg>"
>     :scale 1))
> 
> I hope Alan will find a simpler implementation for all these cases!

Hi David, I did a bit of thinking about what a percentage in the width
or height attributes actually means and how librsvg handles it.

I think we should always ignore it.

A percentage is intended as a percentage of the enclosing box. this
means if we set an image width of 100 pixels in Emacs, and the width
in the SVG is 50%, the image should be 50 pixels wide.

However we requested a width of 100 pixels, and Emacs will give us
that no matter what, even scaling it back up.

Additionally, librsvg will scale the drawn image to a width of 50%
anyway.

What this means is if we set the image width to 100 pixels, librsvg
will scale its drawing down by 50% and it should come out the correct
size within the 100 pixel wide image.

I hope that made sense, it took me a bit of thinking about it before I
came to this conclusion. It was really the fact that librsvg scales
its drawing anyway that made me decide there's no point in us also
scaling it.

I've attached a patch, can you give it a go and let me know how it
works.

Or if you disagree with my analysis above, let me know, because I'm
not 100% sure of it.
-- 
Alan Third
[0001-Fix-percentage-sizes-in-SVG-display-bug-64908.patch (text/x-diff, attachment)]

This bug report was last modified 1 year and 287 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.