Functions
cairo_surface_t* | cairo_svg_surface_create() |
cairo_surface_t* | cairo_svg_surface_create_for_stream() |
cairo_svg_unit_t | cairo_svg_surface_get_document_unit() |
void | cairo_svg_surface_set_document_unit() |
void | cairo_svg_surface_restrict_to_version() |
void | cairo_svg_get_versions() |
const char* | cairo_svg_version_to_string() |
Types and Values
#define | CAIRO_HAS_SVG_SURFACE |
enum | cairo_svg_version_t |
enum | cairo_svg_unit_t |
Description
The SVG surface is used to render cairo graphics toSVG files and is a multi-page vector surface backend.
Functions
cairo_svg_surface_create()
cairo_surface_t*cairo_svg_surface_create (const char *filename
,double width_in_points
,double height_in_points
);
Creates a SVG surface of the specified size in points to be writtento filename
.
The SVG surface backend recognizes the following MIME types for thedata attached to a surface (see cairo_surface_set_mime_data()) whenit is used as a source pattern for drawing on this surface:CAIRO_MIME_TYPE_JPEG, CAIRO_MIME_TYPE_PNG,CAIRO_MIME_TYPE_URI. If any of them is specified, the SVG backendemits a href with the content of MIME data instead of a surfacesnapshot (PNG, Base64-encoded) in the corresponding image tag.
The unofficial MIME type CAIRO_MIME_TYPE_URI is examinedfirst. If present, the URI is emitted as is: assuring thecorrectness of URI is left to the client code.
If CAIRO_MIME_TYPE_URI is not present, but CAIRO_MIME_TYPE_JPEGor CAIRO_MIME_TYPE_PNG is specified, the corresponding data isBase64-encoded and emitted.
If CAIRO_MIME_TYPE_UNIQUE_ID is present, all surfaces with the sameunique identifier will only be embedded once.
Parameters
filename | a filename for the SVG output (must be writable), | |
width_in_points | width of the surface, in points (1 point == 1/72.0 inch) | |
height_in_points | height of the surface, in points (1 point == 1/72.0 inch) |
Returns
a pointer to the newly created surface. The callerowns the surface and should call cairo_surface_destroy() when donewith it.
This function always returns a valid pointer, but it will return apointer to a "nil" surface if an error such as out of memoryoccurs. You can use cairo_surface_status() to check for this.
Since: 1.2
cairo_svg_surface_create_for_stream()
cairo_surface_t*cairo_svg_surface_create_for_stream (cairo_write_func_t write_func
,void *closure
,double width_in_points
,double height_in_points
);
Creates a SVG surface of the specified size in points to be writtenincrementally to the stream represented by write_func
and closure
.
Parameters
write_func | a cairo_write_func_t to accept the output data, may be | |
closure | the closure argument for | |
width_in_points | width of the surface, in points (1 point == 1/72.0 inch) | |
height_in_points | height of the surface, in points (1 point == 1/72.0 inch) |
Returns
a pointer to the newly created surface. The callerowns the surface and should call cairo_surface_destroy() when donewith it.
This function always returns a valid pointer, but it will return apointer to a "nil" surface if an error such as out of memoryoccurs. You can use cairo_surface_status() to check for this.
Since: 1.2
cairo_svg_surface_get_document_unit()
cairo_svg_unit_tcairo_svg_surface_get_document_unit (cairo_surface_t *surface
);
Get the unit of the SVG surface.
If the surface passed as an argument is not a SVG surface, the functionsets the error status to CAIRO_STATUS_SURFACE_TYPE_MISMATCH and returnsCAIRO_SVG_UNIT_USER.
Parameters
surface | a SVG cairo_surface_t |
Returns
the SVG unit of the SVG surface.
Since: 1.16
cairo_svg_surface_set_document_unit()
voidcairo_svg_surface_set_document_unit (cairo_surface_t *surface
,cairo_svg_unit_t unit
);
Use the specified unit for the width and height of the generated SVG file.See cairo_svg_unit_t for a list of available unit values that can be usedhere.
This function can be called at any time before generating the SVG file.
However to minimize the risk of ambiguities it's recommended to call itbefore any drawing operations have been performed on the given surface, tomake it clearer what the unit used in the drawing operations is.
The simplest way to do this is to call this function immediately aftercreating the SVG surface.
Note if this function is never called, the default unit for SVG documentsgenerated by cairo will be user unit.
Parameters
surface | a SVG cairo_surface_t | |
unit | SVG unit |
Since: 1.16
cairo_svg_surface_restrict_to_version()
voidcairo_svg_surface_restrict_to_version (cairo_surface_t *surface
,cairo_svg_version_t version
);
Restricts the generated SVG file to version
. See cairo_svg_get_versions()for a list of available version values that can be used here.
This function should only be called before any drawing operationshave been performed on the given surface. The simplest way to dothis is to call this function immediately after creating thesurface.
Parameters
surface | a SVG cairo_surface_t | |
version | SVG version |
Since: 1.2
cairo_svg_get_versions()
voidcairo_svg_get_versions (cairo_svg_version_t const **versions
,int *num_versions
);
Used to retrieve the list of supported versions. Seecairo_svg_surface_restrict_to_version().
Parameters
versions | supported version list | |
num_versions | list length |
Since: 1.2
cairo_svg_version_to_string()
const char*cairo_svg_version_to_string (cairo_svg_version_t version
);
Get the string representation of the given version
id. This functionwill return NULL
if version
isn't valid. See cairo_svg_get_versions()for a way to get the list of valid version ids.
Parameters
version | a version id |
Returns
the string associated to given version.
Since: 1.2
Types and Values
CAIRO_HAS_SVG_SURFACE
#define CAIRO_HAS_SVG_SURFACE
Defined if the SVG surface backend is available.This macro can be used to conditionally compile backend-specific code.
Since: 1.2
enum cairo_svg_version_t
cairo_svg_version_t is used to describe the version number of the SVGspecification that a generated SVG file will conform to.
Members
Since: 1.2
enum cairo_svg_unit_t
cairo_svg_unit_t is used to describe the units valid for coordinates andlengths in the SVG specification.
See also:
Members
User unit, a value in the current coordinate system.If used in the root element for the initial coordinate systems itcorresponds to pixels. (Since 1.16) | ||
The size of the element's font. (Since 1.16) | ||
The x-height of the element’s font. (Since 1.16) | ||
Pixels (1px = 1/96th of 1in). (Since 1.16) | ||
Inches (1in = 2.54cm = 96px). (Since 1.16) | ||
Centimeters (1cm = 96px/2.54). (Since 1.16) | ||
Millimeters (1mm = 1/10th of 1cm). (Since 1.16) | ||
Points (1pt = 1/72th of 1in). (Since 1.16) | ||
Picas (1pc = 1/6th of 1in). (Since 1.16) | ||
Percent, a value that is some fraction of anotherreference value. (Since 1.16) |
Since: 1.16
See Also
cairo_surface_t