Part I. API Reference

Librsvg is a library for rendering Scalable Vector Graphics 1.1 files (SVG 1.1). Specifically, it can take non-animated, non-scripted SVG data and render it into a Cairo surface. Normally this means an in-memory raster surface, but it could also be any of the other surface types that Cairo supports.

Librsvg supports many of the graphic features in the SVG 1.1 specification. The main features of SVG 1.1 that librsvg does not support are the following:

  • Scripting or animation - Librsvg reads SVG data and renders it to a static image. There is no provision to execute scripts that may control animation parameters.

  • Access to the DOM - Librsvg creates an internal representation of the SVG data, but it does not provide outside access to the resulting Document Object Model (DOM).

  • SVG fonts - Instead, librsvg relies on the system's fonts, particularly those that are available through Cairo/Pango.

<chapter> <title>Overview of Librsvg's API</title> <para> Librsvg's API is divided into two main parts: one for loading SVG data and one for rendering it. In the <emphasis>loading stage</emphasis>, you create an RsvgHandle object from SVG data, which can come from a file or from a stream of bytes. In the <emphasis>rendering stage</emphasis>, you take an RsvgHandle and ask it to render itself to a Cairo context. </para> <formalpara> <title>Loading</title> <para> RsvgHandle is an object that represents SVG data in memory. Your program creates an RsvgHandle from an SVG file, or from a memory buffer that contains SVG data, or in the most general form, from a GIO stream that will provide SVG data. At this stage you can get either I/O errors or parsing errors. If loading completes successfully, the RsvgHandle will be ready for rendering. </para> </formalpara> <formalpara> <title>Rendering</title> <para> Once you have an SVG image loaded into an RsvgHandle, you can render it to a Cairo context any number of times, or to different Cairo contexts, as needed. As a convenience, you can pick a single element in the SVG by its "id" attribute and render only that element; this is so that sub-elements can be extracted conveniently out of a larger SVG. </para> </formalpara> </chapter><refentry> <refmeta> <refentrytitle>RsvgHandle</refentrytitle> <manvolnum>3</manvolnum> <refmiscinfo>RSVG Library</refmiscinfo> </refmeta>

<refentrytitle>RsvgHandle</refentrytitle>

<refname>RsvgHandle</refname> <refpurpose>Loads SVG data into memory.</refpurpose>

