Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librsvg: update to newer API #1061

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions libs/PictureImageLoader.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,23 @@ Bool PImageLoadSvg(FIMAGE_CMD_ARGS)
free(allocated_path);

/* Keep the original aspect ratio when either w or h is 0 */
#if LIBRSVG_CHECK_VERSION(2,52,0)
double ddw, ddh;
RsvgLength out_w, out_h;

rsvg_handle_get_intrinsic_size_in_pixels(rsvg, &ddw, &ddh);
dim.width = ddw;
dim.height = ddh;

rsvg_handle_get_intrinsic_dimensions(rsvg, NULL, &out_w, NULL, &out_h,
NULL, NULL);

dim.em = out_w.length;
dim.ex = out_h.length;

#else
Frsvg_handle_get_dimensions(rsvg, &dim);
#endif
if (!w && !h)
{
w = dim.width;
Expand Down Expand Up @@ -357,7 +373,19 @@ Bool PImageLoadSvg(FIMAGE_CMD_ARGS)
Fcairo_translate(cr, -.5, -.5);
Fcairo_scale(cr, 1 / dim.em, 1 / dim.ex);

#if LIBRSVG_CHECK_VERSION(2,52,0)
GError *err = NULL;
RsvgRectangle vp;

vp.x = 0;
vp.y = 0;
vp.width = dim.width;
vp.height = dim.height;

rsvg_handle_render_document(rsvg, cr, &vp, &err);
#else
Frsvg_handle_render_cairo(rsvg, cr);
#endif
Fg_object_unref(FG_OBJECT(rsvg));
Fcairo_destroy(cr);

Expand Down
Loading