Renderer

public class Renderer

The Renderer class represents a generic glyph renderer. It can be used to generate glyph paths, measure their bounding boxes and draw them in a CGContext object.

  • Specifies if the glyph being drawn is filled, stroked, or both.

    See more

    Declaration

    Swift

    public enum RenderingStyle
  • Specifies the treatment for the beginning and ending of stroked lines and paths.

    See more

    Declaration

    Swift

    public enum StrokeCap : Int
  • Specifies the treatment where lines and curve segments join on a stroked path.

    See more

    Declaration

    Swift

    public enum StrokeJoin : Int
  • Creates a renderer.

    Declaration

    Swift

    public init()
  • The fill color for glyphs. Its default value is .black.

    Declaration

    Swift

    public var fillColor: UIColor { get set }
  • The style, used for controlling how glyphs should appear while drawing. Its default value is .fill.

    Declaration

    Swift

    public var renderingStyle: RenderingStyle
  • The direction in which the pen will advance after drawing a glyph. Its default value is .leftToRight.

    Declaration

    Swift

    public var writingDirection: WritingDirection
  • The typeface, used for drawing glyphs.

    Declaration

    Swift

    public var typeface: Typeface! { get set }
  • The type size applied on the glyphs while drawing.

    Declaration

    Swift

    public var typeSize: CGFloat { get set }
  • The slant angle for glyphs. Its default value is zero.

    Declaration

    Swift

    public var slantAngle: CGFloat { get set }
  • The scale factor applied to the glyphs and their metrics such as offsets and advances.

    Declaration

    Swift

    public var renderScale: CGFloat { get set }
  • The horizontal scale factor applied on the glyphs while drawing. Its default value is 1.0. Values greater than 1.0 will stretch the glyphs wider. Values less than 1.0 will stretch the glyphs narrower.

    Declaration

    Swift

    public var scaleX: CGFloat { get set }
  • The vertical scale factor applied on the glyphs while drawing. Its default value is 1.0. Values greater than 1.0 will stretch the glyphs wider. Values less than 1.0 will stretch the glyphs narrower.

    Declaration

    Swift

    public var scaleY: CGFloat { get set }
  • The stroke color for glyphs. Its default value is .black.

    Declaration

    Swift

    public var strokeColor: UIColor
  • The width, in pixels, for stroking glyphs.

    Declaration

    Swift

    public var strokeWidth: CGFloat { get set }
  • The stroke cap style which controls how the start and end of stroked lines and paths are treated. Its default value is .butt.

    Declaration

    Swift

    public var strokeCap: StrokeCap { get set }
  • The stroke join type. Its default value is .round.

    Declaration

    Swift

    public var strokeJoin: StrokeJoin { get set }
  • The stroke miter limit in pixels. This is used to control the behavior of miter joins when the joins angle is sharp.

    Declaration

    Swift

    public var strokeMiter: CGFloat { get set }
  • The shadow radius, in pixels, used when drawing glyphs. Its default value is zero. The shadow would be disabled if the value is set to zero.

    Declaration

    Swift

    public var shadowRadius: CGFloat
  • The horizontal shadow offset, in pixels.

    Declaration

    Swift

    public var shadowDx: CGFloat
  • The vertical shadow offset in pixels.

    Declaration

    Swift

    public var shadowDy: CGFloat
  • The shadow color.

    Declaration

    Swift

    public var shadowColor: UIColor
  • Generates the path of specified glyph.

    Declaration

    Swift

    public func makePath(glyphID: GlyphID) -> CGPath?

    Parameters

    glyphID

    The ID of glyph whose path is generated.

    Return Value

    The path of the glyph specified by glyphID.

  • Generates a cumulative path of specified glyphs.

    Declaration

    Swift

    public func makePath<GS, OS, AS>(glyphIDs: GS, offsets: OS, advances: AS) -> CGPath?
        where GS : Sequence, GS.Element == GlyphID,
              OS : Sequence, OS.Element == CGPoint,
              AS : Sequence, AS.Element == CGFloat

    Parameters

    glyphIds

    A sequence of glyph IDs.

    offsets

    A sequence of glyph offsets.

    advances

    A sequence of glyph advances.

    Return Value

    The cumulative path of specified glyphs.

  • Calculates the bounding box of specified glyph.

    Declaration

    Swift

    public func computeBoundingBox(forGlyph glyphID: GlyphID) -> CGRect

    Parameters

    glyphID

    The ID of glyph whose bounding box is calculated.

    Return Value

    A rectangle that tightly encloses the path of the specified glyph.

  • Calculates the bounding box of specified glyphs.

    Declaration

    Swift

    public func computeBoundingBox<GS, OS, AS>(forGlyphs glyphIDs: GS, offsets: OS, advances: AS) -> CGRect
        where GS: Sequence, GS.Element == GlyphID,
              OS: Sequence, OS.Element == CGPoint,
              AS: Sequence, AS.Element == CGFloat

    Parameters

    glyphIDs

    A sequence of glyph IDs.

    offsets

    A sequence of glyph offsets.

    advances

    A sequence of glyph advances.

    Return Value

    A rectangle that tightly encloses the paths of specified glyphs.

  • Draws the glyphs in the specified context.

    Declaration

    Swift

    public func drawGlyphs<GS, OS, AS>(in context: CGContext, glyphIDs: GS, offsets: OS, advances: AS)
        where GS: Sequence, GS.Element == GlyphID,
              OS: Sequence, OS.Element == CGPoint,
              AS: Sequence, AS.Element == CGFloat

    Parameters

    context

    The context onto which to draw the glyphs.

    glyphIDs

    A sequence of glyph IDs.

    offsets

    A sequence of glyph offsets.

    advances

    A sequence of glyph advances.