<refsect1> <title>Functions</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><returnvalue>GQuark</returnvalue> </entry><entry>rsvg_error_quark <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_cleanup <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_set_default_dpi <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_set_default_dpi_x_y <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_handle_set_dpi <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_handle_set_dpi_x_y <phrase>()</phrase></entry></row> <row><entry><returnvalue>RsvgHandle</returnvalue> * </entry><entry>rsvg_handle_new <phrase>()</phrase></entry></row> <row><entry><returnvalue>RsvgHandle</returnvalue> * </entry><entry>rsvg_handle_new_with_flags <phrase>()</phrase></entry></row> <row><entry><returnvalue>gboolean</returnvalue> </entry><entry>rsvg_handle_write <phrase>()</phrase></entry></row> <row><entry><returnvalue>gboolean</returnvalue> </entry><entry>rsvg_handle_close <phrase>()</phrase></entry></row> <row><entry>const <returnvalue>char</returnvalue> * </entry><entry>rsvg_handle_get_base_uri <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_handle_set_base_uri <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_handle_get_dimensions <phrase>()</phrase></entry></row> <row><entry><returnvalue>gboolean</returnvalue> </entry><entry>rsvg_handle_get_dimensions_sub <phrase>()</phrase></entry></row> <row><entry><returnvalue>gboolean</returnvalue> </entry><entry>rsvg_handle_get_position_sub <phrase>()</phrase></entry></row> <row><entry><returnvalue>gboolean</returnvalue> </entry><entry>rsvg_handle_has_sub <phrase>()</phrase></entry></row> <row><entry>const <returnvalue>char</returnvalue> * </entry><entry>rsvg_handle_get_title <phrase>()</phrase></entry></row> <row><entry>const <returnvalue>char</returnvalue> * </entry><entry>rsvg_handle_get_desc <phrase>()</phrase></entry></row> <row><entry>const <returnvalue>char</returnvalue> * </entry><entry>rsvg_handle_get_metadata <phrase>()</phrase></entry></row> <row><entry><returnvalue>RsvgHandle</returnvalue> * </entry><entry>rsvg_handle_new_from_data <phrase>()</phrase></entry></row> <row><entry><returnvalue>RsvgHandle</returnvalue> * </entry><entry>rsvg_handle_new_from_file <phrase>()</phrase></entry></row> <row><entry><returnvalue>GType</returnvalue> </entry><entry>rsvg_error_get_type <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_init <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_term <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_handle_free <phrase>()</phrase></entry></row> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_handle_set_size_callback <phrase>()</phrase></entry></row> </tbody> </tgroup> </informaltable> </refsect1> <refsect1> <title>Types and Values</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <tbody> <row><entry>enum</entry><entry>RsvgError</entry></row> <row><entry>#define</entry><entry>RSVG_ERROR</entry></row> <row><entry>struct</entry><entry>RsvgHandle</entry></row> <row><entry>typedef</entry><entry>RsvgHandlePrivate</entry></row> <row><entry>struct</entry><entry>RsvgHandleClass</entry></row> <row><entry>struct</entry><entry>RsvgDimensionData</entry></row> <row><entry>struct</entry><entry>RsvgPositionData</entry></row> <row><entry>#define</entry><entry>RSVG_TYPE_ERROR</entry></row> </tbody> </tgroup> </informaltable> </refsect1> <refsect1> <title>Description</title> <para>This is the main entry point into the librsvg library. An RsvgHandle is an object that represents SVG data in memory. Your program creates an RsvgHandle from an SVG file, or from a memory buffer that contains SVG data, or in the most general form, from a <type>GInputStream</type> that will provide SVG data.</para> <para>Librsvg supports reading SVG 1.1 data. It also supports SVGZ files, which is just an SVG stream compressed with the GZIP algorithm.</para> <refsect2><title>The "base file" and resolving references to external files</title><para>When you load an SVG, librsvg needs to know the location of the "base file" for it. This is so that librsvg can determine the location of referenced entities. For example, say you have an SVG in <filename>/foo/bar/foo.svg</filename> and that it has an image element like this:</para> <informalexample><programlisting> <image xlink:href="resources/foo.png" .../> </programlisting></informalexample> <para></para> <para>In this case, librsvg needs to know the location of the toplevel <filename>/foo/bar/foo.svg</filename> so that it can generate the appropriate reference to <filename>/foo/bar/resources/foo.png</filename>.</para> <refsect3><title>Security and locations of referenced files</title><para>When processing an SVG, librsvg will only load referenced files if they are in the same directory as the base file, or in a subdirectory of it. That is, if the base file is <filename>/foo/bar/baz.svg</filename>, then librsvg will only try to load referenced files (from SVG's "image" element, for example, or from content included through XML entities) if those files are in <filename>/foo/bar/*</filename> or in <filename>/foo/bar/*/.../*</filename>. This is so that malicious SVG files cannot include files that are in a directory above.</para> </refsect3> </refsect2>
<refsect2><title>Loading an SVG with GIO</title><para>If you have a <type>GFile</type> that stands for an SVG file, you can simply call <function>rsvg_handle_new_from_gfile_sync()</function> to load an RsvgHandle from it.</para> <para>Alternatively, if you have a <type>GInputStream</type>, you can use <function>rsvg_handle_new_from_stream_sync()</function>.</para> <para>Both of those methods allow specifying a <type>GCancellable</type>, so the loading process can be cancelled from another thread.</para> <refsect3><title>Loading an SVG from memory</title><para>If you already have SVG data in memory, you can create a memory input stream with <function>g_memory_input_stream_new_from_data()</function> and feed that to <function>rsvg_handle_new_from_stream_sync()</function>. This lets you specify the appropriate flags, for example <type>RSVG_HANDLE_FLAG_UNLIMITED</type> if your input data is very large.</para> <para>Note that in this case, it is important that you specify the base_file for the in-memory SVG data. Librsvg uses the base_file to resolve links to external content, like raster images.</para> </refsect3> </refsect2>
<refsect2><title>Loading an SVG without GIO</title><para>You can load an RsvgHandle from a simple filename or URI with <function>rsvg_handle_new_from_file()</function>. Note that this is a blocking operation; there is no way to cancel it if loading a remote URI takes a long time.</para> <para>Alternatively, you can create an empty RsvgHandle with <function>rsvg_handle_new()</function> or <function>rsvg_handle_new_with_flags()</function>. The first function is equivalent to using <type>RSVG_HANDLE_FLAGS_NONE</type> on the second one. These functions give you back an empty RsvgHandle, which is ready for you to feed it SVG data. You can do this with <function>rsvg_handle_write()</function> and <function>rsvg_handle_close()</function>.</para> </refsect2>
<refsect2><title>Resolution of the rendered image (dots per inch, or DPI)</title><para>SVG images can contain dimensions like "<literal>5 cm</literal>" or "<literal>2 pt</literal>" that must be converted from physical units into device units. To do this, librsvg needs to know the actual dots per inch (DPI) of your target device. You can call <function>rsvg_handle_set_dpi()</function> or <function>rsvg_handle_set_dpi_x_y()</function> on an RsvgHandle to set the DPI before rendering it.</para> </refsect2>
<refsect2><title>Rendering</title><para>The preferred way to render an already-loaded RsvgHandle is to use <function>rsvg_handle_render_cairo()</function>. Please see its documentation for details.</para> <para>Alternatively, you can use <function>rsvg_handle_get_pixbuf()</function> to directly obtain a <type>GdkPixbuf</type> with the rendered image. This is simple, but it does not let you control the size at which the SVG will be rendered. It will just be rendered at the size which <function>rsvg_handle_get_dimensions()</function> would return, which depends on the dimensions that librsvg is able to compute from the SVG data.</para> </refsect2> </refsect1>
<refsect1> <title>Functions</title> <refsect2> <title>rsvg_error_quark ()</title> <programlisting><returnvalue>GQuark</returnvalue> rsvg_error_quark (<parameter><type>void</type></parameter>);</programlisting> <para>The error domain for RSVG</para> <refsect3> <title>Returns</title> <para> The error domain</para> </refsect3></refsect2>
<refsect2> <title>rsvg_cleanup ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_cleanup (<parameter><type>void</type></parameter>);</programlisting> <para>This function should not be called from normal programs. See <function>xmlCleanupParser()</function> for more information.</para> <para>Since: 2.36</para></refsect2>
<refsect2> <title>rsvg_set_default_dpi ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_set_default_dpi (<parameter><type>double</type> dpi</parameter>);</programlisting> <warning><para><literal>rsvg_set_default_dpi</literal> has been deprecated since version 2.42.3 and should not be used in newly-written code.</para> <para>This function used to set a global default DPI. However, it only worked if it was called before any <type>RsvgHandle</type> objects had been created; it would not work after that. To avoid global mutable state, please use <function>rsvg_handle_set_dpi()</function> instead.</para> </warning> <para>Do not use this function. Create an <type>RsvgHandle</type> and call <function>rsvg_handle_set_dpi()</function> on it instead.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>dpi</para></entry> <entry><para>Dots Per Inch (aka Pixels Per Inch)</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><para>Since: 2.8</para></refsect2>
<refsect2> <title>rsvg_set_default_dpi_x_y ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_set_default_dpi_x_y (<parameter><type>double</type> dpi_x</parameter>, <parameter><type>double</type> dpi_y</parameter>);</programlisting> <warning><para><literal>rsvg_set_default_dpi_x_y</literal> has been deprecated since version 2.42.3 and should not be used in newly-written code.</para> <para>This function used to set a global default DPI. However, it only worked if it was called before any <type>RsvgHandle</type> objects had been created; it would not work after that. To avoid global mutable state, please use <function>rsvg_handle_set_dpi()</function> instead.</para> </warning> <para>Do not use this function. Create an <type>RsvgHandle</type> and call <function>rsvg_handle_set_dpi_x_y()</function> on it instead.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>dpi_x</para></entry> <entry><para>Dots Per Inch (aka Pixels Per Inch)</para></entry> <entry></entry></row> <row><entry><para>dpi_y</para></entry> <entry><para>Dots Per Inch (aka Pixels Per Inch)</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><para>Since: 2.8</para></refsect2>
<refsect2> <title>rsvg_handle_set_dpi ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_handle_set_dpi (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>double</type> dpi</parameter>);</programlisting> <para>Sets the DPI for the outgoing pixbuf. Common values are 75, 90, and 300 DPI. Passing a number <= 0 to <parameter>dpi</parameter> will reset the DPI to whatever the default value happens to be.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>An <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>dpi</para></entry> <entry><para>Dots Per Inch (aka Pixels Per Inch)</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><para>Since: 2.8</para></refsect2>
<refsect2> <title>rsvg_handle_set_dpi_x_y ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_handle_set_dpi_x_y (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>double</type> dpi_x</parameter>, <parameter><type>double</type> dpi_y</parameter>);</programlisting> <para>Sets the DPI for the outgoing pixbuf. Common values are 75, 90, and 300 DPI. Passing a number <= 0 to <type>dpi_x</type> or <parameter>dpi_y</parameter> will reset the DPI to whatever the default value happens to be.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>An <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>dpi_x</para></entry> <entry><para>Dots Per Inch (aka Pixels Per Inch)</para></entry> <entry></entry></row> <row><entry><para>dpi_y</para></entry> <entry><para>Dots Per Inch (aka Pixels Per Inch)</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><para>Since: 2.8</para></refsect2>
<refsect2> <title>rsvg_handle_new ()</title> <programlisting><returnvalue>RsvgHandle</returnvalue> * rsvg_handle_new (<parameter><type>void</type></parameter>);</programlisting> <para>Returns a new rsvg handle. Must be freed with <parameter>g_object_unref</parameter> . This handle can be used for dynamically loading an image. You need to feed it data using <parameter>rsvg_handle_write</parameter> , then call <parameter>rsvg_handle_close</parameter> when done. Afterwords, you can render it using Cairo or get a GdkPixbuf from it. When finished, free with <function>g_object_unref()</function>. No more than one image can be loaded with one handle.</para> <refsect3> <title>Returns</title> <para> A new <type>RsvgHandle</type></para> </refsect3></refsect2>
<refsect2> <title>rsvg_handle_new_with_flags ()</title> <programlisting><returnvalue>RsvgHandle</returnvalue> * rsvg_handle_new_with_flags (<parameter><type>RsvgHandleFlags</type> flags</parameter>);</programlisting> <para>Creates a new <type>RsvgHandle</type> with flags <parameter>flags</parameter> .</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>flags</para></entry> <entry><para>flags from <type>RsvgHandleFlags</type></para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para>a new <type>RsvgHandle</type>. </para> <para><emphasis>[transfer full]</emphasis></para> </refsect3><para>Since: 2.36</para></refsect2>
<refsect2> <title>rsvg_handle_write ()</title> <programlisting><returnvalue>gboolean</returnvalue> rsvg_handle_write (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter>const <type>guchar</type> *buf</parameter>, <parameter><type>gsize</type> count</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <para>Loads the next <parameter>count</parameter> bytes of the image. This will return <literal>TRUE</literal> if the data was loaded successful, and <literal>FALSE</literal> if an error occurred. In the latter case, the loader will be closed, and will not accept further writes. If <literal>FALSE</literal> is returned, <parameter>error</parameter> will be set to an error from the <type>RsvgError</type> domain. Errors from <type>GIOErrorEnum</type> are also possible.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>an <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>buf</para></entry> <entry><para>pointer to svg data. </para></entry> <entry><emphasis>[array length=count][element-type guchar]</emphasis></entry></row> <row><entry><para>count</para></entry> <entry><para>length of the <parameter>buf</parameter> buffer in bytes</para></entry> <entry></entry></row> <row><entry><para>error</para></entry> <entry><para>a location to store a <type>GError</type>, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[allow-none]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> <literal>TRUE</literal> on success, or <literal>FALSE</literal> on error</para> </refsect3></refsect2>
<refsect2> <title>rsvg_handle_close ()</title> <programlisting><returnvalue>gboolean</returnvalue> rsvg_handle_close (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <para>Closes <parameter>handle</parameter> , to indicate that loading the image is complete. This will return <literal>TRUE</literal> if the loader closed successfully. Note that <parameter>handle</parameter> isn't freed until <parameter>g_object_unref</parameter> is called.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>a <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>error</para></entry> <entry><para>a location to store a <type>GError</type>, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[allow-none]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> <literal>TRUE</literal> on success, or <literal>FALSE</literal> on error</para> </refsect3></refsect2>
<refsect2> <title>rsvg_handle_get_base_uri ()</title> <programlisting>const <returnvalue>char</returnvalue> * rsvg_handle_get_base_uri (<parameter><type>RsvgHandle</type> *handle</parameter>);</programlisting> <para>Gets the base uri for this <type>RsvgHandle</type>.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>A <type>RsvgHandle</type></para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> the base uri, possibly null</para> </refsect3><para>Since: 2.8</para></refsect2>
<refsect2> <title>rsvg_handle_set_base_uri ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_handle_set_base_uri (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter>const <type>char</type> *base_uri</parameter>);</programlisting> <para>Set the base URI for this SVG. This can only be called before <function>rsvg_handle_write()</function> has been called.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>A <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>base_uri</para></entry> <entry><para>The base uri</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><para>Since: 2.9</para></refsect2>
<refsect2> <title>rsvg_handle_get_dimensions ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_handle_get_dimensions (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>RsvgDimensionData</type> *dimension_data</parameter>);</programlisting> <para>Get the SVG's size. Do not call from within the size_func callback, because an infinite loop will occur.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>A <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>dimension_data</para></entry> <entry><para>A place to store the SVG's size. </para></entry> <entry><emphasis>[out]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><para>Since: 2.14</para></refsect2>
<refsect2> <title>rsvg_handle_get_dimensions_sub ()</title> <programlisting><returnvalue>gboolean</returnvalue> rsvg_handle_get_dimensions_sub (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>RsvgDimensionData</type> *dimension_data</parameter>, <parameter>const <type>char</type> *id</parameter>);</programlisting> <para>Get the size of a subelement of the SVG file. Do not call from within the size_func callback, because an infinite loop will occur.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>A <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>dimension_data</para></entry> <entry><para>A place to store the SVG's size. </para></entry> <entry><emphasis>[out]</emphasis></entry></row> <row><entry><para>id</para></entry> <entry><para>An element's id within the SVG, starting with "##", for example, "#<type>layer1</type>"; or <literal>NULL</literal> to use the whole SVG. </para></entry> <entry><emphasis>[nullable]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><para>Since: 2.22</para></refsect2>
<refsect2> <title>rsvg_handle_get_position_sub ()</title> <programlisting><returnvalue>gboolean</returnvalue> rsvg_handle_get_position_sub (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>RsvgPositionData</type> *position_data</parameter>, <parameter>const <type>char</type> *id</parameter>);</programlisting> <para>Get the position of a subelement of the SVG file. Do not call from within the size_func callback, because an infinite loop will occur.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>A <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>position_data</para></entry> <entry><para>A place to store the SVG fragment's position. </para></entry> <entry><emphasis>[out]</emphasis></entry></row> <row><entry><para>id</para></entry> <entry><para>An element's id within the SVG, starting with "##", for example, "#<type>layer1</type>"; or <literal>NULL</literal> to use the whole SVG. </para></entry> <entry><emphasis>[nullable]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><para>Since: 2.22</para></refsect2>
<refsect2> <title>rsvg_handle_has_sub ()</title> <programlisting><returnvalue>gboolean</returnvalue> rsvg_handle_has_sub (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter>const <type>char</type> *id</parameter>);</programlisting> <para>Checks whether the element <parameter>id</parameter> exists in the SVG document.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>a <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>id</para></entry> <entry><para>an element's id within the SVG, starting with "##", for example, "#<type>layer1</type>".</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> <literal>TRUE</literal> if <parameter>id</parameter> exists in the SVG document</para> </refsect3><para>Since: 2.22</para></refsect2>
<refsect2> <title>rsvg_handle_get_title ()</title> <programlisting>const <returnvalue>char</returnvalue> * rsvg_handle_get_title (<parameter><type>RsvgHandle</type> *handle</parameter>);</programlisting> <warning><para><literal>rsvg_handle_get_title</literal> has been deprecated since version 2.36 and should not be used in newly-written code.</para></warning> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>An <type>RsvgHandle</type></para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para>This function always returns NULL. </para> <para><emphasis>[nullable]</emphasis></para> </refsect3><para>Since: 2.4</para></refsect2>
<refsect2> <title>rsvg_handle_get_desc ()</title> <programlisting>const <returnvalue>char</returnvalue> * rsvg_handle_get_desc (<parameter><type>RsvgHandle</type> *handle</parameter>);</programlisting> <warning><para><literal>rsvg_handle_get_desc</literal> has been deprecated since version 2.36 and should not be used in newly-written code.</para></warning> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>An <type>RsvgHandle</type></para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para>This function always returns NULL. </para> <para><emphasis>[nullable]</emphasis></para> </refsect3><para>Since: 2.4</para></refsect2>
<refsect2> <title>rsvg_handle_get_metadata ()</title> <programlisting>const <returnvalue>char</returnvalue> * rsvg_handle_get_metadata (<parameter><type>RsvgHandle</type> *handle</parameter>);</programlisting> <warning><para><literal>rsvg_handle_get_metadata</literal> has been deprecated since version 2.36 and should not be used in newly-written code.</para></warning> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>An <type>RsvgHandle</type></para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para>This function always returns <type>NULL</type>. </para> <para><emphasis>[nullable]</emphasis></para> </refsect3><para>Since: 2.9</para></refsect2>
<refsect2> <title>rsvg_handle_new_from_data ()</title> <programlisting><returnvalue>RsvgHandle</returnvalue> * rsvg_handle_new_from_data (<parameter>const <type>guint8</type> *data</parameter>, <parameter><type>gsize</type> data_len</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <para>Loads the SVG specified by <parameter>data</parameter> .</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>data</para></entry> <entry><para>The SVG data. </para></entry> <entry><emphasis>[array length=data_len]</emphasis></entry></row> <row><entry><para>data_len</para></entry> <entry><para>The length of <parameter>data</parameter> , in bytes</para></entry> <entry></entry></row> <row><entry><para>error</para></entry> <entry><para>return location for errors</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> A <type>RsvgHandle</type> or <literal>NULL</literal> if an error occurs.</para> </refsect3><para>Since: 2.14</para></refsect2>
<refsect2> <title>rsvg_handle_new_from_file ()</title> <programlisting><returnvalue>RsvgHandle</returnvalue> * rsvg_handle_new_from_file (<parameter>const <type>gchar</type> *file_name</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <para>Loads the SVG specified by <parameter>file_name</parameter> .</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>file_name</para></entry> <entry><para>The file name to load. If built with gnome-vfs, can be a URI.</para></entry> <entry></entry></row> <row><entry><para>error</para></entry> <entry><para>return location for errors</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> A <type>RsvgHandle</type> or <literal>NULL</literal> if an error occurs.</para> </refsect3><para>Since: 2.14</para></refsect2>
<refsect2> <title>rsvg_error_get_type ()</title> <programlisting><returnvalue>GType</returnvalue> rsvg_error_get_type (<parameter><type>void</type></parameter>);</programlisting> </refsect2>
<refsect2> <title>rsvg_init ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_init (<parameter><type>void</type></parameter>);</programlisting> <warning><para><literal>rsvg_init</literal> has been deprecated since version 2.36 and should not be used in newly-written code.</para> <para>There is no need to initialize librsvg.</para> </warning> <para>This function does nothing.</para> <para>Since: 2.9</para></refsect2>
<refsect2> <title>rsvg_term ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_term (<parameter><type>void</type></parameter>);</programlisting> <warning><para><literal>rsvg_term</literal> has been deprecated since version 2.36 and should not be used in newly-written code.</para> <para>There is no need to de-initialize librsvg.</para> </warning> <para>This function does nothing.</para> <para>Since: 2.9</para></refsect2>
<refsect2> <title>rsvg_handle_free ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_handle_free (<parameter><type>RsvgHandle</type> *handle</parameter>);</programlisting> <warning><para><literal>rsvg_handle_free</literal> is deprecated and should not be used in newly-written code.</para> <para>Use <function>g_object_unref()</function> instead.</para> </warning> <para>Frees <parameter>handle</parameter> .</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>An <type>RsvgHandle</type></para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3></refsect2>
<refsect2> <title>rsvg_handle_set_size_callback ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_handle_set_size_callback (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>RsvgSizeFunc</type> size_func</parameter>, <parameter><type>gpointer</type> user_data</parameter>, <parameter><type>GDestroyNotify</type> user_data_destroy</parameter>);</programlisting> <warning><para><literal>rsvg_handle_set_size_callback</literal> is deprecated and should not be used in newly-written code.</para> <para>Set up a cairo matrix and use <function>rsvg_handle_render_cairo()</function> instead. You can call <function>rsvg_handle_get_dimensions()</function> to figure out the size of your SVG, and then scale it to the desired size via Cairo. For example, the following code renders an SVG at a specified size, scaled proportionally from whatever original size it may have had:</para> <informalexample><programlisting> void render_scaled_proportionally (RsvgHandle *handle, cairo_t cr, int width, int height) { RsvgDimensionData dimensions; double x_factor, y_factor; double scale_factor; rsvg_handle_get_dimensions (handle, &dimensions); x_factor = (double) width / dimensions.width; y_factor = (double) height / dimensions.height; scale_factor = MIN (x_factor, y_factor); cairo_scale (cr, scale_factor, scale_factor); rsvg_handle_render_cairo (handle, cr); } </programlisting></informalexample> <para></para> </warning> <para>Sets the sizing function for the <parameter>handle</parameter> . This function is called right after the size of the image has been loaded. The size of the image is passed in to the function, which may then modify these values to set the real size of the generated pixbuf. If the image has no associated size, then the size arguments are set to -1.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>An <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>size_func</para></entry> <entry><para>A sizing function, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[nullable]</emphasis></entry></row> <row><entry><para>user_data</para></entry> <entry><para>User data to pass to <parameter>size_func</parameter> , or <literal>NULL</literal></para></entry> <entry></entry></row> <row><entry><para>user_data_destroy</para></entry> <entry><para>Destroy function for <parameter>user_data</parameter> , or <literal>NULL</literal></para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3></refsect2> </refsect1>
<refsect1> <title>Types and Values</title> <refsect2> <title>enum RsvgError</title> <para>An enumeration representing possible errors</para> <refsect3> <title>Members</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>RSVG_ERROR_FAILED</para></entry> <entry><para>the request failed</para> </entry> <entry></entry> </row> </tbody></tgroup></informaltable> </refsect3></refsect2>
<refsect2> <title>RSVG_ERROR</title> <programlisting>#define RSVG_ERROR (rsvg_error_quark ()) </programlisting> </refsect2>
<refsect2> <title>struct RsvgHandle</title> <programlisting>struct RsvgHandle { GObject parent; }; </programlisting> <para>Lets you load SVG data and render it.</para> <refsect3> <title>Members</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para><type>GObject</type> <structfield>parent</structfield>;</para></entry> <entry><para>parent instance</para></entry> <entry></entry> </row> </tbody></tgroup></informaltable> </refsect3> </refsect2>
<refsect2> <title>RsvgHandlePrivate</title> <programlisting>typedef struct RsvgHandlePrivate RsvgHandlePrivate; </programlisting> </refsect2>
<refsect2> <title>struct RsvgHandleClass</title> <programlisting>struct RsvgHandleClass { GObjectClass parent; }; </programlisting> <para>Class structure for <type>RsvgHandle</type>.</para> <refsect3> <title>Members</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para><type>GObjectClass</type> <structfield>parent</structfield>;</para></entry> <entry><para>parent class</para></entry> <entry></entry> </row> </tbody></tgroup></informaltable> </refsect3> </refsect2>
<refsect2> <title>struct RsvgDimensionData</title> <programlisting>struct RsvgDimensionData { int width; int height; gdouble em; gdouble ex; }; </programlisting> <refsect3> <title>Members</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para><type>int</type> <structfield>width</structfield>;</para></entry> <entry><para>SVG's width, in pixels</para></entry> <entry></entry> </row> <row><entry><para><type>int</type> <structfield>height</structfield>;</para></entry> <entry><para>SVG's height, in pixels</para></entry> <entry></entry> </row> <row><entry><para><type>gdouble</type> <structfield>em</structfield>;</para></entry> <entry><para>em</para></entry> <entry></entry> </row> <row><entry><para><type>gdouble</type> <structfield>ex</structfield>;</para></entry> <entry><para>ex</para></entry> <entry></entry> </row> </tbody></tgroup></informaltable> </refsect3> </refsect2>
<refsect2> <title>struct RsvgPositionData</title> <programlisting>struct RsvgPositionData { int x; int y; }; </programlisting> <para>Position of an SVG fragment.</para> <refsect3> <title>Members</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para><type>int</type> <structfield>x</structfield>;</para></entry> <entry><para>position on the x axis</para></entry> <entry></entry> </row> <row><entry><para><type>int</type> <structfield>y</structfield>;</para></entry> <entry><para>position on the y axis</para></entry> <entry></entry> </row> </tbody></tgroup></informaltable> </refsect3> </refsect2>
<refsect2> <title>RSVG_TYPE_ERROR</title> <programlisting>#define RSVG_TYPE_ERROR (rsvg_error_get_type()) </programlisting> </refsect2> </refsect1>
</refentry>
<refentry> <refmeta> <refentrytitle>Using RSVG with GIO</refentrytitle> <manvolnum>3</manvolnum> <refmiscinfo>RSVG Library</refmiscinfo> </refmeta>

<refentrytitle>Using RSVG with GIO</refentrytitle>

<refname>Using RSVG with GIO</refname> <refpurpose></refpurpose>

<refsect1> <title>Functions</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><returnvalue>void</returnvalue> </entry><entry>rsvg_handle_set_base_gfile <phrase>()</phrase></entry></row> <row><entry><returnvalue>gboolean</returnvalue> </entry><entry>rsvg_handle_read_stream_sync <phrase>()</phrase></entry></row> <row><entry><returnvalue>RsvgHandle</returnvalue> * </entry><entry>rsvg_handle_new_from_gfile_sync <phrase>()</phrase></entry></row> <row><entry><returnvalue>RsvgHandle</returnvalue> * </entry><entry>rsvg_handle_new_from_stream_sync <phrase>()</phrase></entry></row> </tbody> </tgroup> </informaltable> </refsect1> <refsect1> <title>Types and Values</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <tbody> <row><entry>enum</entry><entry>RsvgHandleFlags</entry></row> </tbody> </tgroup> </informaltable> </refsect1> <refsect1> <title>Description</title> </refsect1> <refsect1> <title>Functions</title> <refsect2> <title>rsvg_handle_set_base_gfile ()</title> <programlisting><returnvalue>void</returnvalue> rsvg_handle_set_base_gfile (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>GFile</type> *base_file</parameter>);</programlisting> <para>Set the base URI for <parameter>handle</parameter> from <parameter>file</parameter> . Note: This function may only be called before <function>rsvg_handle_write()</function> or <function>rsvg_handle_read_stream_sync()</function> has been called.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>a <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>base_file</para></entry> <entry><para>a <type>GFile</type></para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><para>Since: 2.32</para></refsect2>
<refsect2> <title>rsvg_handle_read_stream_sync ()</title> <programlisting><returnvalue>gboolean</returnvalue> rsvg_handle_read_stream_sync (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>GInputStream</type> *stream</parameter>, <parameter><type>GCancellable</type> *cancellable</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <para>Reads <parameter>stream</parameter> and writes the data from it to <parameter>handle</parameter> .</para> <para>If <parameter>cancellable</parameter> is not <literal>NULL</literal>, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error <literal>G_IO_ERROR_CANCELLED</literal> will be returned.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>a <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>stream</para></entry> <entry><para>a <type>GInputStream</type></para></entry> <entry></entry></row> <row><entry><para>cancellable</para></entry> <entry><para>a <type>GCancellable</type>, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[allow-none]</emphasis></entry></row> <row><entry><para>error</para></entry> <entry><para>a location to store a <type>GError</type>, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[allow-none]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> <literal>TRUE</literal> if reading <parameter>stream</parameter> succeeded, or <literal>FALSE</literal> otherwise with <parameter>error</parameter> filled in</para> </refsect3><para>Since: 2.32</para></refsect2>
<refsect2> <title>rsvg_handle_new_from_gfile_sync ()</title> <programlisting><returnvalue>RsvgHandle</returnvalue> * rsvg_handle_new_from_gfile_sync (<parameter><type>GFile</type> *file</parameter>, <parameter><type>RsvgHandleFlags</type> flags</parameter>, <parameter><type>GCancellable</type> *cancellable</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <para>Creates a new <type>RsvgHandle</type> for <parameter>file</parameter> .</para> <para>If <parameter>cancellable</parameter> is not <literal>NULL</literal>, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error <literal>G_IO_ERROR_CANCELLED</literal> will be returned.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>file</para></entry> <entry><para>a <type>GFile</type></para></entry> <entry></entry></row> <row><entry><para>flags</para></entry> <entry><para>flags from <type>RsvgHandleFlags</type></para></entry> <entry></entry></row> <row><entry><para>cancellable</para></entry> <entry><para>a <type>GCancellable</type>, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[allow-none]</emphasis></entry></row> <row><entry><para>error</para></entry> <entry><para>a location to store a <type>GError</type>, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[allow-none]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> a new <type>RsvgHandle</type> on success, or <literal>NULL</literal> with <parameter>error</parameter> filled in</para> </refsect3><para>Since: 2.32</para></refsect2>
<refsect2> <title>rsvg_handle_new_from_stream_sync ()</title> <programlisting><returnvalue>RsvgHandle</returnvalue> * rsvg_handle_new_from_stream_sync (<parameter><type>GInputStream</type> *input_stream</parameter>, <parameter><type>GFile</type> *base_file</parameter>, <parameter><type>RsvgHandleFlags</type> flags</parameter>, <parameter><type>GCancellable</type> *cancellable</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <para>Creates a new <type>RsvgHandle</type> for <parameter>stream</parameter> .</para> <para>If <parameter>cancellable</parameter> is not <literal>NULL</literal>, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error <literal>G_IO_ERROR_CANCELLED</literal> will be returned.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>input_stream</para></entry> <entry><para>a <type>GInputStream</type></para></entry> <entry></entry></row> <row><entry><para>base_file</para></entry> <entry><para>a <type>GFile</type>, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[allow-none]</emphasis></entry></row> <row><entry><para>flags</para></entry> <entry><para>flags from <type>RsvgHandleFlags</type></para></entry> <entry></entry></row> <row><entry><para>cancellable</para></entry> <entry><para>a <type>GCancellable</type>, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[allow-none]</emphasis></entry></row> <row><entry><para>error</para></entry> <entry><para>a location to store a <type>GError</type>, or <literal>NULL</literal>. </para></entry> <entry><emphasis>[allow-none]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> a new <type>RsvgHandle</type> on success, or <literal>NULL</literal> with <parameter>error</parameter> filled in</para> </refsect3><para>Since: 2.32</para></refsect2> </refsect1>
<refsect1> <title>Types and Values</title> <refsect2> <title>enum RsvgHandleFlags</title> <refsect3> <title>Members</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>RSVG_HANDLE_FLAGS_NONE</para></entry> <entry><para>none</para> </entry> <entry></entry> </row> <row><entry><para>RSVG_HANDLE_FLAG_UNLIMITED</para></entry> <entry><para>Allow any SVG XML without size limitations. For security reasons, this should only be used for trusted input! Since: 2.40.3</para> </entry> <entry></entry> </row> <row><entry><para>RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA</para></entry> <entry><para>Keeps the image data when loading images, for use by cairo when painting to e.g. a PDF surface. This will make the resulting PDF file smaller and faster. Since: 2.40.3</para> </entry> <entry></entry> </row> </tbody></tgroup></informaltable> </refsect3></refsect2> </refsect1> </refentry>
<refentry> <refmeta> <refentrytitle>Using RSVG with cairo</refentrytitle> <manvolnum>3</manvolnum> <refmiscinfo>RSVG Library</refmiscinfo> </refmeta>

<refentrytitle>Using RSVG with cairo</refentrytitle>

<refname>Using RSVG with cairo</refname> <refpurpose></refpurpose>

<refsect1> <title>Functions</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><returnvalue>gboolean</returnvalue> </entry><entry>rsvg_handle_render_cairo <phrase>()</phrase></entry></row> <row><entry><returnvalue>gboolean</returnvalue> </entry><entry>rsvg_handle_render_cairo_sub <phrase>()</phrase></entry></row> </tbody> </tgroup> </informaltable> </refsect1> <refsect1> <title>Description</title> </refsect1> <refsect1> <title>Functions</title> <refsect2> <title>rsvg_handle_render_cairo ()</title> <programlisting><returnvalue>gboolean</returnvalue> rsvg_handle_render_cairo (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>cairo_t</type> *cr</parameter>);</programlisting> <para>Draws a loaded SVG handle to a Cairo context. Drawing will occur with respect to the <parameter>cr</parameter> 's current transformation: for example, if the <parameter>cr</parameter> has a rotated current transformation matrix, the whole SVG will be rotated in the rendered version.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>A <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>cr</para></entry> <entry><para>A Cairo renderer</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> <literal>TRUE</literal> if drawing succeeded; <literal>FALSE</literal> otherwise.</para> </refsect3><para>Since: 2.14</para></refsect2>
<refsect2> <title>rsvg_handle_render_cairo_sub ()</title> <programlisting><returnvalue>gboolean</returnvalue> rsvg_handle_render_cairo_sub (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter><type>cairo_t</type> *cr</parameter>, <parameter>const <type>char</type> *id</parameter>);</programlisting> <para>Draws a subset of a loaded SVG handle to a Cairo context. Drawing will occur with respect to the <parameter>cr</parameter> 's current transformation: for example, if the <parameter>cr</parameter> has a rotated current transformation matrix, the whole SVG will be rotated in the rendered version.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>A <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>cr</para></entry> <entry><para>A Cairo renderer</para></entry> <entry></entry></row> <row><entry><para>id</para></entry> <entry><para>An element's id within the SVG, or <literal>NULL</literal> to render the whole SVG. For example, if you have a layer called "layer1" that you wish to render, pass "#<type>layer1</type>" as the id. </para></entry> <entry><emphasis>[nullable]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> <literal>TRUE</literal> if drawing succeeded; <literal>FALSE</literal> otherwise.</para> </refsect3><para>Since: 2.14</para></refsect2> </refsect1>
<refsect1> <title>Types and Values</title> </refsect1> </refentry>
<refentry> <refmeta> <refentrytitle>Using RSVG with GdkPixbuf</refentrytitle> <manvolnum>3</manvolnum> <refmiscinfo>RSVG Library</refmiscinfo> </refmeta>

<refentrytitle>Using RSVG with GdkPixbuf</refentrytitle>

<refname>Using RSVG with GdkPixbuf</refname> <refpurpose>How to render SVGs into GdkPixbufs, for easy use in GTK+ applications</refpurpose>

<refsect1> <title>Functions</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><returnvalue>GdkPixbuf</returnvalue> * </entry><entry>rsvg_handle_get_pixbuf <phrase>()</phrase></entry></row> <row><entry><returnvalue>GdkPixbuf</returnvalue> * </entry><entry>rsvg_handle_get_pixbuf_sub <phrase>()</phrase></entry></row> <row><entry><returnvalue>GdkPixbuf</returnvalue> * </entry><entry>rsvg_pixbuf_from_file <phrase>()</phrase></entry></row> <row><entry><returnvalue>GdkPixbuf</returnvalue> * </entry><entry>rsvg_pixbuf_from_file_at_zoom <phrase>()</phrase></entry></row> <row><entry><returnvalue>GdkPixbuf</returnvalue> * </entry><entry>rsvg_pixbuf_from_file_at_size <phrase>()</phrase></entry></row> <row><entry><returnvalue>GdkPixbuf</returnvalue> * </entry><entry>rsvg_pixbuf_from_file_at_max_size <phrase>()</phrase></entry></row> <row><entry><returnvalue>GdkPixbuf</returnvalue> * </entry><entry>rsvg_pixbuf_from_file_at_zoom_with_max <phrase>()</phrase></entry></row> </tbody> </tgroup> </informaltable> </refsect1> <refsect1> <title>Description</title> <para>GdkPixbuf is a library for image loading and manipulation. It is part of the cross-platform GTK+ widget toolkit.</para> </refsect1> <refsect1> <title>Functions</title> <refsect2> <title>rsvg_handle_get_pixbuf ()</title> <programlisting><returnvalue>GdkPixbuf</returnvalue> * rsvg_handle_get_pixbuf (<parameter><type>RsvgHandle</type> *handle</parameter>);</programlisting> <para>Returns the pixbuf loaded by <parameter>handle</parameter> . The pixbuf returned will be reffed, so the caller of this function must assume that ref. If insufficient data has been read to create the pixbuf, or an error occurred in loading, then <literal>NULL</literal> will be returned. Note that the pixbuf may not be complete until <parameter>rsvg_handle_close</parameter> has been called.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>An <type>RsvgHandle</type></para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para>the pixbuf loaded by <parameter>handle</parameter> , or <literal>NULL</literal>. </para> <para><emphasis>[transfer full][nullable]</emphasis></para> </refsect3></refsect2>
<refsect2> <title>rsvg_handle_get_pixbuf_sub ()</title> <programlisting><returnvalue>GdkPixbuf</returnvalue> * rsvg_handle_get_pixbuf_sub (<parameter><type>RsvgHandle</type> *handle</parameter>, <parameter>const <type>char</type> *id</parameter>);</programlisting> <para>Creates a <type>GdkPixbuf</type> the same size as the entire SVG loaded into <parameter>handle</parameter> , but only renders the sub-element that has the specified <parameter>id</parameter> (and all its sub-sub-elements recursively). If <parameter>id</parameter> is <type>NULL</type>, this function renders the whole SVG.</para> <para>If you need to render an image which is only big enough to fit a particular sub-element of the SVG, consider using <function>rsvg_handle_render_cairo_sub()</function>, upon a surface that is just the size returned by <function>rsvg_handle_get_dimensions_sub()</function>. You will need to offset the rendering by the amount returned in <function>rsvg_handle_get_position_sub()</function>.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>handle</para></entry> <entry><para>An <type>RsvgHandle</type></para></entry> <entry></entry></row> <row><entry><para>id</para></entry> <entry><para>An element's id within the SVG, starting with "##", for example, "#<type>layer1</type>"; or <literal>NULL</literal> to use the whole SVG. </para></entry> <entry><emphasis>[nullable]</emphasis></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para>a pixbuf, or <literal>NULL</literal> if an error occurs during rendering. </para> <para><emphasis>[transfer full][nullable]</emphasis></para> </refsect3><para>Since: 2.14</para></refsect2>
<refsect2> <title>rsvg_pixbuf_from_file ()</title> <programlisting><returnvalue>GdkPixbuf</returnvalue> * rsvg_pixbuf_from_file (<parameter>const <type>gchar</type> *file_name</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <warning><para><literal>rsvg_pixbuf_from_file</literal> is deprecated and should not be used in newly-written code.</para> <para>Set up a cairo matrix and use <function>rsvg_handle_new_from_file()</function> + <function>rsvg_handle_render_cairo()</function> instead.</para> </warning> <para>Loads a new <type>GdkPixbuf</type> from <parameter>file_name</parameter> and returns it. The caller must assume the reference to the reurned pixbuf. If an error occurred, <parameter>error</parameter> is set and <literal>NULL</literal> is returned.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>file_name</para></entry> <entry><para>A file name</para></entry> <entry></entry></row> <row><entry><para>error</para></entry> <entry><para>return location for errors</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> A newly allocated <type>GdkPixbuf</type>, or <literal>NULL</literal></para> </refsect3></refsect2>
<refsect2> <title>rsvg_pixbuf_from_file_at_zoom ()</title> <programlisting><returnvalue>GdkPixbuf</returnvalue> * rsvg_pixbuf_from_file_at_zoom (<parameter>const <type>gchar</type> *file_name</parameter>, <parameter><type>double</type> x_zoom</parameter>, <parameter><type>double</type> y_zoom</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <warning><para><literal>rsvg_pixbuf_from_file_at_zoom</literal> is deprecated and should not be used in newly-written code.</para> <para>Set up a cairo matrix and use <function>rsvg_handle_new_from_file()</function> + <function>rsvg_handle_render_cairo()</function> instead.</para> </warning> <para>Loads a new <type>GdkPixbuf</type> from <parameter>file_name</parameter> and returns it. This pixbuf is scaled from the size indicated by the file by a factor of <parameter>x_zoom</parameter> and <parameter>y_zoom</parameter> . The caller must assume the reference to the returned pixbuf. If an error occurred, <parameter>error</parameter> is set and <literal>NULL</literal> is returned.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>file_name</para></entry> <entry><para>A file name</para></entry> <entry></entry></row> <row><entry><para>x_zoom</para></entry> <entry><para>The horizontal zoom factor</para></entry> <entry></entry></row> <row><entry><para>y_zoom</para></entry> <entry><para>The vertical zoom factor</para></entry> <entry></entry></row> <row><entry><para>error</para></entry> <entry><para>return location for errors</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> A newly allocated <type>GdkPixbuf</type>, or <literal>NULL</literal></para> </refsect3></refsect2>
<refsect2> <title>rsvg_pixbuf_from_file_at_size ()</title> <programlisting><returnvalue>GdkPixbuf</returnvalue> * rsvg_pixbuf_from_file_at_size (<parameter>const <type>gchar</type> *file_name</parameter>, <parameter><type>gint</type> width</parameter>, <parameter><type>gint</type> height</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <warning><para><literal>rsvg_pixbuf_from_file_at_size</literal> is deprecated and should not be used in newly-written code.</para> <para>Set up a cairo matrix and use <function>rsvg_handle_new_from_file()</function> + <function>rsvg_handle_render_cairo()</function> instead.</para> </warning> <para>Loads a new <type>GdkPixbuf</type> from <parameter>file_name</parameter> and returns it. This pixbuf is scaled from the size indicated to the new size indicated by <parameter>width</parameter> and <parameter>height</parameter> . If either of these are -1, then the default size of the image being loaded is used. The caller must assume the reference to the returned pixbuf. If an error occurred, <parameter>error</parameter> is set and <literal>NULL</literal> is returned.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>file_name</para></entry> <entry><para>A file name</para></entry> <entry></entry></row> <row><entry><para>width</para></entry> <entry><para>The new width, or -1</para></entry> <entry></entry></row> <row><entry><para>height</para></entry> <entry><para>The new height, or -1</para></entry> <entry></entry></row> <row><entry><para>error</para></entry> <entry><para>return location for errors</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> A newly allocated <type>GdkPixbuf</type>, or <literal>NULL</literal></para> </refsect3></refsect2>
<refsect2> <title>rsvg_pixbuf_from_file_at_max_size ()</title> <programlisting><returnvalue>GdkPixbuf</returnvalue> * rsvg_pixbuf_from_file_at_max_size (<parameter>const <type>gchar</type> *file_name</parameter>, <parameter><type>gint</type> max_width</parameter>, <parameter><type>gint</type> max_height</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <warning><para><literal>rsvg_pixbuf_from_file_at_max_size</literal> is deprecated and should not be used in newly-written code.</para> <para>Set up a cairo matrix and use <function>rsvg_handle_new_from_file()</function> + <function>rsvg_handle_render_cairo()</function> instead.</para> </warning> <para>Loads a new <type>GdkPixbuf</type> from <parameter>file_name</parameter> and returns it. This pixbuf is uniformly scaled so that the it fits into a rectangle of size max_width * max_height. The caller must assume the reference to the returned pixbuf. If an error occurred, <parameter>error</parameter> is set and <literal>NULL</literal> is returned.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>file_name</para></entry> <entry><para>A file name</para></entry> <entry></entry></row> <row><entry><para>max_width</para></entry> <entry><para>The requested max width</para></entry> <entry></entry></row> <row><entry><para>max_height</para></entry> <entry><para>The requested max heigh</para></entry> <entry></entry></row> <row><entry><para>error</para></entry> <entry><para>return location for errors</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> A newly allocated <type>GdkPixbuf</type>, or <literal>NULL</literal></para> </refsect3></refsect2>
<refsect2> <title>rsvg_pixbuf_from_file_at_zoom_with_max ()</title> <programlisting><returnvalue>GdkPixbuf</returnvalue> * rsvg_pixbuf_from_file_at_zoom_with_max (<parameter>const <type>gchar</type> *file_name</parameter>, <parameter><type>double</type> x_zoom</parameter>, <parameter><type>double</type> y_zoom</parameter>, <parameter><type>gint</type> max_width</parameter>, <parameter><type>gint</type> max_height</parameter>, <parameter><type>GError</type> **error</parameter>);</programlisting> <warning><para><literal>rsvg_pixbuf_from_file_at_zoom_with_max</literal> is deprecated and should not be used in newly-written code.</para> <para>Set up a cairo matrix and use <function>rsvg_handle_new_from_file()</function> + <function>rsvg_handle_render_cairo()</function> instead.</para> </warning> <para>Loads a new <type>GdkPixbuf</type> from <parameter>file_name</parameter> and returns it. This pixbuf is scaled from the size indicated by the file by a factor of <parameter>x_zoom</parameter> and <parameter>y_zoom</parameter> . If the resulting pixbuf would be larger than max_width/max_heigh it is uniformly scaled down to fit in that rectangle. The caller must assume the reference to the returned pixbuf. If an error occurred, <parameter>error</parameter> is set and <literal>NULL</literal> is returned.</para> <refsect3> <title>Parameters</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <colspec></colspec> <tbody> <row><entry><para>file_name</para></entry> <entry><para>A file name</para></entry> <entry></entry></row> <row><entry><para>x_zoom</para></entry> <entry><para>The horizontal zoom factor</para></entry> <entry></entry></row> <row><entry><para>y_zoom</para></entry> <entry><para>The vertical zoom factor</para></entry> <entry></entry></row> <row><entry><para>max_width</para></entry> <entry><para>The requested max width</para></entry> <entry></entry></row> <row><entry><para>max_height</para></entry> <entry><para>The requested max heigh</para></entry> <entry></entry></row> <row><entry><para>error</para></entry> <entry><para>return location for errors</para></entry> <entry></entry></row> </tbody></tgroup></informaltable> </refsect3><refsect3> <title>Returns</title> <para> A newly allocated <type>GdkPixbuf</type>, or <literal>NULL</literal></para> </refsect3></refsect2> </refsect1>
<refsect1> <title>Types and Values</title> </refsect1> </refentry>
<refentry> <refmeta> <refentrytitle>Version check and feature tests</refentrytitle> <manvolnum>3</manvolnum> <refmiscinfo>RSVG Library</refmiscinfo> </refmeta>

<refentrytitle>Version check and feature tests</refentrytitle>

<refname>Version check and feature tests</refname> <refpurpose></refpurpose>

<refsect1> <title>Functions</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <tbody> <row><entry>#define</entry><entry>LIBRSVG_CHECK_VERSION<phrase>()</phrase></entry></row> <row><entry>#define</entry><entry>LIBRSVG_CHECK_FEATURE<phrase>()</phrase></entry></row> </tbody> </tgroup> </informaltable> </refsect1> <refsect1> <title>Types and Values</title> <informaltable> <tgroup> <colspec></colspec> <colspec></colspec> <tbody> <row><entry>#define</entry><entry>LIBRSVG_MAJOR_VERSION</entry></row> <row><entry>#define</entry><entry>LIBRSVG_MINOR_VERSION</entry></row> <row><entry>#define</entry><entry>LIBRSVG_MICRO_VERSION</entry></row> <row><entry>#define</entry><entry>LIBRSVG_VERSION</entry></row> <row><entry>#define</entry><entry>LIBRSVG_HAVE_SVGZ</entry></row> <row><entry>#define</entry><entry>LIBRSVG_HAVE_CSS</entry></row> </tbody> </tgroup> </informaltable> </refsect1> <refsect1> <title>Description</title> </refsect1> <refsect1> <title>Functions</title> <refsect2> <title>LIBRSVG_CHECK_VERSION()</title> <programlisting>#define LIBRSVG_CHECK_VERSION(major,minor,micro)</programlisting> </refsect2>
<refsect2> <title>LIBRSVG_CHECK_FEATURE()</title> <programlisting>#define LIBRSVG_CHECK_FEATURE(FEATURE) (defined(LIBRSVG_HAVE_##FEATURE) && LIBRSVG_HAVE_##FEATURE) </programlisting> </refsect2> </refsect1>
<refsect1> <title>Types and Values</title> <refsect2> <title>LIBRSVG_MAJOR_VERSION</title> <programlisting>#define LIBRSVG_MAJOR_VERSION (2) </programlisting> </refsect2>
<refsect2> <title>LIBRSVG_MINOR_VERSION</title> <programlisting>#define LIBRSVG_MINOR_VERSION (44) </programlisting> </refsect2>
<refsect2> <title>LIBRSVG_MICRO_VERSION</title> <programlisting>#define LIBRSVG_MICRO_VERSION (10) </programlisting> </refsect2>
<refsect2> <title>LIBRSVG_VERSION</title> <programlisting>#define LIBRSVG_VERSION "2.44.10" </programlisting> </refsect2>
<refsect2> <title>LIBRSVG_HAVE_SVGZ</title> <programlisting>#define LIBRSVG_HAVE_SVGZ (TRUE) </programlisting> </refsect2>
<refsect2> <title>LIBRSVG_HAVE_CSS</title> <programlisting>#define LIBRSVG_HAVE_CSS (TRUE) </programlisting> </refsect2> </refsect1>
</refentry>