pangocairo.CairoContext — object providing support for using Cairo (new in PyGTK 2.8)
class pangocairo.CairoContext(pangocairo.CairoContext): |
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 pangocairo.CairoContext objects can be used to draw on gtk.gdk.Drawable objects. A pangocairo.CairoContext is created using the gtk.gdk.Drawable.cairo_create() method. See the pangocairo.CairoContext and Python cairo module documentation for additional methods.
|
context : | a pango.Context created by the pangocairo.CairoFontMap.create_context() method |
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.
|
Returns : | a new pango.Layout object. |
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.
|
layout : | a pango.Layout created by the create_layout() method |
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.
|
font : | a pango.Font |
glyphs : | a pango.GlyphString |
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.
|
line : | a pango.LayoutLine |
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.
|
layout : | a pango.Layout |
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.
|
font : | a pango.Font |
glyphs : | a pango.GlyphString |
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.
|
line : | a pango.LayoutLine |
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.
|
layout : | a pango.Layout |
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.