manpagez: man pages & more
html files: pygtk
Home | html | info | man
pangocairo.CairoContext — object providing support for using Cairo (new in PyGTK 2.8)

Synopsis

class pangocairo.CairoContext(cairo.Context):
    pangocairo.CairoContext(cr)
def update_context(context)
def create_layout()
def update_layout(layout)
def show_glyph_string(font, glyphs)
def show_layout_line(line)
def show_layout(layout)
def glyph_string_path(font, glyphs)
def layout_line_path(line)
def layout_path(layout)

Ancestry

+-- cairo.Context
  +-- pangocairo.CairoContext

Description

Cairo is a graphics library that supports vector graphics and image compositing that can be used with PyGTK. Since 2.8, GTK+ and Pango do most of their drawing using Cairo. The Cairo drawing model and primitives are similar to PostScript which uses an imaging model of painting on a two dimensional surface. There is a Python module that wraps the Cairo API that is used by PyGTK via subclassing of the cairo.Context class by the pangocairo.CairoContext class. The cairo.Context class provides most of the drawing primitives used for drawing on Cairo surfaces.

PyGTK (and GTK+ and GDK) does not wrap the Cairo API, instead gtk.gdk.CairoContext objects can be used to draw on gtk.gdk.Drawable objects. A gtk.gdk.CairoContext is created using the gtk.gdk.Drawable.cairo_create() method. See the gtk.gdk.CairoContext and Python cairo module documentation for additional methods.

Constructor

    pangocairo.CairoContext(cr)

cr :

a cairo.Context

Returns :

a new pangocairo.CairoContext.

Creates a new pangocairo.CairoContext

Methods

pangocairo.CairoContext.update_context

    def update_context(context)

context :

a pango.Context created by the pangocairo.CairoFontMap.create_context() method

Note

This method is available in PyGTK 2.8 and above.

The update_context() method updates a pango.Context previously created for use with Cairo to match the current transformation and target surface of a Cairo context. If any layouts have been created for the context, it's necessary to call the pango.Layout.context_changed() method on those layouts.

pangocairo.CairoContext.create_layout

    def create_layout()

Returns :

a new pango.Layout object.

Note

This method is available in PyGTK 2.8 and above.

The create_layout() method creates a pango.Layout object set up to match the current transformation and target surface of the Cairo context. This layout can then be used for text measurement with methods like pango.Layout.get_size() or for drawing with methods like show_layout(). If you change the transformation or target surface for the context, you need to call the update_layout() method.

This method is the most convenient way to use Cairo with Pango, however it is slightly inefficient since it creates a separate pango.Context object for each layout. This might be of concern in an application laying out large amounts of text.

pangocairo.CairoContext.update_layout

    def update_layout(layout)

layout :

a pango.Layout created by the create_layout() method

Note

This method is available in PyGTK 2.8 and above.

The update_layout() method updates the private pango.Context of the pango.Layout (specified by layout) that was created with the create_layout() method to match the current transformation and target surface of a Cairo context.

pangocairo.CairoContext.show_glyph_string

    def show_glyph_string(font, glyphs)

font :

a pango.Font

glyphs :

a pango.GlyphString

Note

This method is available in PyGTK 2.8 and above.

The show_glyph_string() method draws the pango.GlyphString specified by glyphs in the cairo context using the pango.Font specified by font. The origin of the glyphs (the left edge of the baseline) will be drawn at the current point of the cairo context.

pangocairo.CairoContext.show_layout_line

    def show_layout_line(line)

line :

a pango.LayoutLine

Note

This method is available in PyGTK 2.8 and above.

The show_layout_line() method draws the pango.LayoutLine specified by line in the cairo context. The origin of the glyphs (the left edge of the line) will be drawn at the current point of the cairo context.

pangocairo.CairoContext.show_layout

    def show_layout(layout)

layout :

a pango.Layout

Note

This method is available in PyGTK 2.8 and above.

The show_layout() method draws the pango.Layout specified by layout in the cairo context. The top-left corner of the pango.Layout will be drawn at the current point of the cairo context.

pangocairo.CairoContext.glyph_string_path

    def glyph_string_path(font, glyphs)

font :

a pango.Font

glyphs :

a pango.GlyphString

Note

This method is available in PyGTK 2.8 and above.

The glyph_string_path() method adds the pango.GlyphString specified by glyphs to the current path in the cairo context using the pango.Font specified by font. The origin of the added glyphs (the left edge of the baseline) will be at the current point of the cairo context.

pangocairo.CairoContext.layout_line_path

    def layout_line_path(line)

line :

a pango.LayoutLine

Note

This method is available in PyGTK 2.8 and above.

The layout_line_path() method adds the text in the pango.LayoutLine specified by line to the current path in the specified cairo context. The origin of the glyphs (the left edge of the line) will be at the current point of the cairo context.

pangocairo.CairoContext.layout_path

    def layout_path(layout)

layout :

a pango.Layout

Note

This method is available in PyGTK 2.8 and above.

The layout_path() method adds the text in the pango.Layout specified by layout to the current path in the specified cairo context. The top-left corner of the pango.Layout will be at the current point of the cairo context.

© manpagez.com 2000-2017
Individual documents may contain additional copyright information.