Enums
Before Pycairo 1.13 most of the enum values defined here where only available as constants on the module level. See Legacy Constants.
- class cairo.Antialias(value: int)
- Specifies the type of antialiasing to do when rendering text or shapes. - Added in version 1.13. - BEST: Antialias = Ellipsis
- Hint that the backend should render at the highest quality, sacrificing speed if necessary. 
 - FAST: Antialias = Ellipsis
- Hint that the backend should perform some antialiasing but prefer speed over quality. 
 
- class cairo.Content(value: int)
- These constants are used to describe the content that a - Surfacewill contain, whether color information, alpha information (translucence vs. opacity), or both.- Added in version 1.13. 
- class cairo.Extend(value: int)
- These constants are used to describe how - Patterncolor/alpha will be determined for areas “outside” the pattern’s natural area, (for example, outside the surface bounds or outside the gradient geometry).- The default extend mode is - NONEfor- SurfacePatternand- PADfor- Gradientpatterns.- Added in version 1.13. - PAD: Extend = Ellipsis
- pixels outside of the pattern copy the closest pixel from the source (Since 1.2; but only implemented for surface patterns since 1.6) 
 
- class cairo.FillRule(value: int)
- These constants are used to select how paths are filled. For both fill rules, whether or not a point is included in the fill is determined by taking a ray from that point to infinity and looking at intersections with the path. The ray can be in any direction, as long as it doesn’t pass through the end point of a segment or have a tricky intersection such as intersecting tangent to the path. (Note that filling is not actually implemented in this way. This is just a description of the rule that is applied.) - The default fill rule is - WINDING.- Added in version 1.13. - EVEN_ODD: FillRule = Ellipsis
- Counts the total number of intersections, without regard to the orientation of the contour. If the total number of intersections is odd, the point will be filled. 
 - WINDING: FillRule = Ellipsis
- If the path crosses the ray from left-to-right, counts +1. If the path crosses the ray from right to left, counts -1. (Left and right are determined from the perspective of looking along the ray from the starting point.) If the total count is non-zero, the point will be filled. 
 
- class cairo.Filter(value: int)
- These constants are used to indicate what filtering should be applied when reading pixel values from patterns. See - Pattern.set_filter()for indicating the desired filter to be used with a particular pattern.- Added in version 1.13. - BEST: Filter = Ellipsis
- The highest-quality available, performance may not be suitable for interactive use. 
 
- class cairo.FontSlant(value: int)
- These constants specify variants of a - FontFacebased on their slant.- Added in version 1.13. 
- class cairo.FontWeight(value: int)
- These constants specify variants of a - FontFacebased on their weight.- Added in version 1.13. - BOLD: FontWeight = Ellipsis
- Bold font weight 
 - NORMAL: FontWeight = Ellipsis
- Normal font weight 
 
- class cairo.Format(value: int)
- These constants are used to identify the memory format of - ImageSurfacedata.- New entries may be added in future versions. - Added in version 1.13. - stride_for_width(width: int) int
- Parameters:
- width – the desired width of an - ImageSurfaceto be created.
- Returns:
- the appropriate stride to use given the desired format and width, or -1 if either the format is invalid or the width too large. 
 - This method provides a stride value that will respect all alignment requirements of the accelerated image-rendering code within cairo. Typical usage will be of the form: - format = cairo.Format.RGB24 stride = format.stride_for_width(width) surface = cairo.ImageSurface.create_for_data( data, format, width, height, stride) - Also available under - cairo.ImageSurface.format_stride_for_width().- Added in version 1.14. 
 - A1: Format = Ellipsis
- each pixel is a 1-bit quantity holding an alpha value. Pixels are packed together into 32-bit quantities. The ordering of the bits matches the endianess of the platform. On a big-endian machine, the first pixel is in the uppermost bit, on a little-endian machine the first pixel is in the least-significant bit. 
 - ARGB32: Format = Ellipsis
- each pixel is a 32-bit quantity, with alpha in the upper 8 bits, then red, then green, then blue. The 32-bit quantities are stored native-endian. Pre-multiplied alpha is used. (That is, 50% transparent red is 0x80800000, not 0x80ff0000.) 
 - RGB16_565: Format = Ellipsis
- each pixel is a 16-bit quantity with red in the upper 5 bits, then green in the middle 6 bits, and blue in the lower 5 bits. 
 - RGB24: Format = Ellipsis
- each pixel is a 32-bit quantity, with the upper 8 bits unused. [1] Red, Green, and Blue are stored in the remaining 24 bits in that order. 
 
