cairo.types

D types for cairo1 library

Types 50

aliasBool = cairo_bool_t
aliasAntialias = cairo_antialias_t
aliasColorMode = cairo_color_mode_t
aliasContent = cairo_content_t
aliasDeviceType = cairo_device_type_t
aliasDither = cairo_dither_t
aliasExtend = cairo_extend_t
aliasFillRule = cairo_fill_rule_t
aliasFilter = cairo_filter_t
aliasFontSlant = cairo_font_slant_t
aliasFontType = cairo_font_type_t
aliasFontWeight = cairo_font_weight_t
aliasFormat = cairo_format_t
aliasHintMetrics = cairo_hint_metrics_t
aliasHintStyle = cairo_hint_style_t
aliasLineCap = cairo_line_cap_t
aliasLineJoin = cairo_line_join_t
aliasOperator = cairo_operator_t
aliasPathDataType = cairo_path_data_type_t
aliasPatternType = cairo_pattern_type_t
aliasPdfMetadata = cairo_pdf_metadata_t
aliasPdfOutlineFlags = cairo_pdf_outline_flags_t
aliasPdfVersion = cairo_pdf_version_t
aliasPsLevel = cairo_ps_level_t
aliasRegionOverlap = cairo_region_overlap_t
aliasScriptMode = cairo_script_mode_t
aliasStatus = cairo_status_t
aliasSubpixelOrder = cairo_subpixel_order_t
aliasSurfaceObserverMode = cairo_surface_observer_mode_t
aliasSurfaceType = cairo_surface_type_t
aliasSvgUnit = cairo_svg_unit_t
aliasSvgVersion = cairo_svg_version_t
aliasTextClusterFlags = cairo_text_cluster_flags_t
aliasFontExtents = cairo_font_extents_t
aliasRectangle = cairo_rectangle_t
aliasRectangleInt = cairo_rectangle_int_t
aliasTextExtents = cairo_text_extents_t
aliasUserDataKey = cairo_user_data_key_t
aliasDestroyFunc = void delegate()

#cairo_destroy_func_t the type of function which is called when a data element is destroyed. It is passed the pointer to the data element and should free any memory and resources allocated for it.

#cairo_raster_source_acquire_func_t is the type of function which is called when a pattern is being rendered from. It should create a surface that provides the pixel data for the region of interest as defined by extents, though the surface itself does not have to be limited to that area. For convenience the surface should probably be of image type, created with [cairo.surface.Surface.createSimilarImage] for the target (which enables the number of copies to be reduced during transfer to the device). Another option, might be to return a similar surface to the target for explicit handling by the application of a set of cached sources on the device. The region of sample data provided should be defined using [cairo.surface.Surface.setDeviceOffset] to specify the top-left corner of the sample data (along with width and height of the surface).

Parameters

patternthe pattern being rendered from
targetthe rendering target surface
extentsrectangular region of interest in pixels in sample space

Returns

a #cairo_surface_t

#cairo_raster_source_copy_func_t is the type of function which is called when the pattern gets copied as a normal part of rendering.

Parameters

patternthe #cairo_pattern_t that was copied to
otherthe #cairo_pattern_t being used as the source for the copy

Returns

CAIRO_STATUS_SUCCESS on success, or one of the

#cairo_status_t error codes for failure.

aliasRasterSourceFinishFunc = void delegate(cairo.pattern.Pattern pattern)

#cairo_raster_source_finish_func_t is the type of function which is called when the pattern (or a copy thereof) is no longer required.

Parameters

patternthe pattern being rendered from

#cairo_raster_source_release_func_t is the type of function which is called when the pixel data is no longer being access by the pattern for the rendering operation. Typically this function will simply destroy the surface created during acquire.

Parameters

patternthe pattern being rendered from
surfacethe surface created during acquire

#cairo_raster_source_snapshot_func_t is the type of function which is called when the pixel data needs to be preserved for later use during printing. This pattern will be accessed again later, and it is expected to provide the pixel data that was current at the time of snapshotting.

Parameters

