1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-23 14:10:28 -08:00

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.
This commit is contained in:
Manuel Giraud 2022-12-13 10:10:03 +01:00 committed by Eli Zaretskii
parent 10415d9651
commit dc78779c0c

View 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)
{