pangocairo.CairoContextobject providing support for using Cairo (new in
PyGTK 2.8)Synopsispangocairo.CairoContextcairo.Contextpangocairo.CairoContextcrupdate_contextcontextcreate_layoutupdate_layoutlayoutshow_glyph_stringfontglyphsshow_layout_linelineshow_layoutlayoutglyph_string_pathfontglyphslayout_line_pathlinelayout_pathlayoutAncestry+-- cairo.Context
+-- pangocairo.CairoContext
DescriptionCairo 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.Constructorpangocairo.CairoContextcrcr :a cairo.ContextReturns :a new pangocairo.CairoContext.Creates a new pangocairo.CairoContextMethodspangocairo.CairoContext.update_contextupdate_contextcontextcontext :a pango.Context
created by the pangocairo.CairoFontMap.create_context()
methodThis 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_layoutcreate_layoutReturns :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.pangocairo.CairoContext.update_layoutupdate_layoutlayoutlayout :a pango.Layout
created by the create_layout()
methodThis 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_stringshow_glyph_stringfontglyphsfont :a pango.Fontglyphs :a pango.GlyphStringThis 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_lineshow_layout_linelineline :a pango.LayoutLineThis 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_layoutshow_layoutlayoutlayout :a pango.LayoutThis 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_pathglyph_string_pathfontglyphsfont :a pango.Fontglyphs :a pango.GlyphStringThis 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_pathlayout_line_pathlineline :a pango.LayoutLineThis 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_pathlayout_pathlayoutlayout :a pango.LayoutThis 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.