- class cairo.HintMetrics(value: int)
- These constants specify whether to hint font metrics; hinting font metrics means quantizing them so that they are integer values in device space. Doing this improves the consistency of letter and line spacing, however it also means that text will be laid out differently at different zoom factors. - Added in version 1.13. - DEFAULT: HintMetrics = Ellipsis
- Hint metrics in the default manner for the font backend and target device 
 - OFF: HintMetrics = Ellipsis
- “Do not hint font metrics 
 - ON: HintMetrics = Ellipsis
- Hint font metrics 
 
- class cairo.HintStyle(value: int)
- These constants specify the type of hinting to do on font outlines. Hinting is the process of fitting outlines to the pixel grid in order to improve the appearance of the result. Since hinting outlines involves distorting them, it also reduces the faithfulness to the original outline shapes. Not all of the outline hinting styles are supported by all font backends. - New entries may be added in future versions. - Added in version 1.13. 
- class cairo.LineCap(value: int)
- These constants specify how to render the endpoints of the path when stroking. - The default line cap style is - BUTT- Added in version 1.13. 
- class cairo.LineJoin(value: int)
- These constants specify how to render the junction of two lines when stroking. - The default line join style is - MITER- Added in version 1.13. - BEVEL: LineJoin = Ellipsis
- use a cut-off join, the join is cut off at half the line width from the joint point 
 - MITER: LineJoin = Ellipsis
- use a sharp (angled) corner, see - Context.set_miter_limit()
 
- class cairo.Operator(value: int)
- These constants are used to set the compositing operator for all cairo drawing operations. - The default operator is - OVER.- The operators marked as unbounded modify their destination even outside of the mask layer (that is, their effect is not bound by the mask layer). However, their effect can still be limited by way of clipping. - To keep things simple, the operator descriptions here document the behavior for when both source and destination are either fully transparent or fully opaque. The actual implementation works for translucent layers too. - For a more detailed explanation of the effects of each operator, including the mathematical definitions, see https://cairographics.org/operators. - Added in version 1.13. - DARKEN: Operator = Ellipsis
- replaces the destination with the source if it is darker, otherwise keeps the source. 
 - DEST_ATOP: Operator = Ellipsis
- leave destination on top of source content and only there (unbounded) 
 - HSL_COLOR: Operator = Ellipsis
- Creates a color with the hue and saturation of the source and the luminosity of the target. This preserves the gray levels of the target and is useful for coloring monochrome images or tinting color images. 
 - HSL_HUE: Operator = Ellipsis
- Creates a color with the hue of the source and the saturation and luminosity of the target. 
 - HSL_LUMINOSITY: Operator = Ellipsis
- Creates a color with the luminosity of the source and the hue and saturation of the target. This produces an inverse effect to - HSL_COLOR
 - HSL_SATURATION: Operator = Ellipsis
- Creates a color with the saturation of the source and the hue and luminosity of the target. Painting with this mode onto a gray area produces no change. 
 - LIGHTEN: Operator = Ellipsis
- replaces the destination with the source if it is lighter, otherwise keeps the source. 
 - MULTIPLY: Operator = Ellipsis
- source and destination layers are multiplied. This causes the result to be at least as dark as the darker inputs. 
 - OVERLAY: Operator = Ellipsis
- multiplies or screens, depending on the lightness of the destination color. 
 
- class cairo.PathDataType(value: int)
- These constants are used to describe the type of one portion of a path when represented as a - Path.- Added in version 1.13. - CLOSE_PATH: PathDataType = Ellipsis
- A close-path operation 
 - CURVE_TO: PathDataType = Ellipsis
- A curve-to operation 
 - LINE_TO: PathDataType = Ellipsis
- A line-to operation 
 - MOVE_TO: PathDataType = Ellipsis
- A move-to operation 
 
- class cairo.PSLevel(value: int)
- These constants are used to describe the language level of the PostScript Language Reference that a generated PostScript file will conform to. Note: the constants are only defined when cairo has been compiled with PS support enabled. - Added in version 1.13. 
- class cairo.PDFVersion(value: int)
- These constants are used to describe the version number of the PDF specification that a generated PDF file will conform to. - Added in version 1.13. - VERSION_1_4: PDFVersion = Ellipsis
- The version 1.4 of the PDF specification. 
 - VERSION_1_5: PDFVersion = Ellipsis
- The version 1.5 of the PDF specification. 
 - VERSION_1_6: PDFVersion = Ellipsis
- The version 1.6 of the PDF specification. - Added in version 1.23.0: Only available with cairo 1.17.6+ 
 - VERSION_1_7: PDFVersion = Ellipsis
- The version 1.7 of the PDF specification. - Added in version 1.23.0: Only available with cairo 1.17.6+ 
 
