SVG Surfaces: Cairo: A Vector Graphics Library (2024)

Functions

cairo_surface_t*cairo_svg_surface_create()
cairo_surface_t*cairo_svg_surface_create_for_stream()
cairo_svg_unit_tcairo_svg_surface_get_document_unit()
voidcairo_svg_surface_set_document_unit()
voidcairo_svg_surface_restrict_to_version()
voidcairo_svg_get_versions()
const char*cairo_svg_version_to_string()

Types and Values

#defineCAIRO_HAS_SVG_SURFACE
enumcairo_svg_version_t
enumcairo_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), NULL may beused to specify no output. This will generate a SVG surface thatmay be queried and used as a source, without generating atemporary file.

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 NULLto indicate a no-op write_func. With a no-op write_func,the surface may be queried or used as a source withoutgenerating any temporary files.

closure

the closure argument for write_func

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

CAIRO_SVG_VERSION_1_1

The version 1.1 of the SVG specification. (Since 1.2)

CAIRO_SVG_VERSION_1_2

The version 1.2 of the SVG specification. (Since 1.2)

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

CAIRO_SVG_UNIT_USER

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)

CAIRO_SVG_UNIT_EM

The size of the element's font. (Since 1.16)

CAIRO_SVG_UNIT_EX

The x-height of the element’s font. (Since 1.16)

CAIRO_SVG_UNIT_PX

Pixels (1px = 1/96th of 1in). (Since 1.16)

CAIRO_SVG_UNIT_IN

Inches (1in = 2.54cm = 96px). (Since 1.16)

CAIRO_SVG_UNIT_CM

Centimeters (1cm = 96px/2.54). (Since 1.16)

CAIRO_SVG_UNIT_MM

Millimeters (1mm = 1/10th of 1cm). (Since 1.16)

CAIRO_SVG_UNIT_PT

Points (1pt = 1/72th of 1in). (Since 1.16)

CAIRO_SVG_UNIT_PC

Picas (1pc = 1/6th of 1in). (Since 1.16)

CAIRO_SVG_UNIT_PERCENT

Percent, a value that is some fraction of anotherreference value. (Since 1.16)

Since: 1.16

See Also

cairo_surface_t

SVG Surfaces: Cairo: A Vector Graphics Library (2024)

FAQs

What is the cairo surface? ›

cairo_surface_t is the abstract type representing all different drawing targets that cairo can render to. The actual drawings are performed using a cairo context. A cairo surface is created by using backend-specific constructors, typically of the form cairo_backend_surface_create() .

What is SVG in vector graphics? ›

Scalable Vector Graphics (SVG) is a web-friendly vector file format. As opposed to pixel-based raster files like JPEGs, vector files store images via mathematical formulas based on points and lines on a grid.

What is the difference between SVG and vector graphics? ›

SVG (Scalable Vector Graphics) is a specific file format that uses XML to define vector graphics, making it a way to store and display vector images on the web or in various software. In essence, a vector is a conceptual idea, while SVG is a file format used to store and display vector graphics.

Are all SVG files vector files? ›

EPS and SVG are both vector-based formats. While vector files are excellent for producing crisp graphics, drawings, and designs at any scale, they struggle to reproduce photographs. Raster-based files like JPEG, GIF, TIFF and PNG are better suited to photography.

Why is Cairo so special? ›

Cairo juxtaposes the old with the new. The Pyramids of Giza in Greater Cairo and the Egyptian Museum demonstrate ancient Egyptian history preservation. In addition, Cairo is often considered the cultural capital of the Arab Middle East.

What is Cairo used for? ›

Cairo (stylized as cairo) is an open-source graphics library that provides a vector graphics-based, device-independent API for software developers. It provides primitives for two-dimensional drawing across a number of different backends. Cairo uses hardware acceleration when available.

Is SVG good or bad? ›

SVG images work very well when the image itself is relatively simple. They're often used as logos, buttons, icons, and nav bars, roles for which they are ideally suited. They're not ideal for images with a lot of detail, such as photographs. For those, it's usually best to stick with PNG or WebP files.

What is SVG mostly used for? ›

SVG files are great for web graphics like logos, illustrations, and charts. But their lack of pixels makes displaying high-quality digital photos difficult. JPEG files are generally better for detailed photographs. Only modern browsers can support SVG images.

Is SVG a good quality? ›

Svg files are vector-based, meaning you can scale them to any size without any loss in quality. No other file type looks as sharp as an svg. Svg files are actually code–a series of mathematical equations that define shapes, colors, and size. This is why they retain their high quality no matter how much you scale them.

What are the disadvantages of SVG images? ›

Cons: – the file size is growing very fast, if the object consists of a large number of small elements; – it's impossible to read a part of the graphic object, only the entire object and it slows you down.