patternthe pattern being rendered from

Returns

CAIRO_STATUS_SUCCESS on success, or one of the

#cairo_status_t error codes for failure.

aliasReadFunc = cairo.types.Status delegate(ubyte[] data)

#cairo_read_func_t is the type of function which is called when a backend needs to read data from an input stream. It is passed the closure which was specified by the user at the time the read function was registered, the buffer to read the data into and the length of the data in bytes. The read function should return [cairo.types.Status.Success] if all the data was successfully read, [cairo.types.Status.ReadError] otherwise.

Parameters

datathe buffer into which to read the data

Returns

the status code of the read operation

A generic callback function for surface operations.

Parameters

observerthe #cairo_surface_observer_t
targetthe observed surface

#cairo_user_scaled_font_init_func_t is the type of function which is called when a scaled-font needs to be created for a user font-face.

The cairo context cr is not used by the caller, but is prepared in font space, similar to what the cairo contexts passed to the render_glyph method will look like. The callback can use this context for extents computation for example. After the callback is called, cr is checked for any error status.

The extents argument is where the user font sets the font extents for scaled_font. It is in font space, which means that for most cases its ascent and descent members should add to 1.0. extents is preset to hold a value of 1.0 for ascent, height, and max_x_advance, and 0.0 for descent and max_y_advance members.

The callback is optional. If not set, default font extents as described in the previous paragraph will be used.

Note that scaled_font is not fully initialized at this point and trying to use it for text operations in the callback will result in deadlock.

Parameters

scaledFontthe scaled-font being created
cra cairo context, in font space
extentsfont extents to fill in, in font space

Returns

[cairo.types.Status.Success] upon success, or an error status on error.

#cairo_user_scaled_font_render_glyph_func_t is the type of function which is called when a user scaled-font needs to render a glyph.

The callback is mandatory, and expected to draw the glyph with code glyph to the cairo context cr. cr is prepared such that the glyph drawing is done in font space. That is, the matrix set on cr is the scale matrix of scaled_font. The extents argument is where the user font sets the font extents for scaled_font. However, if user prefers to draw in user space, they can achieve that by changing the matrix on cr.

All cairo rendering operations to cr are permitted. However, when this callback is set with [cairo.global.userFontFaceSetRenderGlyphFunc], the result is undefined if any source other than the default source on cr is used. That means, glyph bitmaps should be rendered using [cairo.context.Context.mask] instead of [cairo.context.Context.paint].

When this callback is set with [cairo.global.userFontFaceSetRenderColorGlyphFunc], the default source is black. Setting the source is a valid operation. [cairo.global.userScaledFontGetForegroundMarker] or [cairo.global.userScaledFontGetForegroundSource] may be called to obtain the current source at the time the glyph is rendered.

Other non-default settings on cr include a font size of 1.0 (given that it is set up to be in font space), and font options corresponding to scaled_font.

The extents argument is preset to have <literal>x_bearing</literal>,

<literal>width</literal>, and <literal>y_advance</literal> of zero, <literal>y_bearing</literal> set to <literal>-font_extents.ascent</literal>, <literal>height</literal> to <literal>font_extents.ascent+font_extents.descent</literal>,

and <literal>x_advance</literal> to <literal>font_extents.max_x_advance</literal>. The only field user needs to set in majority of cases is

<literal>x_advance</literal>.

If the <literal>width</literal> field is zero upon the callback returning (which is its preset value), the glyph extents are automatically computed based on the drawings done to cr. This is in most cases exactly what the desired behavior is. However, if for any reason the callback sets the extents, it must be ink extents, and include the extents of all drawing done to cr in the callback.

Where both color and non-color callbacks has been set using [cairo.global.userFontFaceSetRenderColorGlyphFunc], and [cairo.global.userFontFaceSetRenderGlyphFunc], the color glyph callback will be called first. If the color glyph callback returns [cairo.types.Status.UserFontNotImplemented], any drawing operations are discarded and the non-color callback will be called. This is the only case in which the [cairo.types.Status.UserFontNotImplemented] may be returned from a render callback. This fallback sequence allows a user font face to contain a combination of both color and non-color glyphs.

