TRUE if drawing succeeded; FALSE otherwise. This function will emit a g_warning()
if a rendering error occurs.
bool renderCairo(cairo.context.Context cr)Draws a loaded SVG handle to a Cairo context. Please try to use [rsvg.handle.Handle.renderDocument] instead, which allows you to pick the size at which the document will be rendered.
Historically this function has picked a size by itself, based on the following rules:
width and heightattributes with physical units (px, in, cm, mm, pt, pc) or font-based units (em, ex), the function computes the size directly based on the dots-per-inch (DPI) you have configured with [rsvg.handle.Handle.setDpi]. This is the same approach as [rsvg.handle.Handle.getIntrinsicSizeInPixels].
viewBox attribute and bothwidth and height are set to 100% (or if they don't exist at all and thus default to 100%), the function uses the width and height of the viewBox as a pixel size. This produces a rendered document with the correct aspect ratio.
document to find the total extents. This is moderately expensive, but no more expensive than rendering the whole document, for example.
widthand height because there is no viewport against which they could be resolved; that is why it will compute the extents of objects in that case. This is why we recommend that you use [rsvg.handle.Handle.renderDocument] instead, which takes in a viewport and follows the sizing policy from the web platform.
Drawing will occur with respect to the cr's current transformation: for example, if the cr has a rotated current transformation matrix, the whole SVG will be rotated in the rendered version.
This function depends on the [rsvg.handle.Handle]'s DPI to compute dimensions in pixels, so you should call [rsvg.handle.Handle.setDpi] beforehand.
Note that cr must be a Cairo context that is not in an error state, that is, [cairo.context.Context.status] must return [cairo.types.Status.Success] for it. Cairo can set a context to be in an error state in various situations, for example, if it was passed an invalid matrix or if it was created for an invalid surface.
cr | A Cairo context |
TRUE if drawing succeeded; FALSE otherwise. This function will emit a g_warning()
if a rendering error occurs.
you pass a viewport and obtain a good error message.