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
60typedef enum {
63
64#define RSVG_ERROR (rsvg_error_quark ())
65
73RSVG_API
74GQuark rsvg_error_quark (void) G_GNUC_CONST;
75
76RSVG_API
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
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
108 GObjectClass parent;
109
110 /*< private >*/
111 gpointer _abi_padding[15];
112};
113
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
145 int width;
147 gdouble em;
148 gdouble ex;
149};
150
161 int x;
162 int y;
163};
164
173 double x;
174 double y;
175 double width;
176 double height;
177};
178
198
206typedef struct {
207 double length;
209} RsvgLength;
210
226RSVG_DEPRECATED
227void rsvg_cleanup (void);
228
234RSVG_DEPRECATED
235void rsvg_set_default_dpi (double dpi);
236
242RSVG_DEPRECATED
243void rsvg_set_default_dpi_x_y (double dpi_x, double dpi_y);
244
261RSVG_API
262void rsvg_handle_set_dpi (RsvgHandle *handle, double dpi);
263
272RSVG_API
273void 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
322void rsvg_handle_set_base_uri (RsvgHandle *handle, const char *base_uri);
323
337void 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
392
393RSVG_API
395#define RSVG_TYPE_HANDLE_FLAGS (rsvg_handle_flags_get_type())
396
410RSVG_API
412
420RSVG_API
421void 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
556 GCancellable *cancellable);
557
579RSVG_API
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
631void rsvg_term (void);
632
638RSVG_DEPRECATED_FOR(g_object_unref)
639void rsvg_handle_free (RsvgHandle *handle);
640
647typedef void (*RsvgSizeFunc) (gint *width, gint *height, gpointer user_data);
648
654RSVG_DEPRECATED
655void 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 */
void rsvg_handle_set_cancellable_for_rendering(RsvgHandle *handle, GCancellable *cancellable)
Interrupt rendering from another thread.
const char * rsvg_handle_get_metadata(RsvgHandle *handle)
rsvg_handle_get_metadata:
void rsvg_term(void)
rsvg_term:
void rsvg_handle_set_size_callback(RsvgHandle *handle, RsvgSizeFunc size_func, gpointer user_data, GDestroyNotify user_data_destroy)
rsvg_handle_set_size_callback:
const char * rsvg_handle_get_title(RsvgHandle *handle)
rsvg_handle_get_title:
void rsvg_init(void)
rsvg_init:
void rsvg_set_default_dpi_x_y(double dpi_x, double dpi_y)
rsvg_set_default_dpi_x_y:
void rsvg_cleanup(void)
rsvg_cleanup:
void rsvg_handle_free(RsvgHandle *handle)
rsvg_handle_free:
const char * rsvg_handle_get_desc(RsvgHandle *handle)
rsvg_handle_get_desc:
void(* RsvgSizeFunc)(gint *width, gint *height, gpointer user_data)
RsvgSizeFunc:
Definition rsvg.h:647
void rsvg_set_default_dpi(double dpi)
rsvg_set_default_dpi:
void rsvg_handle_get_dimensions(RsvgHandle *handle, RsvgDimensionData *dimension_data)
rsvg_handle_get_dimensions:
gboolean rsvg_handle_get_dimensions_sub(RsvgHandle *handle, RsvgDimensionData *dimension_data, const char *id)
rsvg_handle_get_dimensions_sub:
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...
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.
gboolean rsvg_handle_get_position_sub(RsvgHandle *handle, RsvgPositionData *position_data, const char *id)
rsvg_handle_get_position_sub:
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 ...
gboolean rsvg_handle_has_sub(RsvgHandle *handle, const char *id)
rsvg_handle_has_sub: @handle: an #RsvgHandle @id: element id starting with #
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...
RsvgHandle * rsvg_handle_new_with_flags(RsvgHandleFlags flags)
rsvg_handle_new_with_flags: @flags: RsvgHandleFlags
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 ...
RsvgHandle * rsvg_handle_new(void)
rsvg_handle_new:
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 #...
const char * rsvg_handle_get_base_uri(RsvgHandle *handle)
rsvg_handle_get_base_uri:
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...
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:
void rsvg_handle_set_dpi_x_y(RsvgHandle *handle, double dpi_x, double dpi_y)
rsvg_handle_set_dpi_x_y: @handle: an #RsvgHandle
gboolean rsvg_handle_write(RsvgHandle *handle, const guchar *buf, gsize count, GError **error)
rsvg_handle_write:
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
void rsvg_handle_set_dpi(RsvgHandle *handle, double dpi)
rsvg_handle_set_dpi: @handle: an #RsvgHandle @dpi: dots per inch (both axes)
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...
gboolean rsvg_handle_close(RsvgHandle *handle, GError **error)
rsvg_handle_close:
gboolean rsvg_handle_set_stylesheet(RsvgHandle *handle, const guint8 *css, gsize css_len, GError **error)
Set a CSS stylesheet for the SVG document.
GType rsvg_error_get_type(void)
RsvgHandleFlags
RsvgHandleFlags: @RSVG_HANDLE_FLAGS_NONE: no flags @RSVG_HANDLE_FLAG_UNLIMITED: no limits on XML size...
Definition rsvg.h:387
GType rsvg_handle_flags_get_type(void)
RsvgUnit
RsvgUnit:
Definition rsvg.h:186
RsvgError
RsvgError: @RSVG_ERROR_FAILED: the request failed.
Definition rsvg.h:60
GType rsvg_handle_get_type(void)
GQuark rsvg_error_quark(void)
rsvg_error_quark:
@ RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA
Definition rsvg.h:390
@ RSVG_HANDLE_FLAGS_NONE
Definition rsvg.h:388
@ RSVG_HANDLE_FLAG_UNLIMITED
Definition rsvg.h:389
@ RSVG_UNIT_PERCENT
Definition rsvg.h:187
@ RSVG_UNIT_CM
Definition rsvg.h:192
@ RSVG_UNIT_CH
Definition rsvg.h:196
@ RSVG_UNIT_MM
Definition rsvg.h:193
@ RSVG_UNIT_IN
Definition rsvg.h:191
@ RSVG_UNIT_EM
Definition rsvg.h:189
@ RSVG_UNIT_PT
Definition rsvg.h:194
@ RSVG_UNIT_PX
Definition rsvg.h:188
@ RSVG_UNIT_PC
Definition rsvg.h:195
@ RSVG_UNIT_EX
Definition rsvg.h:190
@ RSVG_ERROR_FAILED
Definition rsvg.h:61
RsvgLength:
Definition rsvg.h:206
double length
Definition rsvg.h:207
RsvgUnit unit
Definition rsvg.h:208
RsvgDimensionData:
Definition rsvg.h:144
gdouble ex
Definition rsvg.h:148
int width
Definition rsvg.h:145
gdouble em
Definition rsvg.h:147
int height
Definition rsvg.h:146
RsvgHandleClass:
Definition rsvg.h:107
gpointer _abi_padding[15]
Definition rsvg.h:111
GObjectClass parent
Definition rsvg.h:108
RsvgHandle:
Definition rsvg.h:123
GObject parent
Definition rsvg.h:124
gpointer _abi_padding[16]
Definition rsvg.h:131
RsvgPositionData:
Definition rsvg.h:160
int y
Definition rsvg.h:162
int x
Definition rsvg.h:161
RsvgRectangle:
Definition rsvg.h:172
double height
Definition rsvg.h:176
double width
Definition rsvg.h:175
double y
Definition rsvg.h:174
double x
Definition rsvg.h:173