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/
This commit is contained in:
Bill Kendrick 2023-06-21 22:26:01 -07:00
parent 408414a9a1
commit a094ec850d

View file

@ -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) */