summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-10-05 01:00:33 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-10-05 01:00:33 +0100
commitc0826212ef3fc4b74a26dedd1788074a3f96ad48 (patch)
tree1155ea2e02543e059dde7f516f380e83f7e6202f /src
parentf2f1cc42a29c3210e6ee501d3ece3b16867d7035 (diff)
downloadefl-c0826212ef3fc4b74a26dedd1788074a3f96ad48.tar.gz
evas - loader - rsvg - work around rsvg now returning 0 sized dims
also work around rsvg now returning a 0 em/ex values for dimensions too. rsvg 2.52 brought us this fun. @fix
Diffstat (limited to 'src')
-rw-r--r--src/generic/evas/rsvg/main.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/generic/evas/rsvg/main.c b/src/generic/evas/rsvg/main.c
index e6389b7afc..69f8f241c6 100644
--- a/src/generic/evas/rsvg/main.c
+++ b/src/generic/evas/rsvg/main.c
@@ -99,16 +99,26 @@ read_svg_header(int scale_down, double dpi, int size_w, int size_h)
{
rsvg_handle_set_dpi(rsvg, 75.0);
-#ifndef HAVE_SVG_2_51
- rsvg_handle_get_dimensions(rsvg, &dim);
- width = dim.width;
- height = dim.height;
-#else
+#ifdef HAVE_SVG_2_51
double owidth, oheight;
rsvg_handle_get_intrinsic_size_in_pixels(rsvg, &owidth, &oheight);
width = ceil(owidth);
height = ceil(oheight);
+ if ((width == 0) || (height == 0))
+ {
+ RsvgLength l1, l2;
+ gboolean has_l1, has_l2, has_vb;
+ RsvgRectangle vb;
+
+ rsvg_handle_get_intrinsic_dimensions(rsvg, &has_l1, &l1, &has_l2, &l2, &has_vb, &vb);
+ width = ceil(vb.width);
+ height = ceil(vb.height);
+ }
+#else
+ rsvg_handle_get_dimensions(rsvg, &dim);
+ width = dim.width;
+ height = dim.height;
#endif
if ((width < 1) || (height < 1)) return 0;
@@ -153,18 +163,21 @@ read_svg_data(void)
if (!shm_addr) return 0;
memset(shm_addr, 0, width * height * sizeof (DATA32));
- surface = cairo_image_surface_create_for_data((unsigned char *)shm_addr, CAIRO_FORMAT_ARGB32,
- width, height, width * sizeof(DATA32));;
+ surface = cairo_image_surface_create_for_data((unsigned char *)shm_addr,
+ CAIRO_FORMAT_ARGB32,
+ width, height,
+ width * sizeof(DATA32));;
if (!surface) return 0;
cr = cairo_create(surface);
if (!cr) return 0;
- cairo_scale(cr, (double) width / dim.em, (double) height / dim.ex);
+ if ((dim.em > 0.0) && (dim.ex > 0.0))
+ cairo_scale(cr, (double) width / dim.em, (double) height / dim.ex);
+ else
+ cairo_scale(cr, (double)1, (double)1);
-#ifndef HAVE_SVG_2_51
- rsvg_handle_render_cairo(rsvg, cr);
-#else
+#ifdef HAVE_SVG_2_51
RsvgRectangle vp =
{
.x = 0,
@@ -172,8 +185,9 @@ read_svg_data(void)
.width = width,
.height = height,
};
-
rsvg_handle_render_document(rsvg, cr, &vp, NULL);
+#else
+ rsvg_handle_render_cairo(rsvg, cr);
#endif
cairo_surface_destroy(surface);