From: David Ponce <da_vid@orange.fr>
To: Eli Zaretskii <eliz@gnu.org>, Alan Third <alan@idiocy.org>
Cc: 64908@debbugs.gnu.org
Subject: bug#64908: 29.1; svg parse failure
Date: Sat, 5 Aug 2023 10:30:38 +0200 [thread overview]
Message-ID: <f3e3417c-4011-3cd2-6f7a-243a841ace8c@orange.fr> (raw)
In-Reply-To: <a2fa94e0-c701-9328-baf2-020ef1ee01c4@orange.fr>
[-- Attachment #1: Type: text/plain, Size: 1855 bytes --]
On 04/08/2023 23:08, David Ponce wrote:
> On 04/08/2023 21:08, Eli Zaretskii wrote:
>>> Date: Fri, 4 Aug 2023 19:32:13 +0100
>>> From: Alan Third <alan@idiocy.org>
>>> Cc: David Ponce <da_vid@orange.fr>, 64908@debbugs.gnu.org
>>>
>>> On Fri, Aug 04, 2023 at 01:26:45PM +0300, Eli Zaretskii wrote:
>>>>
>>>> Thanks. I hope this will help an SVG expert to figure out what's
>>>> going on with these images.
>>>>
>>>> Alan, do you have time to look into this, per chance?
>>>
>>> Yeah. I know roughly what needs to be done here thanks to David's most
>>> recent email, but I'll have a wee think about how best to do it since
>>> we already have, I think, three different methods of finding the image
>>> size depending on the version of librsvg. If I can merge a couple of
>>> those approaches it will probably be best.
>>
>> Thanks in advance.
>
> Eli, Alan,
>
> Until Alan finds the best solution, the attached simple patch fixed
> the issue for me with librsvg 2.56.3.
>
> Thanks & Regards
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!
Thanks & Regards
[-- Attachment #2: image.c.patch --]
[-- Type: text/x-patch, Size: 1060 bytes --]
diff --git a/src/image.c b/src/image.c
index cb9725892d1..ae24f5b3893 100644
--- a/src/image.c
+++ b/src/image.c
@@ -11358,12 +11358,16 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
if (has_width && has_height)
{
+
/* Success! We can use these values directly. */
- viewbox_width = svg_css_length_to_pixels (iwidth, dpi,
- img->face_font_size);
- viewbox_height = svg_css_length_to_pixels (iheight, dpi,
- img->face_font_size);
-
+ viewbox_width = ((iwidth.unit == RSVG_UNIT_PERCENT) && has_viewbox)
+ ? viewbox.width * iwidth.length
+ : svg_css_length_to_pixels (iwidth, dpi, img->face_font_size);
+
+ viewbox_height = ((iheight.unit == RSVG_UNIT_PERCENT) && has_viewbox)
+ ? viewbox.height * iheight.length
+ : svg_css_length_to_pixels (iheight, dpi, img->face_font_size);
+
/* Here one dimension could be zero because in percent unit.
So calculate this dimension with the other. */
if (! (0 < viewbox_width) && (iwidth.unit == RSVG_UNIT_PERCENT))
next prev parent reply other threads:[~2023-08-05 8:30 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-28 1:10 bug#64908: 29.1; svg parse failure Daniel Vianna
2023-07-28 6:05 ` Eli Zaretskii
[not found] ` <CAMLJ+NHO38NYGPctAj9MmMwy4tz8aSqHgLDWQhQaDm7FUP7Yqw@mail.gmail.com>
2023-07-28 11:00 ` Eli Zaretskii
2023-07-28 12:48 ` Visuwesh
2023-08-03 8:11 ` Eli Zaretskii
2023-08-03 19:16 ` David Ponce
2023-08-04 5:23 ` Eli Zaretskii
2023-08-04 7:55 ` David Ponce
2023-08-04 10:26 ` Eli Zaretskii
2023-08-04 16:23 ` David Ponce
2023-08-04 18:32 ` Alan Third
2023-08-04 19:08 ` Eli Zaretskii
2023-08-04 21:08 ` David Ponce
2023-08-05 8:30 ` David Ponce [this message]
2023-08-05 9:58 ` Alan Third
2023-08-05 10:07 ` Eli Zaretskii
2023-08-05 10:24 ` Alan Third
2023-08-05 10:41 ` Eli Zaretskii
2023-08-05 12:32 ` David Ponce
2023-08-05 15:14 ` Alan Third
2023-08-05 15:53 ` David Ponce
2023-08-05 16:02 ` Alan Third
2023-08-05 16:24 ` David Ponce
2023-08-05 16:31 ` Alan Third
2023-08-05 17:37 ` David Ponce
2023-08-05 17:39 ` Alan Third
2023-08-05 18:00 ` David Ponce
2023-08-05 18:31 ` Alan Third
2023-08-05 20:04 ` David Ponce
2023-08-08 13:58 ` David Ponce
2023-08-08 21:18 ` Alan Third
2023-08-08 22:22 ` David Ponce
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=f3e3417c-4011-3cd2-6f7a-243a841ace8c@orange.fr \
--to=da_vid@orange.fr \
--cc=64908@debbugs.gnu.org \
--cc=alan@idiocy.org \
--cc=eliz@gnu.org \
/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).