- class cairo.SVGVersion(value: int)
- These constants are used to describe the version number of the SVG specification that a generated SVG file will conform to. - Added in version 1.13. - VERSION_1_1: SVGVersion = Ellipsis
- The version 1.1 of the SVG specification. 
 - VERSION_1_2: SVGVersion = Ellipsis
- The version 1.2 of the SVG specification. 
 
- class cairo.SubpixelOrder(value: int)
- The subpixel order specifies the order of color elements within each pixel on the display device when rendering with an antialiasing mode of - Antialias.SUBPIXEL.- Added in version 1.13. - BGR: SubpixelOrder = Ellipsis
- Subpixel elements are arranged horizontally with blue at the left 
 - DEFAULT: SubpixelOrder = Ellipsis
- Use the default subpixel order for for the target device 
 - RGB: SubpixelOrder = Ellipsis
- Subpixel elements are arranged horizontally with red at the left 
 - VBGR: SubpixelOrder = Ellipsis
- Subpixel elements are arranged vertically with blue at the top 
 - VRGB: SubpixelOrder = Ellipsis
- Subpixel elements are arranged vertically with red at the top 
 
- class cairo.RegionOverlap(value: int)
- Added in version 1.13. - IN: RegionOverlap = Ellipsis
- The contents are entirely inside the region. 
 - OUT: RegionOverlap = Ellipsis
- The contents are entirely outside the region. 
 - PART: RegionOverlap = Ellipsis
- The contents are partially inside and partially outside the region. 
 
- class cairo.ScriptMode(value: int)
- A set of script output variants. - Added in version 1.14. - ASCII: ScriptMode = Ellipsis
- the output will be in readable text (default) 
 - BINARY: ScriptMode = Ellipsis
- the output will use byte codes. 
 
- class cairo.TextClusterFlags(value: int)
- Specifies properties of a text cluster mapping. - Added in version 1.14. - BACKWARD: TextClusterFlags = Ellipsis
- The clusters in the cluster array map to glyphs in the glyph array from end to start. 
 
- class cairo.SurfaceObserverMode(value: int)
- Whether operations should be recorded. - Added in version 1.14. - NORMAL: SurfaceObserverMode = Ellipsis
- no recording is done 
 - RECORD_OPERATIONS: SurfaceObserverMode = Ellipsis
- operations are recorded 
 
- class cairo.PDFOutlineFlags(value: int)
- PDFOutlineFlagsis used by the- PDFSurface.add_outline()method to specify the attributes of an outline item. These flags may be bitwise-or’d to produce any combination of flags.- Added in version 1.18.0: Only available with cairo 1.15.10+ - OPEN: PDFOutlineFlags = Ellipsis
- The outline item defaults to open in the PDF viewer 
 - BOLD: PDFOutlineFlags = Ellipsis
- The outline item is displayed by the viewer in bold text 
 - ITALIC: PDFOutlineFlags = Ellipsis
- The outline item is displayed by the viewer in italic text 
 
- class cairo.SVGUnit(value: int)
- SVGUnitis used to describe the units valid for coordinates and lengths in the SVG specification.- See also: - Added in version 1.18.0: Only available with cairo 1.15.10+ 
- class cairo.PDFMetadata(value: int)
- PDFMetadatais used by the- PDFSurface.set_metadata()method to specify the metadata to set.- Added in version 1.18.0: Only available with cairo 1.15.10+ - TITLE: PDFMetadata = Ellipsis
- The document title 
 - AUTHOR: PDFMetadata = Ellipsis
- The document author 
 - SUBJECT: PDFMetadata = Ellipsis
- The document subject 
 - KEYWORDS: PDFMetadata = Ellipsis
- The document keywords 
 - CREATOR: PDFMetadata = Ellipsis
- The document creator 
 - CREATE_DATE: PDFMetadata = Ellipsis
- The document creation date 
 - MOD_DATE: PDFMetadata = Ellipsis
- The document modification date 
 
- class cairo.ColorMode(value: int)
- Specifies if color fonts are to be rendered using the color glyphs or outline glyphs. Glyphs that do not have a color presentation, and non-color fonts are not affected by this font option. - Added in version 1.25: Only available with cairo 1.17.8+ 
- class cairo.Dither(value: int)
- Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images (e.g. for gradients). Ordered dithering applies a precomputed threshold matrix to spread the errors smoothly. - Ditheris modeled on pixman dithering algorithm choice. As of Pixman 0.40, FAST corresponds to a 8x8 ordered bayer noise and GOOD and BEST use an ordered 64x64 precomputed blue noise.- Added in version 1.25: Only available with cairo 1.18.0+