From: Manuel Giraud Date: Tue, 13 Dec 2022 09:10:03 +0000 (+0100) Subject: Fix SVG scaling (bug#59802) X-Git-Tag: emacs-29.0.90~1126 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dc78779c0cd1f057830458f341c280ddb6695409;p=emacs.git 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. --- diff --git a/src/image.c b/src/image.c index 2436f78ac38..b881e43e951 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) {