From a094ec850d7d20322020f934dbd6add7d5c17fc1 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Wed, 21 Jun 2023 22:26:01 -0700 Subject: [PATCH] Use rsvg_handle_get_dimensions() again, sometimes If RSVG is < 2.52.x, go back to using rsvg_handle_get_dimensions() (which is deprecated these days) instead of the newer rsvg_handle_get_intrinsic_size_in_pixels() that replaced it. (Shin-ichi reports that function is not available on Rocky Linux 9.) Note - I also recently replaced rsvg_handle_render_cairo() with rsvg_handle_render_document(), but Shin-ichi didn't report problems with that; it's been available since 2.46. See https://sourceforge.net/p/tuxpaint/bugs/278/ --- src/tuxpaint.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index b38dbce3e..82151dcf7 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - June 19, 2023 + June 14, 2002 - June 21, 2023 */ #include "platform.h" @@ -20941,7 +20941,6 @@ static SDL_Surface *_load_svg(const char *file) RsvgHandle *rsvg_handle; GError *gerr; unsigned char *image; - gdouble d_rwidth, d_rheight; int rwidth, rheight; int width, height, stride; float scale; @@ -20963,11 +20962,31 @@ static SDL_Surface *_load_svg(const char *file) return (NULL); } - rsvg_handle_get_intrinsic_size_in_pixels(rsvg_handle, &d_rwidth, &d_rheight); - rwidth = (int) d_rwidth; - rheight = (int) d_rheight; +/* rsvg_handle_get_dimensions() is deprecated since since version 2.52, + but we currently support some platforms where it's not yet available + (e.g., Rocky Linux 9) */ +#if LIBRSVG_MAJOR_VERSION < 2 || LIBRSVG_MINOR_VERSION < 52 + { + RsvgDimensionData dim; + + rsvg_handle_get_dimensions(rsvg_handle, &dim); + rwidth = dim.width; + rheight = dim.height; + + DEBUG_PRINTF("SVG is %d x %d\n", rwidth, rheight); + } +#else + { + gdouble d_rwidth, d_rheight; + + rsvg_handle_get_intrinsic_size_in_pixels(rsvg_handle, &d_rwidth, &d_rheight); + rwidth = (int) d_rwidth; + rheight = (int) d_rheight; + + DEBUG_PRINTF("SVG is %f x %f (%d x %d)\n", d_rwidth, d_rheight, rwidth, rheight); + } +#endif - DEBUG_PRINTF("SVG is %f x %f (%d x %d)\n", d_rwidth, d_rheight, rwidth, rheight); /* Pick best scale to render to (for the canvas in this instance of Tux Paint) */