How do you know if an image is a vector image? ›

Vector files use mathematical equations, lines, and curves with fixed points on a grid to produce an image. There are no pixels in a vector file. A vector file's mathematical formulas capture shape, border, and fill color to build an image.

Why is SVG not used? ›

SVG files can grow significantly in size if they contain a large number of small elements. This can lead to increased loading times and slower performance, particularly for complex graphics.

What is SVG short for? ›

SVG stands for Scalable Vector Graphics. Unlike JPEG, PNG, and GIF files, which are made up of pixels, SVG files are made up of vector graphics. That means they can be scaled to any size without losing quality.

How do I open a SVG image? ›

Open those SVG files through the web browser's Open option (the Ctrl+O keyboard shortcut). SVG files can be created through Adobe Illustrator, so you can use that program to open the file. Some other Adobe programs that support SVG files include Photoshop, Photoshop Elements, and InDesign programs.

Can you turn any image into SVG? ›

Absolutely. Upload any JPG image from your desktop or mobile device to convert to an SVG file.

What caused the Cairo to sink? ›

At the right moment, the two Confederates detonated the torpedoes with an electric charge. Two explosions ripped a large hole in the port bow causing the Cairo to quickly fill with water. Within 12 minutes, it sank to the bottom in six fathoms (36 feet) of water, but with no loss of life.

What is the Citadel of Cairo made of? ›

Cairo Citadel
Cairo Citadel قلعة صلاح الدين الأيوبي
Designated1979 (3rd session)
Part ofHistoric Cairo
Reference no.89-002
Materialsstone
13 more rows

What is the geology of Cairo? ›

The engineering geology of Cairo, Egypt, is essentially influenced by the Quaternary alluvial deposits of the River Nile and the adjacent desert dry streams, as well as by the Tertiary shallow marine carbonates of the ancient Mediterranean Sea and the terrestrial quartzitic sandstone.

What is Cairo surrounded by? ›

Cairo city is located on the Eastern bank of the Nile River and surrounded by Qalyubia province on the north and uninhabited desert on the south and the Giza province and the Nile River on the west.

References

Top Articles
2 Week Anti-Inflammatory Meal Plan - Breakfast, Lunch, and Dinner Recipes - Word From The Bird
Wingstop Cajun Fried Corn: A Delicious Copycat Recipe
Brokensilenze Website
Consignment Shops Milford Ct
Capital In The Caribbean Nyt
Craigslist Centre Alabama
Petco Westerly Ri
Gameplay Clarkston
What to Do For Dog Upset Stomach
Endicott Final Exam Schedule Fall 2023
Are Pharmacy Open On Sunday
Guardians Of The Galaxy Showtimes Near Athol Cinemas 8
Monkey Werx Sitrep 2022
Apryl Prose Wiki
โลโก้โภชนาการที่ดีที่สุด: สัญลักษณ์แห่งความเป็นเลิศ
Myzmanim Edison Nj
[PDF] JO S T OR - Free Download PDF
Blue Beetle Showtimes Near Regal Independence Plaza & Rpx
Dmv Leestown Rd
Cubilabras
Estrella Satánica Emoji
Wells Fargo Banks In Florida
G 037 White Oblong Pill
Dirt Devil Ud70181 Parts Diagram
Watch The Most Popular Video Of Mikayla Campinos Online
Craigslist For Sale By Owner Chillicothe Ohio
Ihub Fnma Message Board
Mylaheychart Login
Integral2 seems to substitute non-scalar values of variable into in...
Slmd Skincare Appointment
Laura Coates Parents Nationality
Craigslist Eugene Motorcycles
Takeaways from AP's report updating the cult massacre that claimed hundreds of lives in Kenya
Eddy Ketchersid Obituary
They Cloned Tyrone Showtimes Near Showbiz Cinemas - Kingwood
3 Izzy Ln, Kittery, ME 03904 - MLS 1603480 - Coldwell Banker
Leccion 4 Lesson Test
Hibbett, Inc. Stock (HIBB) - Quote Nasdaq- MarketScreener
4156303136
Bridger Elementary Logan
Make An Appointment Att
Jason Brewer Leaving Fox 25
Uw Oshkosh Wrestling
Linden Creek Golden Retrievers
Exploring The Craigslist Washington DC Marketplace - A Complete Overview
Deml Ford Used Cars
Directions To Pnc Near Me
Xfiles Wiki
Umn Biology
‘A Knights Tale’ Turns 20: Secrets Behind Heath Ledger’s Royal Rock Flick
Unblocked Games 67 Ez
Ktbs Payroll Login
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 6284

Rating: 4.9 / 5 (69 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.