RendererProtocol

public protocol RendererProtocol : ObjectProtocol

PangoRenderer is a base class for objects that can render text provided as PangoGlyphString or PangoLayout.

By subclassing PangoRenderer and overriding operations such as draw_glyphs and draw_rectangle, renderers for particular font backends and destinations can be created.

The RendererProtocol protocol exposes the methods and properties of an underlying PangoRenderer instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see Renderer. Alternatively, use RendererRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying PangoRenderer instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • renderer_ptr Default implementation

    Typed pointer to the underlying PangoRenderer instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the PangoRenderer instance.

    Declaration

    Swift

    var renderer_ptr: UnsafeMutablePointer<PangoRenderer>! { get }
  • Required Initialiser for types conforming to RendererProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Renderer Class: RendererProtocol extension (methods and fields)

  • activate() Extension method

    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.

    Declaration

    Swift

    @inlinable
    func activate()
  • deactivate() Extension method

    Cleans up after rendering operations on renderer.

    See docs for [methodPango.Renderer.activate].

    Declaration

    Swift

    @inlinable
    func deactivate()
  • 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.

    Declaration

    Swift

    @inlinable
    func drawErrorUnderline(x: Int, y: Int, width: Int, height: Int)
  • drawGlyph(font:glyph:x:y:) Extension method

    Draws a single glyph with coordinates in device space.

    Declaration

    Swift

    @inlinable
    func drawGlyph<FontT>(font: FontT, glyph: PangoGlyph, x: CDouble, y: CDouble) where FontT : FontProtocol
  • 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-&gt;item-&gt;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].

    Declaration

    Swift

    @inlinable
    func drawGlyphItem<GlyphItemT>(text: UnsafePointer<CChar>? = nil, glyphItem: GlyphItemT, x: Int, y: Int) where GlyphItemT : GlyphItemProtocol
  • drawGlyphs(font:glyphs:x:y:) Extension method

    Draws the glyphs in glyphs with the specified PangoRenderer.

    Declaration

    Swift

    @inlinable
    func drawGlyphs<FontT, GlyphStringT>(font: FontT, glyphs: GlyphStringT, x: Int, y: Int) where FontT : FontProtocol, GlyphStringT : GlyphStringProtocol
  • draw(layout:x:y:) Extension method

    Draws layout with the specified PangoRenderer.

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

    Declaration

    Swift

    @inlinable
    func draw<LayoutT>(layout: LayoutT, x: Int, y: Int) where LayoutT : LayoutProtocol
  • drawLayout(line:x:y:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func drawLayout<LayoutLineT>(line: LayoutLineT, x: Int, y: Int) where LayoutLineT : LayoutLineProtocol
  • 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.

    Declaration

    Swift

    @inlinable
    func drawRectangle(part: PangoRenderPart, x: Int, y: Int, width: Int, height: Int)
  • Draws a trapezoid with the parallel sides aligned with the X axis using the given PangoRenderer; coordinates are in device space.

    Declaration

    Swift

    @inlinable
    func drawTrapezoid(part: PangoRenderPart, y1: CDouble, x11: CDouble, x21: CDouble, y2: CDouble, x12: CDouble, x22: CDouble)
  • getAlpha(part:) Extension method

    Gets the current alpha for the specified part.

    Declaration

    Swift

    @inlinable
    func getAlpha(part: PangoRenderPart) -> guint16
  • getColor(part:) Extension method

    Gets the current rendering color for the specified part.

    Declaration

    Swift

    @inlinable
    func getColor(part: PangoRenderPart) -> Pango.ColorRef!
  • getLayout() Extension method

    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.

    Declaration

    Swift

    @inlinable
    func getLayout() -> Pango.LayoutRef!
  • getLayoutLine() Extension method

    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.

    Declaration

    Swift

    @inlinable
    func getLayoutLine() -> Pango.LayoutLineRef!
  • getMatrix() Extension method

    Gets the transformation matrix that will be applied when rendering.

    See [methodPango.Renderer.set_matrix].

    Declaration

    Swift

    @inlinable
    func getMatrix() -> Pango.MatrixRef!
  • partChanged(part:) Extension method

    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])

    Declaration

    Swift

    @inlinable
    func partChanged(part: PangoRenderPart)
  • setAlpha(part:alpha:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func setAlpha(part: PangoRenderPart, alpha: guint16)
  • setColor(part:color:) Extension method

    Sets the color for part of the rendering.

    Also see [methodPango.Renderer.set_alpha].

    Declaration

    Swift

    @inlinable
    func setColor(part: PangoRenderPart, color: ColorRef? = nil)
  • setColor(part:color:) Extension method

    Sets the color for part of the rendering.

    Also see [methodPango.Renderer.set_alpha].

    Declaration

    Swift

    @inlinable
    func setColor<ColorT>(part: PangoRenderPart, color: ColorT?) where ColorT : ColorProtocol
  • set(matrix:) Extension method

    Sets the transformation matrix that will be applied when rendering.

    Declaration

    Swift

    @inlinable
    func set(matrix: MatrixRef? = nil)
  • set(matrix:) Extension method

    Sets the transformation matrix that will be applied when rendering.

    Declaration

    Swift

    @inlinable
    func set<MatrixT>(matrix: MatrixT?) where MatrixT : MatrixProtocol
  • layout Extension method

    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.

    Declaration

    Swift

    @inlinable
    var layout: Pango.LayoutRef! { get }
  • layoutLine Extension method

    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.

    Declaration

    Swift

    @inlinable
    var layoutLine: Pango.LayoutLineRef! { get }
  • matrix Extension method

    Gets the transformation matrix that will be applied when rendering.

    See [methodPango.Renderer.set_matrix].

    Declaration

    Swift

    @inlinable
    var matrix: Pango.MatrixRef! { get nonmutating set }
  • _matrix Extension method

    the current transformation matrix for the Renderer; may be nil, which should be treated the same as the identity matrix.

    Declaration

    Swift

    @inlinable
    var _matrix: MatrixRef! { get }