pango.Renderer — a base class for pango rendering (new in PyGTK 2.8)
class pango.Renderer( |
pango.Renderer
is a base class that contains the necessary logic for rendering a pango.Layout
or
pango.LayoutLine
. By
subclassing pango.Renderer
and overriding operations such as draw_glyphs
()
and draw_rectangle
(),
renderers for particular font backends and destinations can be
created.
def draw_layout(layout
, x
, y
)
| a pango.Layout |
| the x position of left edge of baseline, in user space coordinates in Pango units. |
| the y position of left edge of baseline, in user space coordinates in Pango units. |
This method is available in PyGTK 2.8 and above.
The draw_layout
() method draws the
pango.Layout
s[ecified by layout
at the position specified by
x
and y
.
def draw_layout_line(line
, x
, y
)
| a pango.LayoutLine |
| the x position of left edge of baseline, in user space coordinates in Pango units. |
| the y position of left edge of baseline, in user space coordinates in Pango units. |
This method is available in PyGTK 2.8 and above.
The draw_layout_line
() method draws the
pango.LayoutLine
specified by line
at the position specified by
x
and y
.
def draw_glyphs(font
, glyphs
, x
, y
)
| a pango.Font |
| a pango.GlyphString |
| the x position of left edge of baseline, in user space coordinates in Pango units. |
| the y position of left edge of baseline, in user space coordinates in Pango units. |
This method is available in PyGTK 2.8 and above.
The draw_glyphs
() method draws the
pango.GlyphString
specified by glyphs
using the pango.Font
specified
by font
at the position specified by
x
and y
.
def draw_rectangle(part
, x
, y
, width
, height
)
| the part where the rectangle is to be rendered |
| the x position at which to draw rectangle, in user space coordinates in Pango units |
| the y position at which to draw rectangle, in user space coordinates in Pango units |
| the width of rectangle in Pango units in user space coordinates |
| the height of rectangle in Pango units in user space coordinates |
This method is available in PyGTK 2.8 and above.
The draw_rectangle
() method draws an
axis-aligned rectangle with the size specified by
width
and height
at the
position specified by x
and y
,
all in user space coordinates. The rectangle will be drawn in the rendering
part (see the Pango Render Part Constants) specified by
part
.
def draw_error_underline(x
, y
, width
, height
)
| the X coordinate of the underline, in Pango units in the user coordinate system |
| the Y coordinate of the underline, in Pango units in the user coordinate system |
| the width of the underline, in Pango units in the user coordinate system |
| the height of the underline, in Pango units in the user coordinate system |
This method is available in PyGTK 2.8 and above.
The draw_error_underline
() method draws a
squiggly line that approximately covers the rectangle specified by
x
, y
,
width
and height
in the style
of an underline used to indicate a spelling error. (The width of the
underline is rounded to an integer number of up/down segments and the
resulting rectangle is centered in the original rectangle).
def draw_trapezoid(part
, y1_
, x11
, x21
, y2
, x12
, x22
)
| where the trapezoid is to be rendered |
| the Y coordinate of the top of the trapezoid |
| the X coordinate of the left end of the top of the trapezoid |
| the X coordinate of the right end of the top of the trapezoid |
| the Y coordinate of the bottom of the trapezoid |
| the X coordinate of the left end of the bottom of the trapezoid |
| the X coordinate of the left end of the bottom of the trapezoid |
This method is available in PyGTK 2.8 and above.
The draw_trapezoid
() method draws a
trapezoid with the parallel sides aligned with the X axis using the
coordinates specified by y1_
,
x11
, x21
,
y2
, x12
,
x22
. The coordinates are in device space. The
trapezoid is rendered in the part specified by part
which must be one of the Pango Render Part Constants.
def activate()
This method is available in PyGTK 2.8 and above.
The activate
() method does initial
setup before performing the rendering operations on renderer. The deactivate
()
method should be called when drawing is complete. Calls to the draw_layout
()
method automatically activate the layout before drawing on it. Calls to the
activate
()
and deactivate
()
methods can be nested and the renderer will only be initialized and
deinitialized once.
def deactivate()
This method is available in PyGTK 2.8 and above.
The deactivate
() method cleans up after
rendering operations are completed. See the activate
()
method for more information.
def part_changed(part
)
| the part that has its rendering changed. |
This method is available in PyGTK 2.8 and above.
The part_changed
() method informs Pango
that the way that the renderering is done for the part specified by
part
has changed in a way that would prevent multiple
pieces being joined together into one drawing
call. part
must be one of the Pango Render Part Constants. For instance, if a
subclass of pango.Renderer
was to add a stipple option for drawing underlines, it needs to call:
renderer.part_changed(pango.RENDER_PART_UNDERLINE)
when the stipple changes or underlines with different stipples
might be joined together. Pango automatically calls this for changes to
colors. (See the set_color
()
method for more information).
def set_color(part
, color
)
| the part to change the color of |
| a pango.Color |
This method is available in PyGTK 2.8 and above.
The set_color
() method sets the pango.Color
specified by color
as the color for the part
specified by part
. part
must
be one of the Pango Render Part Constants.
def get_color(part
)
| a part |
Returns :, | a pango.Color or
None |
This method is available in PyGTK 2.8 and above.
The get_color
() method returns the
current rendering pango.Color
for the
part specified by part
. part
must be one of the Pango Render Part Constants. If
None
is returned, the color has not been set and should
be inherited from the environment.