Handle.setSizeCallback

void setSizeCallback(rsvg.types.SizeFunc sizeFunc = null)

Sets the sizing function for the handle, which can be used to override the size that librsvg computes for SVG images. The size_func is called from the following functions:

  • [rsvg.handle.Handle.getDimensions]
  • [rsvg.handle.Handle.getDimensionsSub]
  • [rsvg.handle.Handle.getPositionSub]
  • [rsvg.handle.Handle.renderCairo]
  • [rsvg.handle.Handle.renderCairoSub]

Librsvg computes the size of the SVG being rendered, and passes it to the size_func, which may then modify these values to set the final size of the generated image.

Parameters

sizeFuncA sizing function, or NULL

Deprecated

Use [rsvg.handle.Handle.renderDocument] instead.

This function was deprecated because when the size_func is used, it makes it unclear when the librsvg functions which call the size_func will use the size computed originally, or the callback-specified size, or whether it refers to the whole SVG or to just a sub-element of it. It is easier, and unambiguous, to use code similar to the example above.