Pango.Renderer¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
active_count |
r |
||
matrix |
r |
the current transformation matrix for the Renderer; may be |
|
parent_instance |
r |
||
strikethrough |
r |
||
underline |
r |
Class Details¶
- class Pango.Renderer(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
PangoRenderer
is a base class for objects that can render text provided asPangoGlyphString
orPangoLayout
.By subclassing
PangoRenderer
and overriding operations such as draw_glyphs and draw_rectangle, renderers for particular font backends and destinations can be created.New in version 1.8.
- activate()[source]¶
Does initial setup before rendering operations on self.
[method`Pango`.Renderer.deactivate] should be called when done drawing. Calls such as [method`Pango`.Renderer.draw_layout] automatically activate the layout before drawing on it.
Calls to [method`Pango`.Renderer.activate] and [method`Pango`.Renderer.deactivate] can be nested and the renderer will only be initialized and deinitialized once.
New in version 1.8.
- deactivate()[source]¶
Cleans up after rendering operations on self.
See docs for [method`Pango`.Renderer.activate].
New in version 1.8.
- draw_error_underline(x, y, width, height)[source]¶
- Parameters:
x (
int
) – X coordinate of underline, in Pango units in user coordinate systemy (
int
) – Y coordinate of underline, in Pango units in user coordinate systemwidth (
int
) – width of underline, in Pango units in user coordinate systemheight (
int
) – height of underline, in Pango units in user coordinate system
Draw a squiggly line that approximately covers the given rectangle 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.
This should be called while self is already active. Use [method`Pango`.Renderer.activate] to activate a renderer.
New in version 1.8.
- draw_glyph(font, glyph, x, y)[source]¶
- Parameters:
font (
Pango.Font
) – aPangoFont
glyph (
int
) – the glyph index of a single glyphx (
float
) – X coordinate of left edge of baseline of glyphy (
float
) – Y coordinate of left edge of baseline of glyph
Draws a single glyph with coordinates in device space.
New in version 1.8.
- draw_glyph_item(text, glyph_item, x, y)[source]¶
- Parameters:
text (
str
orNone
) – the UTF-8 text that glyph_item refers toglyph_item (
Pango.GlyphItem
) – aPangoGlyphItem
x (
int
) – X position of left edge of baseline, in user space coordinates in Pango unitsy (
int
) – Y position of left edge of baseline, in user space coordinates in Pango units
Draws the glyphs in glyph_item with the specified
PangoRenderer
, embedding the text associated with the glyphs in the output if the output format supports it.This is useful for rendering text in PDF.
Note that this method does not handle attributes in glyph_item. If you want colors, shapes and lines handled automatically according to those attributes, you need to use
Pango.Renderer.draw_layout_line
() orPango.Renderer.draw_layout
().Note that text is the start of the text for layout, which is then indexed by
glyph_item->item->offset
.If text is
None
, this simply calls [method`Pango`.Renderer.draw_glyphs].The default implementation of this method simply falls back to [method`Pango`.Renderer.draw_glyphs].
New in version 1.22.
- draw_glyphs(font, glyphs, x, y)[source]¶
- Parameters:
font (
Pango.Font
) – aPangoFont
glyphs (
Pango.GlyphString
) – aPangoGlyphString
x (
int
) – X position of left edge of baseline, in user space coordinates in Pango units.y (
int
) – Y position of left edge of baseline, in user space coordinates in Pango units.
Draws the glyphs in glyphs with the specified
PangoRenderer
.New in version 1.8.
- draw_layout(layout, x, y)[source]¶
- Parameters:
layout (
Pango.Layout
) – aPangoLayout
x (
int
) – X position of left edge of baseline, in user space coordinates in Pango units.y (
int
) – Y position of left edge of baseline, in user space coordinates in Pango units.
Draws layout with the specified
PangoRenderer
.This is equivalent to drawing the lines of the layout, at their respective positions relative to x, y.
New in version 1.8.
- draw_layout_line(line, x, y)[source]¶
- Parameters:
line (
Pango.LayoutLine
) – aPangoLayoutLine
x (
int
) – X position of left edge of baseline, in user space coordinates in Pango units.y (
int
) – Y position of left edge of baseline, in user space coordinates in Pango units.
Draws line with the specified
PangoRenderer
.This draws the glyph items that make up the line, as well as shapes, backgrounds and lines that are specified by the attributes of those items.
New in version 1.8.
- draw_rectangle(part, x, y, width, height)[source]¶
- Parameters:
part (
Pango.RenderPart
) – type of object this rectangle is part ofx (
int
) – X position at which to draw rectangle, in user space coordinates in Pango unitsy (
int
) – Y position at which to draw rectangle, in user space coordinates in Pango unitswidth (
int
) – width of rectangle in Pango unitsheight (
int
) – height of rectangle in Pango units
Draws an axis-aligned rectangle in user space coordinates with the specified
PangoRenderer
.This should be called while self is already active. Use [method`Pango`.Renderer.activate] to activate a renderer.
New in version 1.8.
- draw_trapezoid(part, y1_, x11, x21, y2, x12, x22)[source]¶
- Parameters:
part (
Pango.RenderPart
) – type of object this trapezoid is part ofy1 (
float
) – Y coordinate of top of trapezoidx11 (
float
) – X coordinate of left end of top of trapezoidx21 (
float
) – X coordinate of right end of top of trapezoidy2 (
float
) – Y coordinate of bottom of trapezoidx12 (
float
) – X coordinate of left end of bottom of trapezoidx22 (
float
) – X coordinate of right end of bottom of trapezoid
Draws a trapezoid with the parallel sides aligned with the X axis using the given
PangoRenderer
; coordinates are in device space.New in version 1.8.
- get_alpha(part)[source]¶
- Parameters:
part (
Pango.RenderPart
) – the part to get the alpha for- Returns:
the alpha for the specified part, or 0 if it hasn’t been set and should be inherited from the environment.
- Return type:
Gets the current alpha for the specified part.
New in version 1.38.
- get_color(part)[source]¶
- Parameters:
part (
Pango.RenderPart
) – the part to get the color for- Returns:
the color for the specified part, or
None
if it hasn’t been set and should be inherited from the environment.- Return type:
Pango.Color
orNone
Gets the current rendering color for the specified part.
New in version 1.8.
- get_layout()[source]¶
- Returns:
the layout, or
None
if no layout is being rendered using self at this time.- Return type:
Pango.Layout
orNone
Gets the layout currently being rendered using self.
Calling this function only makes sense from inside a subclass’s methods, like in its draw_shape vfunc, for example.
The returned layout should not be modified while still being rendered.
New in version 1.20.
- get_layout_line()[source]¶
- Returns:
the layout line, or
None
if no layout line is being rendered using self at this time.- Return type:
Gets the layout line currently being rendered using self.
Calling this function only makes sense from inside a subclass’s methods, like in its draw_shape vfunc, for example.
The returned layout line should not be modified while still being rendered.
New in version 1.20.
- get_matrix()[source]¶
- Returns:
the matrix, or
None
if no matrix has been set (which is the same as the identity matrix). The returned matrix is owned by Pango and must not be modified or freed.- Return type:
Pango.Matrix
orNone
Gets the transformation matrix that will be applied when rendering.
See [method`Pango`.Renderer.set_matrix].
New in version 1.8.
- part_changed(part)[source]¶
- Parameters:
part (
Pango.RenderPart
) – the part for which rendering has changed.
Informs Pango that the way that the rendering is done for part has changed.
This should be called if the rendering changes in a way that would prevent multiple pieces being joined together into one drawing call. For instance, if a subclass of
PangoRenderer
was to add a stipple option for drawing underlines, it needs to call`` pango_renderer_part_changed (render, 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 [method`Pango`.Renderer.set_color])
New in version 1.8.
- set_alpha(part, alpha)[source]¶
- Parameters:
part (
Pango.RenderPart
) – the part to set the alpha foralpha (
int
) – an alpha value between 1 and 65536, or 0 to unset the alpha
Sets the alpha for part of the rendering.
Note that the alpha may only be used if a color is specified for part as well.
New in version 1.38.
- set_color(part, color)[source]¶
- Parameters:
part (
Pango.RenderPart
) – the part to change the color ofcolor (
Pango.Color
orNone
) – the new color orNone
to unset the current color
Sets the color for part of the rendering.
Also see [method`Pango`.Renderer.set_alpha].
New in version 1.8.
- set_matrix(matrix)[source]¶
- Parameters:
matrix (
Pango.Matrix
orNone
) – aPangoMatrix
, orNone
to unset any existing matrix (No matrix set is the same as setting the identity matrix.)
Sets the transformation matrix that will be applied when rendering.
New in version 1.8.
- do_begin() virtual¶
Do renderer-specific initialization before drawing
- do_draw_error_underline(x, y, width, height) virtual¶
- Parameters:
x (
int
) – X coordinate of underline, in Pango units in user coordinate systemy (
int
) – Y coordinate of underline, in Pango units in user coordinate systemwidth (
int
) – width of underline, in Pango units in user coordinate systemheight (
int
) – height of underline, in Pango units in user coordinate system
Draw a squiggly line that approximately covers the given rectangle 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.
This should be called while renderer is already active. Use [method`Pango`.Renderer.activate] to activate a renderer.
New in version 1.8.
- do_draw_glyph(font, glyph, x, y) virtual¶
- Parameters:
font (
Pango.Font
) – aPangoFont
glyph (
int
) – the glyph index of a single glyphx (
float
) – X coordinate of left edge of baseline of glyphy (
float
) – Y coordinate of left edge of baseline of glyph
Draws a single glyph with coordinates in device space.
New in version 1.8.
- do_draw_glyph_item(text, glyph_item, x, y) virtual¶
- Parameters:
text (
str
orNone
) – the UTF-8 text that glyph_item refers toglyph_item (
Pango.GlyphItem
) – aPangoGlyphItem
x (
int
) – X position of left edge of baseline, in user space coordinates in Pango unitsy (
int
) – Y position of left edge of baseline, in user space coordinates in Pango units
Draws the glyphs in glyph_item with the specified
PangoRenderer
, embedding the text associated with the glyphs in the output if the output format supports it.This is useful for rendering text in PDF.
Note that this method does not handle attributes in glyph_item. If you want colors, shapes and lines handled automatically according to those attributes, you need to use
Pango.Renderer.draw_layout_line
() orPango.Renderer.draw_layout
().Note that text is the start of the text for layout, which is then indexed by
glyph_item->item->offset
.If text is
None
, this simply calls [method`Pango`.Renderer.draw_glyphs].The default implementation of this method simply falls back to [method`Pango`.Renderer.draw_glyphs].
New in version 1.22.
- do_draw_glyphs(font, glyphs, x, y) virtual¶
- Parameters:
font (
Pango.Font
) – aPangoFont
glyphs (
Pango.GlyphString
) – aPangoGlyphString
x (
int
) – X position of left edge of baseline, in user space coordinates in Pango units.y (
int
) – Y position of left edge of baseline, in user space coordinates in Pango units.
Draws the glyphs in glyphs with the specified
PangoRenderer
.New in version 1.8.
- do_draw_rectangle(part, x, y, width, height) virtual¶
- Parameters:
part (
Pango.RenderPart
) – type of object this rectangle is part ofx (
int
) – X position at which to draw rectangle, in user space coordinates in Pango unitsy (
int
) – Y position at which to draw rectangle, in user space coordinates in Pango unitswidth (
int
) – width of rectangle in Pango unitsheight (
int
) – height of rectangle in Pango units
Draws an axis-aligned rectangle in user space coordinates with the specified
PangoRenderer
.This should be called while renderer is already active. Use [method`Pango`.Renderer.activate] to activate a renderer.
New in version 1.8.
- do_draw_shape(attr, x, y) virtual¶
- Parameters:
attr (
Pango.AttrShape
) –x (
int
) –y (
int
) –
draw content for a glyph shaped with
PangoAttrShape
x, y are the coordinates of the left edge of the baseline, in user coordinates.
- do_draw_trapezoid(part, y1_, x11, x21, y2, x12, x22) virtual¶
- Parameters:
part (
Pango.RenderPart
) – type of object this trapezoid is part ofy1 (
float
) – Y coordinate of top of trapezoidx11 (
float
) – X coordinate of left end of top of trapezoidx21 (
float
) – X coordinate of right end of top of trapezoidy2 (
float
) – Y coordinate of bottom of trapezoidx12 (
float
) – X coordinate of left end of bottom of trapezoidx22 (
float
) – X coordinate of right end of bottom of trapezoid
Draws a trapezoid with the parallel sides aligned with the X axis using the given
PangoRenderer
; coordinates are in device space.New in version 1.8.
- do_end() virtual¶
Do renderer-specific cleanup after drawing
- do_part_changed(part) virtual¶
- Parameters:
part (
Pango.RenderPart
) – the part for which rendering has changed.
Informs Pango that the way that the rendering is done for part has changed.
This should be called if the rendering changes in a way that would prevent multiple pieces being joined together into one drawing call. For instance, if a subclass of
PangoRenderer
was to add a stipple option for drawing underlines, it needs to call`` pango_renderer_part_changed (render, 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 [method`Pango`.Renderer.set_color])
New in version 1.8.
- do_prepare_run(run) virtual¶
- Parameters:
run (
Pango.GlyphItem
) –
updates the renderer for a new run