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.
-
Untyped pointer to the underlying
PangoRenderer
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
renderer_ptr
Default implementationTyped 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)
-
activate()
Extension methodDoes initial setup before rendering operations on
renderer
.[method
Pango.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 [method
Pango.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 methodCleans up after rendering operations on
renderer
.See docs for [method
Pango.Renderer.activate
].Declaration
Swift
@inlinable func deactivate()
-
drawErrorUnderline(x:
Extension methody: width: height: ) 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:
Extension methodglyph: x: y: ) 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
-
drawGlyphItem(text:
Extension methodglyphItem: x: y: ) Draws the glyphs in
glyph_item
with the specifiedPangoRenderer
, 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 usepango_renderer_draw_layout_line()
orpango_renderer_draw_layout()
.Note that
text
is the start of the text for layout, which is then indexed byglyph_item->item->offset
.If
text
isnil
, this simply calls [methodPango.Renderer.draw_glyphs
].The default implementation of this method simply falls back to [method
Pango.Renderer.draw_glyphs
].Declaration
Swift
@inlinable func drawGlyphItem<GlyphItemT>(text: UnsafePointer<CChar>? = nil, glyphItem: GlyphItemT, x: Int, y: Int) where GlyphItemT : GlyphItemProtocol
-
drawGlyphs(font:
Extension methodglyphs: x: y: ) Draws the glyphs in
glyphs
with the specifiedPangoRenderer
.Declaration
Swift
@inlinable func drawGlyphs<FontT, GlyphStringT>(font: FontT, glyphs: GlyphStringT, x: Int, y: Int) where FontT : FontProtocol, GlyphStringT : GlyphStringProtocol
-
draw(layout:
Extension methodx: y: ) Draws
layout
with the specifiedPangoRenderer
.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:
Extension methodx: y: ) Draws
line
with the specifiedPangoRenderer
.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
-
drawRectangle(part:
Extension methodx: y: width: height: ) 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)
-
drawTrapezoid(part:
Extension methody1: x11: x21: y2: x12: x22: ) 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 methodGets 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 methodGets 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 methodGets the transformation matrix that will be applied when rendering.
See [method
Pango.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 callpango_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
])Declaration
Swift
@inlinable func partChanged(part: PangoRenderPart)
-
setAlpha(part:
Extension methodalpha: ) 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:
Extension methodcolor: ) Sets the color for part of the rendering.
Also see [method
Pango.Renderer.set_alpha
].Declaration
Swift
@inlinable func setColor(part: PangoRenderPart, color: ColorRef? = nil)
-
setColor(part:
Extension methodcolor: ) Sets the color for part of the rendering.
Also see [method
Pango.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 methodGets 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 methodGets 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 methodGets the transformation matrix that will be applied when rendering.
See [method
Pango.Renderer.set_matrix
].Declaration
Swift
@inlinable var matrix: Pango.MatrixRef! { get nonmutating set }
-
_matrix
Extension methodthe 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 }