Module Functions and Constants

Module Functions

cairo.cairo_version()
Returns

the encoded version

Return type

int

Returns the version of the underlying C cairo library, encoded in a single integer.

cairo.cairo_version_string()
Returns

the encoded version

Return type

str

Returns the version of the underlying C cairo library as a human-readable string of the form “X.Y.Z”.

cairo.get_include()
Returns

a path to the directory containing the C header files

Return type

str

Gives the include path which should be passed to the compiler.

New in version 1.16.0.

Module Constants

cairo.version

the pycairo version, as a string

cairo.version_info

the pycairo version, as a tuple

cairo.CAIRO_VERSION

The version of cairo available at compile-time in the same format as returned by cairo_version()

New in version 1.18.0.

cairo.CAIRO_VERSION_STRING

A human-readable string literal containing the version of cairo available at compile-time, in the form of “X.Y.Z”.

New in version 1.18.0.

cairo.CAIRO_VERSION_MAJOR

The major component of the version of cairo available at compile-time.

New in version 1.18.0.

cairo.CAIRO_VERSION_MINOR

The minor component of the version of cairo available at compile-time.

New in version 1.18.0.

cairo.CAIRO_VERSION_MICRO

The micro component of the version of cairo available at compile-time.

New in version 1.18.0.

cairo.HAS

1 if the feature is present in the underlying C cairo library, 0 otherwise.

cairo.HAS_ATSUI_FONT
cairo.HAS_FT_FONT
cairo.HAS_GLITZ_SURFACE
cairo.HAS_IMAGE_SURFACE
cairo.HAS_PDF_SURFACE
cairo.HAS_PNG_FUNCTIONS
cairo.HAS_PS_SURFACE
cairo.HAS_RECORDING_SURFACE
cairo.HAS_SVG_SURFACE
cairo.HAS_USER_FONT
cairo.HAS_QUARTZ_SURFACE
cairo.HAS_WIN32_FONT
cairo.HAS_WIN32_SURFACE
cairo.HAS_XCB_SURFACE
cairo.HAS_XLIB_SURFACE
cairo.HAS_MIME_SURFACE

New in version 1.12.0.

cairo.HAS_SCRIPT_SURFACE

New in version 1.12.0.

cairo.HAS_TEE_SURFACE

New in version 1.15.3.

cairo.TAG

cairo.TAG_DEST = "cairo.dest"

Create a destination for a hyperlink. Destination tag attributes are detailed at Destinations.

New in version 1.18.0: Only available with cairo 1.15.10+

Create hyperlink. Link tag attributes are detailed at Links.

New in version 1.18.0: Only available with cairo 1.15.10+

cairo.MIME_TYPE

cairo.MIME_TYPE_JP2 = "image/jp2"

The Joint Photographic Experts Group (JPEG) 2000 image coding standard (ISO/IEC 15444-1).

New in version 1.12.0.

cairo.MIME_TYPE_JPEG = "image/jpeg"

The Joint Photographic Experts Group (JPEG) image coding standard (ISO/IEC 10918-1).

New in version 1.12.0.

cairo.MIME_TYPE_PNG = "image/png"

The Portable Network Graphics image file format (ISO/IEC 15948).

New in version 1.12.0.

cairo.MIME_TYPE_URI = "text/x-uri"

URI for an image file (unofficial MIME type).

New in version 1.12.0.

cairo.MIME_TYPE_UNIQUE_ID = "application/x-cairo.uuid"

Unique identifier for a surface (cairo specific MIME type). All surfaces with the same unique identifier will only be embedded once.

New in version 1.12.0.

cairo.MIME_TYPE_CCITT_FAX = "image/g3fax"

Group 3 or Group 4 CCITT facsimile encoding (International Telecommunication Union, Recommendations T.4 and T.6.)

New in version 1.18.0: Only available with cairo 1.15.10+

cairo.MIME_TYPE_CCITT_FAX_PARAMS = "application/x-cairo.ccitt.params"

Decode parameters for Group 3 or Group 4 CCITT facsimile encoding. See CCITT Fax Images.

New in version 1.18.0: Only available with cairo 1.15.10+

cairo.MIME_TYPE_EPS = "application/postscript"

Encapsulated PostScript file. Encapsulated PostScript File Format Specification

New in version 1.18.0: Only available with cairo 1.15.10+

cairo.MIME_TYPE_EPS_PARAMS = "application/x-cairo.eps.params"

Embedding parameters Encapsulated PostScript data. See Embedding EPS files.

New in version 1.18.0: Only available with cairo 1.15.10+

cairo.MIME_TYPE_JBIG2 = "application/x-cairo.jbig2"

Joint Bi-level Image Experts Group image coding standard (ISO/IEC 11544).

New in version 1.18.0.

cairo.MIME_TYPE_JBIG2_GLOBAL = "application/x-cairo.jbig2-global"

Joint Bi-level Image Experts Group image coding standard (ISO/IEC 11544) global segment.

New in version 1.18.0.

cairo.MIME_TYPE_JBIG2_GLOBAL_ID = "application/x-cairo.jbig2-global-id"

An unique identifier shared by a JBIG2 global segment and all JBIG2 images that depend on the global segment.

New in version 1.18.0.

Other Constants

cairo.PDF_OUTLINE_ROOT = 0

The root outline item in PDFSurface.add_outline()

New in version 1.18.0: Only available with cairo 1.15.10+

Other Classes and Functions

class cairo.text

This type only exists for documentation purposes. It represents str under Python 3.

class cairo.pathlike

This type only exists for documentation purposes.

On Unix it is equal to what Python allows as a filesystem path. On Windows with cairo <=1.15.8 only ANSI paths are supported. With cairo >=1.15.10 all paths are supported as long as they don’t contain surrogates.

Many functions taking a path also allow passing in an already open Python file object. This can be used to support all Python filesystem paths independent of the underlying platform or cairo version.

New in version 1.15.1: Older versions only supported a subset of str paths