Class: Pango::Renderer

Inherits:
Object
  • Object
show all
Extended by:
GLib::Deprecatable
Defined in:
lib/pango/deprecated.rb

Overview

Class structure for PangoRenderer.

The following vfuncs take user space coordinates in Pango units and have default implementations:

  • draw_glyphs
  • draw_rectangle
  • draw_error_underline
  • draw_shape
  • draw_glyph_item

The default draw_shape implementation draws nothing.

The following vfuncs take device space coordinates as doubles and must be implemented:

  • draw_trapezoid
  • draw_glyph

Instance Method Summary collapse

Instance Method Details

#activatenil

Does initial setup before rendering operations on renderer.

[methodPango.Renderer.deactivate] should be called when done drawing. Calls such as [methodPango.Renderer.draw_layout] automatically activate the layout before drawing on it.

Calls to [methodPango.Renderer.activate] and [methodPango.Renderer.deactivate] can be nested and the renderer will only be initialized and deinitialized once.

Returns:

  • (nil)

#deactivatenil

Cleans up after rendering operations on renderer.

See docs for [methodPango.Renderer.activate].

Returns:

  • (nil)

#draw_error_underline(x, y, width, height) ⇒ nil

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 [methodPango.Renderer.activate] to activate a renderer.

Parameters:

  • x (Integer)

    X coordinate of underline, in Pango units in user coordinate system

  • y (Integer)

    Y coordinate of underline, in Pango units in user coordinate system

  • width (Integer)

    width of underline, in Pango units in user coordinate system

  • height (Integer)

    height of underline, in Pango units in user coordinate system

Returns:

  • (nil)

#draw_glyph(font, glyph, x, y) ⇒ nil

Draws a single glyph with coordinates in device space.

Parameters:

  • font (Pango::Font)

    a PangoFont

  • glyph (Pango::Glyph)

    the glyph index of a single glyph

  • x (Float)

    X coordinate of left edge of baseline of glyph

  • y (Float)

    Y coordinate of left edge of baseline of glyph

Returns:

  • (nil)

#draw_glyph_item(text, glyph_item, x, y) ⇒ nil

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() or pango_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 nil, this simply calls [methodPango.Renderer.draw_glyphs].

The default implementation of this method simply falls back to [methodPango.Renderer.draw_glyphs].

Parameters:

  • text (String)

    the UTF-8 text that glyph_item refers to

  • glyph_item (Pango::GlyphItem)

    a PangoGlyphItem

  • x (Integer)

    X position of left edge of baseline, in user space coordinates in Pango units

  • y (Integer)

    Y position of left edge of baseline, in user space coordinates in Pango units

Returns:

  • (nil)

#draw_glyphs(font, glyphs, x, y) ⇒ nil

Draws the glyphs in glyphs with the specified PangoRenderer.

Parameters:

  • font (Pango::Font)

    a PangoFont

  • glyphs (Pango::GlyphString)

    a PangoGlyphString

  • x (Integer)

    X position of left edge of baseline, in user space coordinates in Pango units.

  • y (Integer)

    Y position of left edge of baseline, in user space coordinates in Pango units.

Returns:

  • (nil)

#draw_layout(layout, x, y) ⇒ nil

Draws layout with the specified PangoRenderer.

This is equivalent to drawing the lines of the layout, at their respective positions relative to x, y.

Parameters:

  • layout (Pango::Layout)

    a PangoLayout

  • x (Integer)

    X position of left edge of baseline, in user space coordinates in Pango units.

  • y (Integer)

    Y position of left edge of baseline, in user space coordinates in Pango units.

Returns:

  • (nil)

#draw_layout_line(line, x, y) ⇒ nil

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.

Parameters:

  • line (Pango::LayoutLine)

    a PangoLayoutLine

  • x (Integer)

    X position of left edge of baseline, in user space coordinates in Pango units.

  • y (Integer)

    Y position of left edge of baseline, in user space coordinates in Pango units.

Returns:

  • (nil)

#draw_rectangle(part, x, y, width, height) ⇒ nil

Draws an axis-aligned rectangle in user space coordinates with the specified PangoRenderer.

This should be called while renderer is already active. Use [methodPango.Renderer.activate] to activate a renderer.

Parameters:

  • part (Pango::RenderPart)

    type of object this rectangle is part of

  • x (Integer)

    X position at which to draw rectangle, in user space coordinates in Pango units

  • y (Integer)

    Y position at which to draw rectangle, in user space coordinates in Pango units

  • width (Integer)

    width of rectangle in Pango units

  • height (Integer)

    height of rectangle in Pango units

Returns:

  • (nil)

#draw_trapezoid(part, y1_, x11, x21, y2, x12, x22) ⇒ nil

Draws a trapezoid with the parallel sides aligned with the X axis using the given PangoRenderer; coordinates are in device space.

Parameters:

  • part (Pango::RenderPart)

    type of object this trapezoid is part of

  • y1_ (Float)

    Y coordinate of top of trapezoid

  • x11 (Float)

    X coordinate of left end of top of trapezoid

  • x21 (Float)

    X coordinate of right end of top of trapezoid

  • y2 (Float)

    Y coordinate of bottom of trapezoid

  • x12 (Float)

    X coordinate of left end of bottom of trapezoid

  • x22 (Float)

    X coordinate of right end of bottom of trapezoid

Returns:

  • (nil)

#get_alpha(part) ⇒ Integer

Gets the current alpha for the specified part.

Parameters:

Returns:

  • (Integer)

    the alpha for the specified part, or 0 if it hasn't been set and should be inherited from the environment.

#get_color(part) ⇒ Pango::Color

Gets the current rendering color for the specified part.

Parameters:

Returns:

  • (Pango::Color)

    the color for the specified part, or nil if it hasn't been set and should be inherited from the environment.

#layoutPango::Layout

Gets the layout currently being rendered using renderer.

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.

Returns:

  • (Pango::Layout)

    the layout, or nil if no layout is being rendered using renderer at this time.

#layout_linePango::LayoutLine

Gets the layout line currently being rendered using renderer.

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.

Returns:

  • (Pango::LayoutLine)

    the layout line, or nil if no layout line is being rendered using renderer at this time.

#matrixPango::Matrix

Gets the transformation matrix that will be applied when rendering.

See [methodPango.Renderer.set_matrix].

Returns:

  • (Pango::Matrix)

    the matrix, or nil 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.

#matrix=(matrix) ⇒ nil

Sets the transformation matrix that will be applied when rendering.

Parameters:

  • matrix (Pango::Matrix)

    a PangoMatrix, or nil to unset any existing matrix (No matrix set is the same as setting the identity matrix.)

Returns:

  • (nil)

#part_changed(part) ⇒ nil

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 [methodPango.Renderer.set_color])

Parameters:

Returns:

  • (nil)

#set_alpha(part, alpha) ⇒ nil

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.

Parameters:

  • part (Pango::RenderPart)

    the part to set the alpha for

  • alpha (Integer)

    an alpha value between 1 and 65536, or 0 to unset the alpha

Returns:

  • (nil)

#set_color(part, color) ⇒ nil

Sets the color for part of the rendering.

Also see [methodPango.Renderer.set_alpha].

Parameters:

Returns:

  • (nil)