You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we manually calculate the size and scale parameters, based on the w and h given by the user and fitting that into the size given by rsvg_handle_get_intrinsic_dimensions.
However as of librsvg 2.52 we have to use the new rsvg_handle_render_document API which allows us to pass a viewport size to do auto-scaling. Perhaps this also makes the output work better with css.
However the thing I can't figure out is how to make this work if we don't know the viewport size beforehand, i.e. if we just want to render to the size defined in the svg itself, rather than provides by the user. The API seems to assume that the application uses a fixed size viewport, but that is not always the case.
In our application, we first create a cairo canvas using cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height), and then load the svg handle. So we need to give a width/height before loading the svg, but if the user has not specified a width/height, we want to use the width/height as specified in the svg file (which we haven't loaded yet at that point).
So for now we don't use auto-scaling yet, and keep manual scaling (with the new apis): #28
The text was updated successfully, but these errors were encountered:
First, use rsvg_handle_get_intrinsic_size_in_pixels(). If that returns true, you have a size you can use. If it doesn't, it means the SVG has something like <svg width="50%" height="100%">, which must be resolved against a viewport..
... and in that case, I think you are in the "just figure out a sensible size so I can create my surface" case. You can rsvg_handle_get_geometry_for_element(handle, NULL, &out_ink_rect, NULL, &error) to ask librsvg to actually measure the geometries of all elements. This is the implicit behavior from the old rsvg_handle_get_dimensions().
Currently we manually calculate the size and scale parameters, based on the w and h given by the user and fitting that into the size given by
rsvg_handle_get_intrinsic_dimensions
.However as of librsvg 2.52 we have to use the new
rsvg_handle_render_document
API which allows us to pass a viewport size to do auto-scaling. Perhaps this also makes the output work better with css.However the thing I can't figure out is how to make this work if we don't know the viewport size beforehand, i.e. if we just want to render to the size defined in the svg itself, rather than provides by the user. The API seems to assume that the application uses a fixed size viewport, but that is not always the case.
In our application, we first create a cairo canvas using
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height)
, and then load the svg handle. So we need to give a width/height before loading the svg, but if the user has not specified a width/height, we want to use the width/height as specified in the svg file (which we haven't loaded yet at that point).So for now we don't use auto-scaling yet, and keep manual scaling (with the new apis): #28
The text was updated successfully, but these errors were encountered: