ComposedLine

public class ComposedLine

Represents a line of text consisting of an array of GlyphRun objects in visual order.

  • The UTF-16 range of this line in source string.

    Declaration

    Swift

    public let codeUnitRange: Range<Int>
  • The index to the first character of this line in source string.

    Declaration

    Swift

    public var startIndex: String.Index { get }
  • The index after the last character of this line in source string.

    Declaration

    Swift

    public var endIndex: String.Index { get }
  • The paragraph level of this line.

    Declaration

    Swift

    public let paragraphLevel: UInt8
  • The origin of this line in parent frame.

    Declaration

    Swift

    public internal(set) var origin: CGPoint { get }
  • The ascent of this line which is the maximum ascent from the baseline of all runs.

    Declaration

    Swift

    public internal(set) var ascent: CGFloat { get }
  • The descent of this line which is the maximum descent from the baseline of all runs.

    Declaration

    Swift

    public internal(set) var descent: CGFloat { get }
  • The leading of this line which is the maximum leading of all runs.

    Declaration

    Swift

    public internal(set) var leading: CGFloat { get }
  • The typographic width of this line.

    Declaration

    Swift

    public var width: CGFloat { get }
  • The typographic height of this line.

    Declaration

    Swift

    public var height: CGFloat { get }
  • The typographic extent corresponding to the trailing whitespace characters in this line.

    Declaration

    Swift

    public let trailingWhitespaceExtent: CGFloat
  • The glyph runs of this line in visual order.

    Declaration

    Swift

    public let visualRuns: [GlyphRun]
  • Determines the distance of the specified UTF-16 code unit from the start of the line assumed at zero.

    Declaration

    Swift

    public func distance(forCodeUnitAt index: Int) -> CGFloat

    Parameters

    index

    The index of the UTF-16 code unit in source string.

    Return Value

    The distance of the specified UTF-16 code unit from the start of the line assumed at zero.

  • Determines the distance of the specified character from the start of the line assumed at zero.

    Declaration

    Swift

    public func distance(forCharacterAt index: String.Index) -> CGFloat

    Parameters

    index

    The index of character in source string.

    Return Value

    The distance of specified character from the start of the line assumed at zero.

  • Returns an array of visual edges corresponding to the specified range of UTF-16 code units.

    The resulting array will contain pairs of leading and trailing edges sorted from left to right. There will be a separate pair for each glyph run occurred in the specified code unit range. Each edge will be positioned relative to the start of the line assumed at zero.

    Declaration

    Swift

    public func visualEdges(forCodeUnitRange codeUnitRange: Range<Int>) -> [CGFloat]

    Parameters

    codeUnitRange

    The range of UTF-16 code units in source string.

    Return Value

    An array of visual edges corresponding to the specified UTF-16 code unit range.

  • Returns an array of visual edges corresponding to the specified character range.

    The resulting array will contain pairs of leading and trailing edges sorted from left to right. There will be a separate pair for each glyph run occurred in the specified character range. Each edge will be positioned relative to the start of the line assumed at zero.

    Declaration

    Swift

    public func visualEdges(forCharacterRange characterRange: Range<String.Index>) -> [CGFloat]

    Parameters

    characterRange

    The range of characters in source string.

    Return Value

    An array of visual edges corresponding to the specified character range.

  • Returns the index of UTF-16 code unit nearest to the specified distance.

    Declaration

    Swift

    public func indexOfCodeUnit(at distance: CGFloat) -> Int

    Parameters

    distance

    The distance for which to determine the UTF-16 code unit index. It should be offset from zero origin.

    Return Value

    The index of UTF-16 code unit in source string, nearest to the specified distance.

  • Returns the index of character nearest to the specified distance.

    Declaration

    Swift

    public func indexOfCharacter(at distance: CGFloat) -> String.Index

    Parameters

    distance

    The distance for which to determine the character index. It should be offset from zero origin.

    Return Value

    The index of character in source string, nearest to the specified distance.

  • Returns the pen offset required to draw flush text.

    Declaration

    Swift

    public func penOffset(forFlushFactor flushFactor: CGFloat, flushExtent: CGFloat) -> CGFloat

    Parameters

    flushFactor

    Specifies the kind of flushness. A flush factor of 0 or less indicates left flush. A flushFactor of 1.0 or more indicates right flush. Flush factors between 0 and 1.0 indicate varying degrees of center flush, with a value of 0.5 being totally center flush.

    flushExtent

    Specifies the extent that the flushness operation should apply to.

    Return Value

    A value which can be used to offset the current pen position for the flush operation.

  • Draws this line in the context with the specified renderer.

    Declaration

    Swift

    public func draw(with renderer: Renderer, in context: CGContext)

    Parameters

    renderer

    The renderer with which to draw the line.

    context

    The context in which to draw the line.