Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def copy_path(self): path = cairo.cairo_copy_path(self._pointer) result = list(_iter_path(path)) cairo.cairo_path_destroy(path) return result
[ "Return a copy of the current path.\n\n :returns:\n A list of ``(path_operation, coordinates)`` tuples\n of a :ref:`PATH_OPERATION` string\n and a tuple of floats coordinates\n whose content depends on the operation type:\n\n * :obj:`MOVE_TO <PATH_MOVE_T...
Please provide a description of the function:def copy_path_flat(self): path = cairo.cairo_copy_path_flat(self._pointer) result = list(_iter_path(path)) cairo.cairo_path_destroy(path) return result
[ "Return a flattened copy of the current path\n\n This method is like :meth:`copy_path`\n except that any curves in the path will be approximated\n with piecewise-linear approximations,\n (accurate to within the current tolerance value,\n see :meth:`set_tolerance`).\n That i...
Please provide a description of the function:def append_path(self, path): # Both objects need to stay alive # until after cairo.cairo_append_path() is finished, but not after. path, _ = _encode_path(path) cairo.cairo_append_path(self._pointer, path) self._check_status()
[ "Append :obj:`path` onto the current path.\n The path may be either the return value from one of :meth:`copy_path`\n or :meth:`copy_path_flat` or it may be constructed manually.\n\n :param path:\n An iterable of tuples\n in the same format as returned by :meth:`copy_path`....
Please provide a description of the function:def path_extents(self): extents = ffi.new('double[4]') cairo.cairo_path_extents( self._pointer, extents + 0, extents + 1, extents + 2, extents + 3) self._check_status() return tuple(extents)
[ "Computes a bounding box in user-space coordinates\n covering the points on the current path.\n If the current path is empty,\n returns an empty rectangle ``(0, 0, 0, 0)``.\n Stroke parameters, fill rule, surface dimensions and clipping\n are not taken into account.\n\n Con...
Please provide a description of the function:def mask(self, pattern): cairo.cairo_mask(self._pointer, pattern._pointer) self._check_status()
[ "A drawing operator that paints the current source\n using the alpha channel of :obj:`pattern` as a mask.\n (Opaque areas of :obj:`pattern` are painted with the source,\n transparent areas are not painted.)\n\n :param pattern: A :class:`Pattern` object.\n\n " ]
Please provide a description of the function:def mask_surface(self, surface, surface_x=0, surface_y=0): cairo.cairo_mask_surface( self._pointer, surface._pointer, surface_x, surface_y) self._check_status()
[ "A drawing operator that paints the current source\n using the alpha channel of :obj:`surface` as a mask.\n (Opaque areas of :obj:`surface` are painted with the source,\n transparent areas are not painted.)\n\n :param pattern: A :class:`Surface` object.\n :param surface_x: X coord...
Please provide a description of the function:def fill_extents(self): extents = ffi.new('double[4]') cairo.cairo_fill_extents( self._pointer, extents + 0, extents + 1, extents + 2, extents + 3) self._check_status() return tuple(extents)
[ "Computes a bounding box in user-space coordinates\n covering the area that would be affected, (the \"inked\" area),\n by a :meth:`fill` operation given the current path and fill parameters.\n If the current path is empty,\n returns an empty rectangle ``(0, 0, 0, 0)``.\n Surface d...
Please provide a description of the function:def in_fill(self, x, y): return bool(cairo.cairo_in_fill(self._pointer, x, y))
[ "Tests whether the given point is inside the area\n that would be affected by a :meth:`fill` operation\n given the current path and filling parameters.\n Surface dimensions and clipping are not taken into account.\n\n See :meth:`fill`, :meth:`set_fill_rule` and :meth:`fill_preserve`.\n\n...
Please provide a description of the function:def stroke_extents(self): extents = ffi.new('double[4]') cairo.cairo_stroke_extents( self._pointer, extents + 0, extents + 1, extents + 2, extents + 3) self._check_status() return tuple(extents)
[ "Computes a bounding box in user-space coordinates\n covering the area that would be affected, (the \"inked\" area),\n by a :meth:`stroke` operation given the current path\n and stroke parameters.\n If the current path is empty,\n returns an empty rectangle ``(0, 0, 0, 0)``.\n ...
Please provide a description of the function:def in_stroke(self, x, y): return bool(cairo.cairo_in_stroke(self._pointer, x, y))
[ "Tests whether the given point is inside the area\n that would be affected by a :meth:`stroke` operation\n given the current path and stroking parameters.\n Surface dimensions and clipping are not taken into account.\n\n See :meth:`stroke`, :meth:`set_line_width`, :meth:`set_line_join`,\...
Please provide a description of the function:def clip_extents(self): extents = ffi.new('double[4]') cairo.cairo_clip_extents( self._pointer, extents + 0, extents + 1, extents + 2, extents + 3) self._check_status() return tuple(extents)
[ "Computes a bounding box in user coordinates\n covering the area inside the current clip.\n\n :return:\n A ``(x1, y1, x2, y2)`` tuple of floats:\n the left, top, right and bottom of the resulting extents,\n respectively.\n\n " ]
Please provide a description of the function:def copy_clip_rectangle_list(self): rectangle_list = cairo.cairo_copy_clip_rectangle_list(self._pointer) _check_status(rectangle_list.status) rectangles = rectangle_list.rectangles result = [] for i in range(rectangle_list.num...
[ "Return the current clip region as a list of rectangles\n in user coordinates.\n\n :return:\n A list of rectangles,\n as ``(x, y, width, height)`` tuples of floats.\n :raises:\n :exc:`CairoError`\n if the clip region cannot be represented as a list\n...
Please provide a description of the function:def in_clip(self, x, y): return bool(cairo.cairo_in_clip(self._pointer, x, y))
[ "Tests whether the given point is inside the area\n that would be visible through the current clip,\n i.e. the area that would be filled by a :meth:`paint` operation.\n\n See :meth:`clip`, and :meth:`clip_preserve`.\n\n :param x: X coordinate of the point to test\n :param y: Y coo...
Please provide a description of the function:def select_font_face(self, family='', slant=constants.FONT_SLANT_NORMAL, weight=constants.FONT_WEIGHT_NORMAL): cairo.cairo_select_font_face( self._pointer, _encode_string(family), slant, weight) self._check_status...
[ "Selects a family and style of font from a simplified description\n as a family name, slant and weight.\n\n .. note::\n\n The :meth:`select_font_face` method is part of\n what the cairo designers call the \"toy\" text API.\n It is convenient for short demos and simple ...
Please provide a description of the function:def set_font_face(self, font_face): font_face = font_face._pointer if font_face is not None else ffi.NULL cairo.cairo_set_font_face(self._pointer, font_face) self._check_status()
[ "Replaces the current font face with :obj:`font_face`.\n\n :param font_face:\n A :class:`FontFace` object,\n or :obj:`None` to restore the default font.\n\n " ]
Please provide a description of the function:def get_font_face(self): return FontFace._from_pointer( cairo.cairo_get_font_face(self._pointer), incref=True)
[ "Return the current font face.\n\n :param font_face:\n A new :class:`FontFace` object\n wrapping an existing cairo object.\n\n " ]
Please provide a description of the function:def set_font_size(self, size): cairo.cairo_set_font_size(self._pointer, size) self._check_status()
[ "Sets the current font matrix to a scale by a factor of :obj:`size`,\n replacing any font matrix previously set with :meth:`set_font_size`\n or :meth:`set_font_matrix`.\n This results in a font size of size user space units.\n (More precisely, this matrix will result in the font's\n ...
Please provide a description of the function:def set_font_matrix(self, matrix): cairo.cairo_set_font_matrix(self._pointer, matrix._pointer) self._check_status()
[ "Sets the current font matrix to :obj:`matrix`.\n The font matrix gives a transformation\n from the design space of the font\n (in this space, the em-square is 1 unit by 1 unit)\n to user space.\n Normally, a simple scale is used (see :meth:`set_font_size`),\n but a more co...
Please provide a description of the function:def get_font_matrix(self): matrix = Matrix() cairo.cairo_get_font_matrix(self._pointer, matrix._pointer) self._check_status() return matrix
[ "Copies the current font matrix. See :meth:`set_font_matrix`.\n\n :returns: A new :class:`Matrix`.\n\n " ]
Please provide a description of the function:def set_font_options(self, font_options): cairo.cairo_set_font_options(self._pointer, font_options._pointer) self._check_status()
[ "Sets a set of custom font rendering options.\n Rendering options are derived by merging these options\n with the options derived from underlying surface;\n if the value in options has a default value\n (like :obj:`ANTIALIAS_DEFAULT`),\n then the value from the surface is used.\n\...
Please provide a description of the function:def get_font_options(self): font_options = FontOptions() cairo.cairo_get_font_options(self._pointer, font_options._pointer) return font_options
[ "Retrieves font rendering options set via :meth:`set_font_options`.\n Note that the returned options do not include any options\n derived from the underlying surface;\n they are literally the options passed to :meth:`set_font_options`.\n\n :return: A new :class:`FontOptions` object.\n\n ...
Please provide a description of the function:def set_scaled_font(self, scaled_font): cairo.cairo_set_scaled_font(self._pointer, scaled_font._pointer) self._check_status()
[ "Replaces the current font face, font matrix, and font options\n with those of :obj:`scaled_font`.\n Except for some translation, the current CTM of the context\n should be the same as that of the :obj:`scaled_font`,\n which can be accessed using :meth:`ScaledFont.get_ctm`.\n\n :p...
Please provide a description of the function:def get_scaled_font(self): return ScaledFont._from_pointer( cairo.cairo_get_scaled_font(self._pointer), incref=True)
[ "Return the current scaled font.\n\n :return:\n A new :class:`ScaledFont` object,\n wrapping an existing cairo object.\n\n " ]
Please provide a description of the function:def font_extents(self): extents = ffi.new('cairo_font_extents_t *') cairo.cairo_font_extents(self._pointer, extents) self._check_status() # returning extents as is would be a nice API, # but return a tuple for compat with pyca...
[ "Return the extents of the currently selected font.\n\n Values are given in the current user-space coordinate system.\n\n Because font metrics are in user-space coordinates, they are mostly,\n but not entirely, independent of the current transformation matrix.\n If you call :meth:`contex...
Please provide a description of the function:def text_extents(self, text): extents = ffi.new('cairo_text_extents_t *') cairo.cairo_text_extents(self._pointer, _encode_string(text), extents) self._check_status() # returning extents as is would be a nice API, # but return ...
[ "Returns the extents for a string of text.\n\n The extents describe a user-space rectangle\n that encloses the \"inked\" portion of the text,\n (as it would be drawn by :meth:`show_text`).\n Additionally, the :obj:`x_advance` and :obj:`y_advance` values\n indicate the amount by wh...
Please provide a description of the function:def glyph_extents(self, glyphs): glyphs = ffi.new('cairo_glyph_t[]', glyphs) extents = ffi.new('cairo_text_extents_t *') cairo.cairo_glyph_extents( self._pointer, glyphs, len(glyphs), extents) self._check_status() ...
[ "Returns the extents for a list of glyphs.\n\n The extents describe a user-space rectangle\n that encloses the \"inked\" portion of the glyphs,\n (as it would be drawn by :meth:`show_glyphs`).\n Additionally, the :obj:`x_advance` and :obj:`y_advance` values\n indicate the amount b...
Please provide a description of the function:def show_text(self, text): cairo.cairo_show_text(self._pointer, _encode_string(text)) self._check_status()
[ "A drawing operator that generates the shape from a string text,\n rendered according to the current\n font :meth:`face <set_font_face>`,\n font :meth:`size <set_font_size>`\n (font :meth:`matrix <set_font_matrix>`),\n and font :meth:`options <set_font_options>`.\n\n This m...
Please provide a description of the function:def show_glyphs(self, glyphs): glyphs = ffi.new('cairo_glyph_t[]', glyphs) cairo.cairo_show_glyphs(self._pointer, glyphs, len(glyphs)) self._check_status()
[ "A drawing operator that generates the shape from a list of glyphs,\n rendered according to the current\n font :meth:`face <set_font_face>`,\n font :meth:`size <set_font_size>`\n (font :meth:`matrix <set_font_matrix>`),\n and font :meth:`options <set_font_options>`.\n\n :pa...
Please provide a description of the function:def show_text_glyphs(self, text, glyphs, clusters, cluster_flags=0): glyphs = ffi.new('cairo_glyph_t[]', glyphs) clusters = ffi.new('cairo_text_cluster_t[]', clusters) cairo.cairo_show_text_glyphs( self._pointer, _encode_string(te...
[ "This operation has rendering effects similar to :meth:`show_glyphs`\n but, if the target surface supports it\n (see :meth:`Surface.has_show_text_glyphs`),\n uses the provided text and cluster mapping\n to embed the text for the glyphs shown in the output.\n If the target does not...
Please provide a description of the function:def tag_begin(self, tag_name, attributes=None): if attributes is None: attributes = '' cairo.cairo_tag_begin( self._pointer, _encode_string(tag_name), _encode_string(attributes)) self._check_status()
[ "Marks the beginning of the ``tag_name`` structure.\n\n Call :meth:`tag_end` with the same ``tag_name`` to mark the end of the\n structure.\n\n The attributes string is of the form \"key1=value2 key2=value2 ...\".\n Values may be boolean (true/false or 1/0), integer, float, string, or\n ...
Please provide a description of the function:def tag_end(self, tag_name): cairo.cairo_tag_end(self._pointer, _encode_string(tag_name)) self._check_status()
[ "Marks the end of the ``tag_name`` structure.\n\n Invalid nesting of tags will cause @cr to shutdown with a status of\n ``CAIRO_STATUS_TAG_ERROR``.\n\n See :meth:`tag_begin`.\n\n :param tag_name: tag name\n\n *New in cairo 1.16.*\n\n *New in cairocffi 0.9.*\n\n " ]
Please provide a description of the function:def _make_read_func(file_obj): @ffi.callback("cairo_read_func_t", error=constants.STATUS_READ_ERROR) def read_func(_closure, data, length): string = file_obj.read(length) if len(string) < length: # EOF too early return constants.STAT...
[ "Return a CFFI callback that reads from a file-like object." ]
Please provide a description of the function:def _make_write_func(file_obj): if file_obj is None: return ffi.NULL @ffi.callback("cairo_write_func_t", error=constants.STATUS_WRITE_ERROR) def write_func(_closure, data, length): file_obj.write(ffi.buffer(data, length)) return cons...
[ "Return a CFFI callback that writes to a file-like object." ]
Please provide a description of the function:def _encode_filename(filename): # pragma: no cover # Don't replace unknown characters as '?' is forbidden in Windows filenames errors = 'ignore' if os.name == 'nt' else 'replace' if not isinstance(filename, bytes): if os.name == 'nt' and cairo.cair...
[ "Return a byte string suitable for a filename.\n\n Unicode is encoded using an encoding adapted to what both cairo and the\n filesystem want.\n\n " ]
Please provide a description of the function:def from_buffer(obj): if hasattr(obj, 'buffer_info'): # Looks like a array.array object. address, length = obj.buffer_info() return address, length * obj.itemsize else: # Other buffers. # XXX Unfortunately ctypes.c_char.fr...
[ "Return ``(pointer_address, length_in_bytes)`` for a buffer object." ]
Please provide a description of the function:def _from_pointer(pointer, incref): if pointer == ffi.NULL: raise ValueError('Null pointer') if incref: cairo.cairo_surface_reference(pointer) self = object.__new__(SURFACE_TYPE_TO_CLASS.get( cairo.cairo_su...
[ "Wrap an existing :c:type:`cairo_surface_t *` cdata pointer.\n\n :type incref: bool\n :param incref:\n Whether increase the :ref:`reference count <refcounting>` now.\n :return:\n A new instance of :class:`Surface` or one of its sub-classes,\n depending on the su...
Please provide a description of the function:def create_similar(self, content, width, height): return Surface._from_pointer( cairo.cairo_surface_create_similar( self._pointer, content, width, height), incref=False)
[ "Create a new surface that is as compatible as possible\n for uploading to and the use in conjunction with this surface.\n For example the new surface will have the same fallback resolution\n and :class:`FontOptions`.\n Generally, the new surface will also use the same backend as other,\...
Please provide a description of the function:def create_similar_image(self, content, width, height): return Surface._from_pointer( cairo.cairo_surface_create_similar_image( self._pointer, content, width, height), incref=False)
[ "\n Create a new image surface that is as compatible as possible\n for uploading to and the use in conjunction with this surface.\n However, this surface can still be used like any normal image surface.\n\n Initially the surface contents are all 0\n (transparent if contents have t...
Please provide a description of the function:def create_for_rectangle(self, x, y, width, height): return Surface._from_pointer( cairo.cairo_surface_create_for_rectangle( self._pointer, x, y, width, height), incref=False)
[ "\n Create a new surface that is a rectangle within this surface.\n All operations drawn to this surface are then clipped and translated\n onto the target surface.\n Nothing drawn via this sub-surface outside of its bounds\n is drawn onto the target surface,\n making this a...
Please provide a description of the function:def set_device_offset(self, x_offset, y_offset): cairo.cairo_surface_set_device_offset( self._pointer, x_offset, y_offset) self._check_status()
[ " Sets an offset that is added to the device coordinates\n determined by the CTM when drawing to surface.\n One use case for this method is\n when we want to create a :class:`Surface` that redirects drawing\n for a portion of an onscreen surface\n to an offscreen surface in a way ...
Please provide a description of the function:def get_device_offset(self): offsets = ffi.new('double[2]') cairo.cairo_surface_get_device_offset( self._pointer, offsets + 0, offsets + 1) return tuple(offsets)
[ "Returns the previous device offset set by :meth:`set_device_offset`.\n\n :returns: ``(x_offset, y_offset)``\n\n " ]
Please provide a description of the function:def set_fallback_resolution(self, x_pixels_per_inch, y_pixels_per_inch): cairo.cairo_surface_set_fallback_resolution( self._pointer, x_pixels_per_inch, y_pixels_per_inch) self._check_status()
[ "\n Set the horizontal and vertical resolution for image fallbacks.\n\n When certain operations aren't supported natively by a backend,\n cairo will fallback by rendering operations to an image\n and then overlaying that image onto the output.\n For backends that are natively vect...
Please provide a description of the function:def get_fallback_resolution(self): ppi = ffi.new('double[2]') cairo.cairo_surface_get_fallback_resolution( self._pointer, ppi + 0, ppi + 1) return tuple(ppi)
[ "Returns the previous fallback resolution\n set by :meth:`set_fallback_resolution`,\n or default fallback resolution if never set.\n\n :returns: ``(x_pixels_per_inch, y_pixels_per_inch)``\n\n " ]
Please provide a description of the function:def get_font_options(self): font_options = FontOptions() cairo.cairo_surface_get_font_options( self._pointer, font_options._pointer) return font_options
[ "Retrieves the default font rendering options for the surface.\n\n This allows display surfaces to report the correct subpixel order\n for rendering on them,\n print surfaces to disable hinting of metrics and so forth.\n The result can then be used with :class:`ScaledFont`.\n\n :r...
Please provide a description of the function:def set_device_scale(self, x_scale, y_scale): cairo.cairo_surface_set_device_scale(self._pointer, x_scale, y_scale) self._check_status()
[ "Sets a scale that is multiplied to the device coordinates determined\n by the CTM when drawing to surface.\n\n One common use for this is to render to very high resolution display\n devices at a scale factor, so that code that assumes 1 pixel will be a\n certain size will still work. S...
Please provide a description of the function:def get_device_scale(self): size = ffi.new('double[2]') cairo.cairo_surface_get_device_scale(self._pointer, size + 0, size + 1) return tuple(size)
[ "Returns the previous device offset set by :meth:`set_device_scale`.\n\n *New in cairo 1.14.*\n\n *New in cairocffi 0.9.*\n\n " ]
Please provide a description of the function:def set_mime_data(self, mime_type, data): mime_type = ffi.new('char[]', mime_type.encode('utf8')) if data is None: _check_status(cairo.cairo_surface_set_mime_data( self._pointer, mime_type, ffi.NULL, 0, ffi.NULL, ffi.NULL)...
[ "\n Attach an image in the format :obj:`mime_type` to this surface.\n\n To remove the data from a surface,\n call this method with same mime type and :obj:`None` for data.\n\n The attached image (or filename) data can later\n be used by backends which support it\n (currentl...
Please provide a description of the function:def get_mime_data(self, mime_type): buffer_address = ffi.new('unsigned char **') buffer_length = ffi.new('unsigned long *') mime_type = ffi.new('char[]', mime_type.encode('utf8')) cairo.cairo_surface_get_mime_data( self._p...
[ "Return mime data previously attached to surface\n using the specified mime type.\n\n :param mime_type: The MIME type of the image data.\n :type mime_type: ASCII string\n :returns:\n A CFFI buffer object, or :obj:`None`\n if no data has been attached with the given ...
Please provide a description of the function:def supports_mime_type(self, mime_type): mime_type = ffi.new('char[]', mime_type.encode('utf8')) return bool(cairo.cairo_surface_supports_mime_type( self._pointer, mime_type))
[ " Return whether surface supports :obj:`mime_type`.\n\n :param mime_type: The MIME type of the image data.\n :type mime_type: ASCII string\n\n *New in cairo 1.12.*\n\n " ]
Please provide a description of the function:def mark_dirty_rectangle(self, x, y, width, height): cairo.cairo_surface_mark_dirty_rectangle( self._pointer, x, y, width, height) self._check_status()
[ "\n Like :meth:`mark_dirty`,\n but drawing has been done only to the specified rectangle,\n so that cairo can retain cached contents\n for other parts of the surface.\n\n Any cached clip set on the surface will be reset by this method,\n to make sure that future cairo calls...
Please provide a description of the function:def write_to_png(self, target=None): return_bytes = target is None if return_bytes: target = io.BytesIO() if hasattr(target, 'write'): write_func = _make_write_func(target) _check_status(cairo.cairo_surface...
[ "Writes the contents of surface as a PNG image.\n\n :param target:\n A filename,\n a binary mode file-like object with a :meth:`~file.write` method,\n or :obj:`None`.\n :returns:\n If :obj:`target` is :obj:`None`,\n return the PNG contents as a by...
Please provide a description of the function:def create_for_data(cls, data, format, width, height, stride=None): return cls(format, width, height, data, stride)
[ "Same as ``ImageSurface(format, width, height, data, stride)``.\n Exists for compatibility with pycairo.\n\n " ]
Please provide a description of the function:def create_from_png(cls, source): if hasattr(source, 'read'): read_func = _make_read_func(source) pointer = cairo.cairo_image_surface_create_from_png_stream( read_func, ffi.NULL) else: pointer = cai...
[ "Decode a PNG file into a new image surface.\n\n :param source:\n A filename or\n a binary mode file-like object with a :meth:`~file.read` method.\n If you already have a byte string in memory,\n use :class:`io.BytesIO`.\n :returns: A new :class:`ImageSurfac...
Please provide a description of the function:def get_data(self): return ffi.buffer( cairo.cairo_image_surface_get_data(self._pointer), self.get_stride() * self.get_height())
[ "Return the buffer pointing to the image’s pixel data,\n encoded according to the surface’s :ref:`FORMAT` string.\n\n A call to :meth:`flush` is required before accessing the pixel data\n to ensure that all pending drawing operations are finished.\n A call to :meth:`~Surface.mark_dirty` ...
Please provide a description of the function:def set_size(self, width_in_points, height_in_points): cairo.cairo_pdf_surface_set_size( self._pointer, width_in_points, height_in_points) self._check_status()
[ "Changes the size of a PDF surface\n for the current (and subsequent) pages.\n\n This method should only be called\n before any drawing operations have been performed on the current page.\n The simplest way to do this is to call this method\n immediately after creating the surface...
Please provide a description of the function:def add_outline(self, parent_id, utf8, link_attribs, flags=None): if flags is None: flags = 0 value = cairo.cairo_pdf_surface_add_outline( self._pointer, parent_id, _encode_string(utf8), _encode_string(link_attribs...
[ "Add an item to the document outline hierarchy.\n\n The outline has the ``utf8`` name and links to the location specified\n by ``link_attribs``. Link attributes have the same keys and values as\n the Link Tag, excluding the ``rect`` attribute. The item will be a\n child of the item with ...
Please provide a description of the function:def set_metadata(self, metadata, utf8): cairo.cairo_pdf_surface_set_metadata( self._pointer, metadata, _encode_string(utf8)) self._check_status()
[ "Sets document metadata.\n\n The ``PDF_METADATA_CREATE_DATE`` and ``PDF_METADATA_MOD_DATE``\n values must be in ISO-8601 format: YYYY-MM-DDThh:mm:ss. An optional\n timezone of the form \"[+/-]hh:mm\" or \"Z\" for UTC time can be appended.\n All other metadata values can be any UTF-8 stri...
Please provide a description of the function:def set_thumbnail_size(self, width, height): cairo.cairo_pdf_surface_set_thumbnail_size( self._pointer, width, height)
[ "Set thumbnail image size for the current and all subsequent pages.\n\n Setting a width or height of 0 disables thumbnails for the current and\n subsequent pages.\n\n :param width: thumbnail width.\n :param height: thumbnail height.\n\n *New in cairo 1.16.*\n\n *New in cair...
Please provide a description of the function:def restrict_to_version(self, version): cairo.cairo_pdf_surface_restrict_to_version(self._pointer, version) self._check_status()
[ "Restricts the generated PDF file to :obj:`version`.\n\n See :meth:`get_versions` for a list of available version values\n that can be used here.\n\n This method should only be called\n before any drawing operations have been performed on the given surface.\n The simplest way to d...
Please provide a description of the function:def get_versions(): versions = ffi.new('cairo_pdf_version_t const **') num_versions = ffi.new('int *') cairo.cairo_pdf_get_versions(versions, num_versions) versions = versions[0] return [versions[i] for i in range(num_versions...
[ "Return the list of supported PDF versions.\n See :meth:`restrict_to_version`.\n\n :return: A list of :ref:`PDF_VERSION` strings.\n\n *New in cairo 1.10.*\n\n " ]
Please provide a description of the function:def dsc_comment(self, comment): cairo.cairo_ps_surface_dsc_comment( self._pointer, _encode_string(comment)) self._check_status()
[ " Emit a comment into the PostScript output for the given surface.\n\n The comment is expected to conform to\n the PostScript Language Document Structuring Conventions (DSC).\n Please see that manual for details on the available comments\n and their meanings.\n In particular, the ...
Please provide a description of the function:def set_eps(self, eps): cairo.cairo_ps_surface_set_eps(self._pointer, bool(eps)) self._check_status()
[ "\n If :obj:`eps` is True,\n the PostScript surface will output Encapsulated PostScript.\n\n This method should only be called\n before any drawing operations have been performed on the current page.\n The simplest way to do this is to call this method\n immediately after c...
Please provide a description of the function:def set_size(self, width_in_points, height_in_points): cairo.cairo_ps_surface_set_size( self._pointer, width_in_points, height_in_points) self._check_status()
[ "Changes the size of a PostScript surface\n for the current (and subsequent) pages.\n\n This method should only be called\n before any drawing operations have been performed on the current page.\n The simplest way to do this is to call this method\n immediately after creating the ...
Please provide a description of the function:def restrict_to_level(self, level): cairo.cairo_ps_surface_restrict_to_level(self._pointer, level) self._check_status()
[ "Restricts the generated PostScript file to :obj:`level`.\n\n See :meth:`get_levels` for a list of available level values\n that can be used here.\n\n This method should only be called\n before any drawing operations have been performed on the given surface.\n The simplest way to ...
Please provide a description of the function:def get_levels(): levels = ffi.new('cairo_ps_level_t const **') num_levels = ffi.new('int *') cairo.cairo_ps_get_levels(levels, num_levels) levels = levels[0] return [levels[i] for i in range(num_levels[0])]
[ "Return the list of supported PostScript levels.\n See :meth:`restrict_to_level`.\n\n :return: A list of :ref:`PS_LEVEL` strings.\n\n " ]
Please provide a description of the function:def ps_level_to_string(level): c_string = cairo.cairo_ps_level_to_string(level) if c_string == ffi.NULL: raise ValueError(level) return ffi.string(c_string).decode('ascii')
[ "Return the string representation of the given :ref:`PS_LEVEL`.\n See :meth:`get_levels` for a way to get\n the list of valid level ids.\n\n " ]
Please provide a description of the function:def restrict_to_version(self, version): cairo.cairo_svg_surface_restrict_to_version(self._pointer, version) self._check_status()
[ "Restricts the generated SVG file to :obj:`version`.\n\n See :meth:`get_versions` for a list of available version values\n that can be used here.\n\n This method should only be called\n before any drawing operations have been performed on the given surface.\n The simplest way to d...
Please provide a description of the function:def set_document_unit(self, unit): cairo.cairo_svg_surface_set_document_unit(self._pointer, unit) self._check_status()
[ "Use specified unit for width and height of generated SVG file.\n\n See ``SVG_UNIT_*`` enumerated values for a list of available unit\n values that can be used here.\n\n This function can be called at any time before generating the SVG file.\n\n However to minimize the risk of ambiguitie...
Please provide a description of the function:def get_document_unit(self): unit = cairo.cairo_svg_surface_get_document_unit(self._pointer) self._check_status() return unit
[ "Get the unit of the SVG surface.\n\n If the surface passed as an argument is not a SVG surface, the function\n sets the error status to ``STATUS_SURFACE_TYPE_MISMATCH`` and\n returns :ref:`SVG_UNIT_USER`.\n\n :return: The SVG unit of the SVG surface.\n\n *New in cairo 1.16.*\n\n ...
Please provide a description of the function:def version_to_string(version): c_string = cairo.cairo_svg_version_to_string(version) if c_string == ffi.NULL: raise ValueError(version) return ffi.string(c_string).decode('ascii')
[ "Return the string representation of the given :ref:`SVG_VERSION`.\n See :meth:`get_versions` for a way to get\n the list of valid version ids.\n\n " ]
Please provide a description of the function:def get_extents(self): extents = ffi.new('cairo_rectangle_t *') if cairo.cairo_recording_surface_get_extents(self._pointer, extents): return (extents.x, extents.y, extents.width, extents.height)
[ "Return the extents of the recording-surface.\n\n :returns:\n A ``(x, y, width, height)`` tuple of floats,\n or :obj:`None` if the surface is unbounded.\n\n *New in cairo 1.12*\n\n " ]
Please provide a description of the function:def ink_extents(self): extents = ffi.new('double[4]') cairo.cairo_recording_surface_ink_extents( self._pointer, extents + 0, extents + 1, extents + 2, extents + 3) self._check_status() return tuple(extents)
[ "Measures the extents of the operations\n stored within the recording-surface.\n This is useful to compute the required size of an image surface\n (or equivalent) into which to replay the full sequence\n of drawing operations.\n\n :return: A ``(x, y, width, height)`` tuple of floa...
Please provide a description of the function:def _from_pointer(pointer, incref): if pointer == ffi.NULL: raise ValueError('Null pointer') if incref: cairo.cairo_pattern_reference(pointer) self = object.__new__(PATTERN_TYPE_TO_CLASS.get( cairo.cairo_pa...
[ "Wrap an existing :c:type:`cairo_pattern_t *` cdata pointer.\n\n :type incref: bool\n :param incref:\n Whether increase the :ref:`reference count <refcounting>` now.\n :return:\n A new instance of :class:`Pattern` or one of its sub-classes,\n depending on the pa...
Please provide a description of the function:def set_extend(self, extend): cairo.cairo_pattern_set_extend(self._pointer, extend) self._check_status()
[ "\n Sets the mode to be used for drawing outside the area of this pattern.\n See :ref:`EXTEND` for details on the semantics of each extend strategy.\n\n The default extend mode is\n :obj:`NONE <EXTEND_NONE>` for :class:`SurfacePattern`\n and :obj:`PAD <EXTEND_PAD>` for :class:`Gra...
Please provide a description of the function:def set_filter(self, filter): cairo.cairo_pattern_set_filter(self._pointer, filter) self._check_status()
[ "Sets the filter to be used for resizing when using this pattern.\n See :ref:`FILTER` for details on each filter.\n\n Note that you might want to control filtering\n even when you do not have an explicit :class:`Pattern`,\n (for example when using :meth:`Context.set_source_surface`).\n ...
Please provide a description of the function:def set_matrix(self, matrix): cairo.cairo_pattern_set_matrix(self._pointer, matrix._pointer) self._check_status()
[ "Sets the pattern’s transformation matrix to :obj:`matrix`.\n This matrix is a transformation from user space to pattern space.\n\n When a pattern is first created\n it always has the identity matrix for its transformation matrix,\n which means that pattern space is initially identical t...
Please provide a description of the function:def get_matrix(self): matrix = Matrix() cairo.cairo_pattern_get_matrix(self._pointer, matrix._pointer) self._check_status() return matrix
[ "Copies the pattern’s transformation matrix.\n\n :retuns: A new :class:`Matrix` object.\n\n " ]
Please provide a description of the function:def get_rgba(self): rgba = ffi.new('double[4]') _check_status(cairo.cairo_pattern_get_rgba( self._pointer, rgba + 0, rgba + 1, rgba + 2, rgba + 3)) return tuple(rgba)
[ "Returns the solid pattern’s color.\n\n :returns: a ``(red, green, blue, alpha)`` tuple of floats.\n\n " ]
Please provide a description of the function:def get_surface(self): surface_p = ffi.new('cairo_surface_t **') _check_status(cairo.cairo_pattern_get_surface( self._pointer, surface_p)) return Surface._from_pointer(surface_p[0], incref=True)
[ "Return this :class:`SurfacePattern`’s surface.\n\n :returns:\n An instance of :class:`Surface` or one of its sub-classes,\n a new Python object referencing the existing cairo surface.\n\n " ]
Please provide a description of the function:def add_color_stop_rgba(self, offset, red, green, blue, alpha=1): cairo.cairo_pattern_add_color_stop_rgba( self._pointer, offset, red, green, blue, alpha) self._check_status()
[ "Adds a translucent color stop to a gradient pattern.\n\n The offset specifies the location along the gradient's control vector.\n For example,\n a linear gradient's control vector is from (x0,y0) to (x1,y1)\n while a radial gradient's control vector is\n from any point on the sta...
Please provide a description of the function:def add_color_stop_rgb(self, offset, red, green, blue): cairo.cairo_pattern_add_color_stop_rgb( self._pointer, offset, red, green, blue) self._check_status()
[ "Same as :meth:`add_color_stop_rgba` with ``alpha=1``.\n Kept for compatibility with pycairo.\n\n " ]
Please provide a description of the function:def get_color_stops(self): count = ffi.new('int *') _check_status(cairo.cairo_pattern_get_color_stop_count( self._pointer, count)) stops = [] stop = ffi.new('double[5]') for i in range(count[0]): _check...
[ "Return this gradient’s color stops so far.\n\n :returns:\n A list of ``(offset, red, green, blue, alpha)`` tuples of floats.\n\n " ]
Please provide a description of the function:def get_linear_points(self): points = ffi.new('double[4]') _check_status(cairo.cairo_pattern_get_linear_points( self._pointer, points + 0, points + 1, points + 2, points + 3)) return tuple(points)
[ "Return this linear gradient’s endpoints.\n\n :returns: A ``(x0, y0, x1, y1)`` tuple of floats.\n\n " ]
Please provide a description of the function:def get_radial_circles(self): circles = ffi.new('double[6]') _check_status(cairo.cairo_pattern_get_radial_circles( self._pointer, circles + 0, circles + 1, circles + 2, circles + 3, circles + 4, circles + 5)) return t...
[ "Return this radial gradient’s endpoint circles,\n each specified as a center coordinate and a radius.\n\n :returns: A ``(cx0, cy0, radius0, cx1, cy1, radius1)`` tuple of floats.\n\n " ]
Please provide a description of the function:def _encode_string(string): if not isinstance(string, bytes): string = string.encode('utf8') return ffi.new('char[]', string)
[ "Return a byte string, encoding Unicode with UTF-8." ]
Please provide a description of the function:def _from_pointer(pointer, incref): if pointer == ffi.NULL: raise ValueError('Null pointer') if incref: cairo.cairo_font_face_reference(pointer) self = object.__new__(FONT_TYPE_TO_CLASS.get( cairo.cairo_fon...
[ "Wrap an existing :c:type:`cairo_font_face_t *` cdata pointer.\n\n :type incref: bool\n :param incref:\n Whether increase the :ref:`reference count <refcounting>` now.\n :return:\n A new instance of :class:`FontFace` or one of its sub-classes,\n depending on the...
Please provide a description of the function:def _from_pointer(pointer, incref): if pointer == ffi.NULL: raise ValueError('Null pointer') if incref: cairo.cairo_scaled_font_reference(pointer) self = object.__new__(ScaledFont) ScaledFont._init_pointer(self...
[ "Wrap an existing :c:type:`cairo_scaled_font_t *` cdata pointer.\n\n :type incref: bool\n :param incref:\n Whether increase the :ref:`reference count <refcounting>` now.\n :return: A new :class:`ScaledFont` instance.\n\n " ]
Please provide a description of the function:def get_font_options(self): font_options = FontOptions() cairo.cairo_scaled_font_get_font_options( self._pointer, font_options._pointer) return font_options
[ "Copies the scaled font’s options.\n\n :returns: A new :class:`FontOptions` object.\n\n " ]
Please provide a description of the function:def get_font_matrix(self): matrix = Matrix() cairo.cairo_scaled_font_get_font_matrix(self._pointer, matrix._pointer) self._check_status() return matrix
[ "Copies the scaled font’s font matrix.\n\n :returns: A new :class:`Matrix` object.\n\n " ]
Please provide a description of the function:def get_ctm(self): matrix = Matrix() cairo.cairo_scaled_font_get_ctm(self._pointer, matrix._pointer) self._check_status() return matrix
[ "Copies the scaled font’s font current transform matrix.\n\n Note that the translation offsets ``(x0, y0)`` of the CTM\n are ignored by :class:`ScaledFont`.\n So, the matrix this method returns always has 0 as ``x0`` and ``y0``.\n\n :returns: A new :class:`Matrix` object.\n\n " ]
Please provide a description of the function:def get_scale_matrix(self): matrix = Matrix() cairo.cairo_scaled_font_get_scale_matrix( self._pointer, matrix._pointer) self._check_status() return matrix
[ "Copies the scaled font’s scaled matrix.\n\n The scale matrix is product of the font matrix\n and the ctm associated with the scaled font,\n and hence is the matrix mapping from font space to device space.\n\n :returns: A new :class:`Matrix` object.\n\n " ]
Please provide a description of the function:def text_to_glyphs(self, x, y, text, with_clusters): glyphs = ffi.new('cairo_glyph_t **', ffi.NULL) num_glyphs = ffi.new('int *') if with_clusters: clusters = ffi.new('cairo_text_cluster_t **', ffi.NULL) num_clusters =...
[ "Converts a string of text to a list of glyphs,\n optionally with cluster mapping,\n that can be used to render later using this scaled font.\n\n The output values can be readily passed to\n :meth:`Context.show_text_glyphs`, :meth:`Context.show_glyphs`\n or related methods,\n ...
Please provide a description of the function:def copy(self): cls = type(self) other = object.__new__(cls) cls._init_pointer(other, cairo.cairo_font_options_copy(self._pointer)) return other
[ "Return a new :class:`FontOptions` with the same values." ]
Please provide a description of the function:def merge(self, other): cairo.cairo_font_options_merge(self._pointer, other._pointer) _check_status(cairo.cairo_font_options_status(self._pointer))
[ "Merges non-default options from :obj:`other`,\n replacing existing values.\n This operation can be thought of as somewhat similar\n to compositing other onto options\n with the operation of :obj:`OVER <OPERATOR_OVER>`.\n\n " ]
Please provide a description of the function:def set_antialias(self, antialias): cairo.cairo_font_options_set_antialias(self._pointer, antialias) self._check_status()
[ "Changes the :ref:`ANTIALIAS` for the font options object.\n This specifies the type of antialiasing to do when rendering text.\n\n " ]
Please provide a description of the function:def set_subpixel_order(self, subpixel_order): cairo.cairo_font_options_set_subpixel_order( self._pointer, subpixel_order) self._check_status()
[ "Changes the :ref:`SUBPIXEL_ORDER` for the font options object.\n The subpixel order specifies the order of color elements\n within each pixel on the display device\n when rendering with an antialiasing mode of\n :obj:`SUBPIXEL <ANTIALIAS_SUBPIXEL>`.\n\n " ]
Please provide a description of the function:def set_hint_style(self, hint_style): cairo.cairo_font_options_set_hint_style(self._pointer, hint_style) self._check_status()
[ "Changes the :ref:`HINT_STYLE` for the font options object.\n This controls whether to fit font outlines to the pixel grid,\n and if so, whether to optimize for fidelity or contrast.\n\n " ]
Please provide a description of the function:def set_hint_metrics(self, hint_metrics): cairo.cairo_font_options_set_hint_metrics(self._pointer, hint_metrics) self._check_status()
[ "Changes the :ref:`HINT_METRICS` for the font options object.\n This controls whether metrics are quantized\n to integer values in device units.\n\n " ]
Please provide a description of the function:def set_variations(self, variations): if variations is None: variations = ffi.NULL else: variations = _encode_string(variations) cairo.cairo_font_options_set_variations(self._pointer, variations) self._check_st...
[ "Sets the OpenType font variations for the font options object.\n\n Font variations are specified as a string with a format that is similar\n to the CSS font-variation-settings. The string contains a\n comma-separated list of axis assignments, which each assignment\n consists of a 4-char...
Please provide a description of the function:def get_variations(self): variations = cairo.cairo_font_options_get_variations(self._pointer) if variations != ffi.NULL: return ffi.string(variations).decode('utf8', 'replace')
[ "Gets the OpenType font variations for the font options object.\n\n See :meth:`set_variations` for details about the\n string format.\n\n :return: the font variations for the font options object. The\n returned string belongs to the ``options`` and must not be modified.\n It is va...