]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix SVG scaling (bug#59802)
authorManuel Giraud <manuel@ledu-giraud.fr>
Tue, 13 Dec 2022 09:10:03 +0000 (10:10 +0100)
committerEli Zaretskii <eliz@gnu.org>
Fri, 16 Dec 2022 15:47:37 +0000 (17:47 +0200)
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

index 2436f78ac389b8ad390c85c8d6ad95bdf1b592ef..b881e43e951a82c9ea2a4b545ec9cc1ee8705a3d 100644 (file)
@@ -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)
        {