From 73d58b9d631dce8d84965cb842f3a831c24187af Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Tue, 13 Dec 2022 10:10:03 +0100 Subject: [PATCH] Fix SVG scaling (bug#59802) Fix SVG scaling with librsvg>2.52 and SVG file with only one known dimension. * src/image.c (svg_load_image): Compute a percentage dimension with the other known dimension. --- src/image.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/image.c b/src/image.c index 2436f78ac3..b881e43e95 100644 --- a/src/image.c +++ b/src/image.c @@ -11309,6 +11309,15 @@ svg_load_image (struct frame *f, struct image *img, char *contents, img->face_font_size); viewbox_height = 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)) + viewbox_width = (viewbox_height * viewbox.width / viewbox.height) + * iwidth.length; + else if (! (0 < viewbox_height) && (iheight.unit == RSVG_UNIT_PERCENT)) + viewbox_height = (viewbox_width * viewbox.height / viewbox.width) + * iheight.length; } else if (has_width && has_viewbox) { -- 2.38.1