Parameters

scaledFontuser scaled-font
glyphglyph code to render
crcairo context to draw to, in font space
extentsglyph extents to fill in, in font space

Returns

[cairo.types.Status.Success] upon success,

[cairo.types.Status.UserFontNotImplemented] if fallback options should be tried, or [cairo.types.Status.UserFontError] or any other error status on error.

aliasUserScaledFontUnicodeToGlyphFunc = cairo.types.Status delegate(cairo.scaled_font.ScaledFont scaledFont, gulong unicode, out gulong glyphIndex)

#cairo_user_scaled_font_unicode_to_glyph_func_t is the type of function which is called to convert an input Unicode character to a single glyph. This is used by the [cairo.context.Context.showText] operation.

This callback is used to provide the same functionality as the text_to_glyphs callback does (see #cairo_user_scaled_font_text_to_glyphs_func_t) but has much less control on the output, in exchange for increased ease of use. The inherent assumption to using this callback is that each character maps to one glyph, and that the mapping is context independent. It also assumes that glyphs are positioned according to their advance width. These mean no ligatures, kerning, or complex scripts can be implemented using this callback.

The callback is optional, and only used if text_to_glyphs callback is not set or fails to return glyphs. If this callback is not set or if it returns [cairo.types.Status.UserFontNotImplemented], an identity mapping from Unicode code-points to glyph indices is assumed.

Note

While cairo does not impose any limitation on glyph indices,

some applications may assume that a glyph index fits in a 16-bit unsigned integer. As such, it is advised that user-fonts keep their glyphs in the 0 to 65535 range. Furthermore, some applications may assume that glyph 0 is a special glyph-not-found glyph. User-fonts are advised to use glyph 0 for such purposes and do not use that glyph value for other purposes.

Parameters

scaledFontthe scaled-font being created
unicodeinput unicode character code-point
glyphIndexoutput glyph index

Returns

[cairo.types.Status.Success] upon success,

[cairo.types.Status.UserFontNotImplemented] if fallback options should be tried, or [cairo.types.Status.UserFontError] or any other error status on error.

aliasWriteFunc = cairo.types.Status delegate(ubyte[] data)

#cairo_write_func_t is the type of function which is called when a backend needs to write data to an output stream. It is passed the closure which was specified by the user at the time the write function was registered, the data to write and the length of the data in bytes. The write function should return [cairo.types.Status.Success] if all the data was successfully written, [cairo.types.Status.WriteError] otherwise.

Parameters

datathe buffer containing the data to write

Returns

the status code of the write operation

Variables 18

enumvarCOLOR_PALETTE_DEFAULT = 0

The default color palette index.

enumvarMIME_TYPE_CCITT_FAX = "image/g3fax"

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

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

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

enumvarMIME_TYPE_EPS = "application/postscript"
enumvarMIME_TYPE_EPS_PARAMS = "application/x-cairo.eps.params"

Embedding parameters Encapsulated PostScript data. See [Embedding EPS files][eps].

enumvarMIME_TYPE_JBIG2 = "application/x-cairo.jbig2"

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

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

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

enumvarMIME_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.

enumvarMIME_TYPE_JP2 = "image/jp2"

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

enumvarMIME_TYPE_JPEG = "image/jpeg"

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

enumvarMIME_TYPE_PNG = "image/png"

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

enumvarMIME_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.

enumvarMIME_TYPE_URI = "text/x-uri"

URI for an image file (unofficial MIME type).

enumvarPDF_OUTLINE_ROOT = 0

The root outline item in [cairo.global.pdfSurfaceAddOutline].

enumvarTAG_CONTENT = "cairo.content"

Create a content tag.

enumvarTAG_CONTENT_REF = "cairo.content_ref"

Create a content reference tag.

enumvarTAG_DEST = "cairo.dest"

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

enumvarTAG_LINK = "Link"

Create hyperlink. Link tag attributes are detailed at [Links][link].