LIBRSVG: C library for rendering SVG

LIBRSVG 2.62.3 C library for rendering SVG

Loading...
Searching...
No Matches
rsvg.h
Go to the documentation of this file.
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* vim: set sw=4 sts=4 expandtab: */
3/*
4 rsvg.h: Public C API for librsvg.
5
6 Copyright (C) 2000 Eazel, Inc.
7 Copyright (C) 2026 Randy Butler
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
18
19 You should have received a copy of the GNU Library General Public
20 License along with this program; if not, write to the
21 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.
23*/
24
25#ifndef RSVG_H
26#define RSVG_H
27
28#define __RSVG_RSVG_H_INSIDE__
29
30#include <glib-object.h>
31#include <gio/gio.h>
32
33G_BEGIN_DECLS
34
35#ifndef RSVG_API
36# define RSVG_API
37#endif
38
39#if defined(RSVG_DISABLE_DEPRECATION_WARNINGS) || !GLIB_CHECK_VERSION (2, 31, 0)
40#define RSVG_DEPRECATED RSVG_API
41#define RSVG_DEPRECATED_FOR(f) RSVG_API
42#else
43#define RSVG_DEPRECATED G_DEPRECATED RSVG_API
44#define RSVG_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) RSVG_API
45#endif
46
60 typedef enum {
61 RSVG_ERROR_FAILED
62} RsvgError;
63
64#define RSVG_ERROR (rsvg_error_quark ())
65
73RSVG_API
74GQuark rsvg_error_quark (void) G_GNUC_CONST;
75
76RSVG_API
77GType rsvg_error_get_type (void);
78#define RSVG_TYPE_ERROR (rsvg_error_get_type())
79
80#define RSVG_TYPE_HANDLE (rsvg_handle_get_type ())
81#define RSVG_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RSVG_TYPE_HANDLE, RsvgHandle))
82#define RSVG_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RSVG_TYPE_HANDLE, RsvgHandleClass))
83#define RSVG_IS_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RSVG_TYPE_HANDLE))
84#define RSVG_IS_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RSVG_TYPE_HANDLE))
85#define RSVG_HANDLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RSVG_TYPE_HANDLE, RsvgHandleClass))
86
87RSVG_API
88GType rsvg_handle_get_type (void);
89
90#ifdef RSVG_COMPILATION
91typedef struct RsvgHandlePrivate RsvgHandlePrivate;
92#endif
93
94typedef struct _RsvgHandle RsvgHandle;
95typedef struct _RsvgHandleClass RsvgHandleClass;
96typedef struct _RsvgDimensionData RsvgDimensionData;
97typedef struct _RsvgPositionData RsvgPositionData;
98typedef struct _RsvgRectangle RsvgRectangle;
99
107 struct _RsvgHandleClass {
108 GObjectClass parent;
109
110 /*< private >*/
111 gpointer _abi_padding[15];
112};
113
123 struct _RsvgHandle {
124 GObject parent;
125
126 /*< private >*/
127#ifdef RSVG_COMPILATION
128 RsvgHandlePrivate *priv;
129 gpointer _abi_padding[15];
130#else
131 gpointer _abi_padding[16];
132#endif
133};
134
144 struct _RsvgDimensionData {
145 int width;
146 int height;
147 gdouble em;
148 gdouble ex;
149};
150
160 struct _RsvgPositionData {
161 int x;
162 int y;
163};
164
172 struct _RsvgRectangle {
173 double x;
174 double y;
175 double width;
176 double height;
177};
178
186 typedef enum {
187 RSVG_UNIT_PERCENT,
188 RSVG_UNIT_PX,
189 RSVG_UNIT_EM,
190 RSVG_UNIT_EX,
191 RSVG_UNIT_IN,
192 RSVG_UNIT_CM,
193 RSVG_UNIT_MM,
194 RSVG_UNIT_PT,
195 RSVG_UNIT_PC,
196 RSVG_UNIT_CH
197} RsvgUnit;
198
206 typedef struct {
207 double length;
208 RsvgUnit unit;
209} RsvgLength;
210
226RSVG_DEPRECATED
227 void rsvg_cleanup (void);
228
234RSVG_DEPRECATED
235 void rsvg_set_default_dpi (double dpi);
236
242RSVG_DEPRECATED
243 void rsvg_set_default_dpi_x_y (double dpi_x, double dpi_y);
244
261RSVG_API
262 void rsvg_handle_set_dpi (RsvgHandle *handle, double dpi);
263
272RSVG_API
273 void rsvg_handle_set_dpi_x_y (RsvgHandle *handle, double dpi_x, double dpi_y);
274
283RSVG_API
284RsvgHandle *rsvg_handle_new (void);
285
291RSVG_DEPRECATED_FOR(rsvg_handle_read_stream_sync)
292gboolean rsvg_handle_write (RsvgHandle *handle,
293 const guchar *buf,
294 gsize count,
295 GError **error);
296
302RSVG_DEPRECATED_FOR(rsvg_handle_read_stream_sync)
303gboolean rsvg_handle_close (RsvgHandle *handle, GError **error);
304
309RSVG_API
310const char *rsvg_handle_get_base_uri (RsvgHandle *handle);
311
321RSVG_API
322 void rsvg_handle_set_base_uri (RsvgHandle *handle, const char *base_uri);
323
336RSVG_DEPRECATED_FOR(rsvg_handle_get_intrinsic_size_in_pixels)
337 void rsvg_handle_get_dimensions (RsvgHandle *handle, RsvgDimensionData *dimension_data);
338
344RSVG_DEPRECATED_FOR(rsvg_handle_get_geometry_for_layer)
345gboolean rsvg_handle_get_dimensions_sub (RsvgHandle *handle,
346 RsvgDimensionData *dimension_data,
347 const char *id);
348
354RSVG_DEPRECATED_FOR(rsvg_handle_get_geometry_for_layer)
355gboolean rsvg_handle_get_position_sub (RsvgHandle *handle,
356 RsvgPositionData *position_data,
357 const char *id);
358
368RSVG_API
369gboolean rsvg_handle_has_sub (RsvgHandle *handle, const char *id);
370
386typedef enum /*< flags >*/
387{
388 RSVG_HANDLE_FLAGS_NONE = 0,
389 RSVG_HANDLE_FLAG_UNLIMITED = 1 << 0,
390 RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA = 1 << 1
391} RsvgHandleFlags;
392
393RSVG_API
394GType rsvg_handle_flags_get_type (void);
395#define RSVG_TYPE_HANDLE_FLAGS (rsvg_handle_flags_get_type())
396
410RSVG_API
411RsvgHandle *rsvg_handle_new_with_flags (RsvgHandleFlags flags);
412
420RSVG_API
421 void rsvg_handle_set_base_gfile (RsvgHandle *handle, GFile *base_file);
422
434RSVG_API
435gboolean rsvg_handle_read_stream_sync (RsvgHandle *handle,
436 GInputStream *stream,
437 GCancellable *cancellable,
438 GError **error);
439
451RSVG_API
452RsvgHandle *rsvg_handle_new_from_gfile_sync (GFile *file,
453 RsvgHandleFlags flags,
454 GCancellable *cancellable,
455 GError **error);
456
464RSVG_API
465RsvgHandle *rsvg_handle_new_from_stream_sync (GInputStream *input_stream,
466 GFile *base_file,
467 RsvgHandleFlags flags,
468 GCancellable *cancellable,
469 GError **error);
470
481RSVG_API
482RsvgHandle *rsvg_handle_new_from_data (const guint8 *data, gsize data_len, GError **error);
483
493RSVG_API
494RsvgHandle *rsvg_handle_new_from_file (const gchar *filename, GError **error);
495
525RSVG_API
526gboolean rsvg_handle_set_stylesheet (RsvgHandle *handle,
527 const guint8 *css,
528 gsize css_len,
529 GError **error);
530
554RSVG_API
555 void rsvg_handle_set_cancellable_for_rendering (RsvgHandle *handle,
556 GCancellable *cancellable);
557
579RSVG_API
580 void rsvg_handle_get_intrinsic_dimensions (RsvgHandle *handle,
581 gboolean *out_has_width,
582 RsvgLength *out_width,
583 gboolean *out_has_height,
584 RsvgLength *out_height,
585 gboolean *out_has_viewbox,
586 RsvgRectangle *out_viewbox);
587
600RSVG_API
601gboolean rsvg_handle_get_intrinsic_size_in_pixels (RsvgHandle *handle,
602 gdouble *out_width,
603 gdouble *out_height);
604
607#ifndef __GTK_DOC_IGNORE__
608RSVG_API
609void rsvg_handle_internal_set_testing (RsvgHandle *handle, gboolean testing);
610#endif
611
622RSVG_DEPRECATED_FOR(g_type_init)
623void rsvg_init (void);
624
630RSVG_DEPRECATED
631 void rsvg_term (void);
632
638RSVG_DEPRECATED_FOR(g_object_unref)
639 void rsvg_handle_free (RsvgHandle *handle);
640
647typedef void (*RsvgSizeFunc) (gint *width, gint *height, gpointer user_data);
648
654RSVG_DEPRECATED
655 void rsvg_handle_set_size_callback (RsvgHandle *handle,
656 RsvgSizeFunc size_func,
657 gpointer user_data,
658 GDestroyNotify user_data_destroy);
659
665RSVG_DEPRECATED
666const char *rsvg_handle_get_title (RsvgHandle *handle);
667
673RSVG_DEPRECATED
674const char *rsvg_handle_get_desc (RsvgHandle *handle);
675
681RSVG_DEPRECATED
682const char *rsvg_handle_get_metadata (RsvgHandle *handle);
683
686G_END_DECLS
687
688#include "rsvg-version.h"
689#include "rsvg-features.h"
690#include "rsvg-cairo.h"
691
692#if LIBRSVG_HAVE_PIXBUF
693#include "rsvg-pixbuf.h"
694#endif
695
696#undef __RSVG_RSVG_H_INSIDE__
697
698#endif /* RSVG_H */
rsvg_handle_set_cancellable_for_rendering
void rsvg_handle_set_cancellable_for_rendering(RsvgHandle *handle, GCancellable *cancellable)
Interrupt rendering from another thread.
rsvg_handle_get_metadata
const char * rsvg_handle_get_metadata(RsvgHandle *handle)
rsvg_handle_get_metadata:
rsvg_term
void rsvg_term(void)
rsvg_term:
rsvg_handle_set_size_callback
void rsvg_handle_set_size_callback(RsvgHandle *handle, RsvgSizeFunc size_func, gpointer user_data, GDestroyNotify user_data_destroy)
rsvg_handle_set_size_callback:
rsvg_handle_get_title
const char * rsvg_handle_get_title(RsvgHandle *handle)
rsvg_handle_get_title:
rsvg_init
void rsvg_init(void)
rsvg_init:
rsvg_set_default_dpi_x_y
void rsvg_set_default_dpi_x_y(double dpi_x, double dpi_y)
rsvg_set_default_dpi_x_y:
rsvg_cleanup
void rsvg_cleanup(void)
rsvg_cleanup:
rsvg_handle_free
void rsvg_handle_free(RsvgHandle *handle)
rsvg_handle_free:
rsvg_handle_get_desc
const char * rsvg_handle_get_desc(RsvgHandle *handle)
rsvg_handle_get_desc:
RsvgSizeFunc
void(* RsvgSizeFunc)(gint *width, gint *height, gpointer user_data)
RsvgSizeFunc:
Definition rsvg.h:647
rsvg_set_default_dpi
void rsvg_set_default_dpi(double dpi)
rsvg_set_default_dpi:
rsvg_handle_get_dimensions
void rsvg_handle_get_dimensions(RsvgHandle *handle, RsvgDimensionData *dimension_data)
rsvg_handle_get_dimensions:
rsvg_handle_get_dimensions_sub
gboolean rsvg_handle_get_dimensions_sub(RsvgHandle *handle, RsvgDimensionData *dimension_data, const char *id)
rsvg_handle_get_dimensions_sub:
rsvg_handle_get_intrinsic_dimensions
void rsvg_handle_get_intrinsic_dimensions(RsvgHandle *handle, gboolean *out_has_width, RsvgLength *out_width, gboolean *out_has_height, RsvgLength *out_height, gboolean *out_has_viewbox, RsvgRectangle *out_viewbox)
rsvg_handle_get_intrinsic_dimensions: @handle: an #RsvgHandle @out_has_width: (out)(optional): whethe...
rsvg_handle_get_geometry_for_layer
gboolean rsvg_handle_get_geometry_for_layer(RsvgHandle *handle, const char *id, const RsvgRectangle *viewport, RsvgRectangle *out_ink_rect, RsvgRectangle *out_logical_rect, GError **error)
Geometry of an element (or the whole SVG) as if rendered to @viewport.
rsvg_handle_get_position_sub
gboolean rsvg_handle_get_position_sub(RsvgHandle *handle, RsvgPositionData *position_data, const char *id)
rsvg_handle_get_position_sub:
rsvg_handle_get_intrinsic_size_in_pixels
gboolean rsvg_handle_get_intrinsic_size_in_pixels(RsvgHandle *handle, gdouble *out_width, gdouble *out_height)
rsvg_handle_get_intrinsic_size_in_pixels: @handle: an #RsvgHandle @out_width: (out)(optional): width ...
rsvg_handle_has_sub
gboolean rsvg_handle_has_sub(RsvgHandle *handle, const char *id)
rsvg_handle_has_sub: @handle: an #RsvgHandle @id: element id starting with #
rsvg_handle_new_from_gfile_sync
RsvgHandle * rsvg_handle_new_from_gfile_sync(GFile *file, RsvgHandleFlags flags, GCancellable *cancellable, GError **error)
rsvg_handle_new_from_gfile_sync: @gfile: a #GFile @flags: RsvgHandleFlags @cancellable: (nullable): a...
rsvg_handle_new_with_flags
RsvgHandle * rsvg_handle_new_with_flags(RsvgHandleFlags flags)
rsvg_handle_new_with_flags: @flags: RsvgHandleFlags
rsvg_handle_new_from_data
RsvgHandle * rsvg_handle_new_from_data(const guint8 *data, gsize data_len, GError **error)
rsvg_handle_new_from_data: @data: SVG bytes @data_len: length of @data @error: return location for a ...
rsvg_handle_new
RsvgHandle * rsvg_handle_new(void)
rsvg_handle_new:
rsvg_handle_read_stream_sync
gboolean rsvg_handle_read_stream_sync(RsvgHandle *handle, GInputStream *stream, GCancellable *cancellable, GError **error)
rsvg_handle_read_stream_sync: @handle: an #RsvgHandle @stream: SVG data @cancellable: (nullable): a #...
rsvg_handle_get_base_uri
const char * rsvg_handle_get_base_uri(RsvgHandle *handle)
rsvg_handle_get_base_uri:
rsvg_handle_set_base_gfile
void rsvg_handle_set_base_gfile(RsvgHandle *handle, GFile *base_file)
rsvg_handle_set_base_gfile: @handle: an #RsvgHandle @base_file: a #GFile used as the base for relativ...
rsvg_handle_new_from_stream_sync
RsvgHandle * rsvg_handle_new_from_stream_sync(GInputStream *input_stream, GFile *base_file, RsvgHandleFlags flags, GCancellable *cancellable, GError **error)
rsvg_handle_new_from_stream_sync:
rsvg_handle_set_dpi_x_y
void rsvg_handle_set_dpi_x_y(RsvgHandle *handle, double dpi_x, double dpi_y)
rsvg_handle_set_dpi_x_y: @handle: an #RsvgHandle
rsvg_handle_write
gboolean rsvg_handle_write(RsvgHandle *handle, const guchar *buf, gsize count, GError **error)
rsvg_handle_write:
rsvg_handle_new_from_file
RsvgHandle * rsvg_handle_new_from_file(const gchar *filename, GError **error)
rsvg_handle_new_from_file: @filename: a file name @error: return location for a #GError
rsvg_handle_set_dpi
void rsvg_handle_set_dpi(RsvgHandle *handle, double dpi)
rsvg_handle_set_dpi: @handle: an #RsvgHandle @dpi: dots per inch (both axes)
rsvg_handle_set_base_uri
void rsvg_handle_set_base_uri(RsvgHandle *handle, const char *base_uri)
rsvg_handle_set_base_uri: @handle: an #RsvgHandle @base_uri: base URI for resolving relative referenc...
rsvg_handle_close
gboolean rsvg_handle_close(RsvgHandle *handle, GError **error)
rsvg_handle_close:
rsvg_handle_set_stylesheet
gboolean rsvg_handle_set_stylesheet(RsvgHandle *handle, const guint8 *css, gsize css_len, GError **error)
Set a CSS stylesheet for the SVG document.
rsvg_error_get_type
GType rsvg_error_get_type(void)
RsvgHandleFlags
RsvgHandleFlags
RsvgHandleFlags: @RSVG_HANDLE_FLAGS_NONE: no flags @RSVG_HANDLE_FLAG_UNLIMITED: no limits on XML size...
Definition rsvg.h:387
rsvg_handle_flags_get_type
GType rsvg_handle_flags_get_type(void)
RsvgUnit
RsvgUnit
RsvgUnit:
Definition rsvg.h:186
RsvgError
RsvgError
RsvgError: @RSVG_ERROR_FAILED: the request failed.
Definition rsvg.h:60
rsvg_handle_get_type
GType rsvg_handle_get_type(void)
rsvg_error_quark
GQuark rsvg_error_quark(void)
rsvg_error_quark:
RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA
@ RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA
Definition rsvg.h:390
RSVG_HANDLE_FLAGS_NONE
@ RSVG_HANDLE_FLAGS_NONE
Definition rsvg.h:388
RSVG_HANDLE_FLAG_UNLIMITED
@ RSVG_HANDLE_FLAG_UNLIMITED
Definition rsvg.h:389
RSVG_UNIT_PERCENT
@ RSVG_UNIT_PERCENT
Definition rsvg.h:187
RSVG_UNIT_CM
@ RSVG_UNIT_CM
Definition rsvg.h:192
RSVG_UNIT_CH
@ RSVG_UNIT_CH
Definition rsvg.h:196
RSVG_UNIT_MM
@ RSVG_UNIT_MM
Definition rsvg.h:193
RSVG_UNIT_IN
@ RSVG_UNIT_IN
Definition rsvg.h:191
RSVG_UNIT_EM
@ RSVG_UNIT_EM
Definition rsvg.h:189
RSVG_UNIT_PT
@ RSVG_UNIT_PT
Definition rsvg.h:194
RSVG_UNIT_PX
@ RSVG_UNIT_PX
Definition rsvg.h:188
RSVG_UNIT_PC
@ RSVG_UNIT_PC
Definition rsvg.h:195
RSVG_UNIT_EX
@ RSVG_UNIT_EX
Definition rsvg.h:190
RSVG_ERROR_FAILED
@ RSVG_ERROR_FAILED
Definition rsvg.h:61
rsvg-cairo.h
rsvg-features.h
rsvg-pixbuf.h
RsvgLength
RsvgLength:
Definition rsvg.h:206
RsvgLength::length
double length
Definition rsvg.h:207
RsvgLength::unit
RsvgUnit unit
Definition rsvg.h:208
_RsvgDimensionData
RsvgDimensionData:
Definition rsvg.h:144
_RsvgDimensionData::ex
gdouble ex
Definition rsvg.h:148
_RsvgDimensionData::width
int width
Definition rsvg.h:145
_RsvgDimensionData::em
gdouble em
Definition rsvg.h:147
_RsvgDimensionData::height
int height
Definition rsvg.h:146
_RsvgHandleClass
RsvgHandleClass:
Definition rsvg.h:107
_RsvgHandleClass::_abi_padding
gpointer _abi_padding[15]
Definition rsvg.h:111
_RsvgHandleClass::parent
GObjectClass parent
Definition rsvg.h:108
_RsvgHandle
RsvgHandle:
Definition rsvg.h:123
_RsvgHandle::parent
GObject parent
Definition rsvg.h:124
_RsvgHandle::_abi_padding
gpointer _abi_padding[16]
Definition rsvg.h:131
_RsvgPositionData
RsvgPositionData:
Definition rsvg.h:160
_RsvgPositionData::y
int y
Definition rsvg.h:162
_RsvgPositionData::x
int x
Definition rsvg.h:161
_RsvgRectangle
RsvgRectangle:
Definition rsvg.h:172
_RsvgRectangle::height
double height
Definition rsvg.h:176
_RsvgRectangle::width
double width
Definition rsvg.h:175
_RsvgRectangle::y
double y
Definition rsvg.h:174
_RsvgRectangle::x
double x
Definition rsvg.h:173