summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Giraud <manuel@ledu-giraud.fr>2022-12-13 10:10:03 +0100
committerEli Zaretskii <eliz@gnu.org>2022-12-16 17:47:37 +0200
commitdc78779c0cd1f057830458f341c280ddb6695409 (patch)
treee0d91eabc48cc8883e1d2223ab038ef500b769fe
parent10415d9651b0c85f9d6585cb789100c239c532b4 (diff)
downloademacs-dc78779c0cd1f057830458f341c280ddb6695409.tar.gz
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.
-rw-r--r--src/image.c9
1 files changed, 9 insertions, 0 deletions
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)
{