GlyphStringProtocol

public protocol GlyphStringProtocol

A PangoGlyphString is used to store strings of glyphs with geometry and visual attribute information.

The storage for the glyph information is owned by the structure which simplifies memory management.

The GlyphStringProtocol protocol exposes the methods and properties of an underlying PangoGlyphString 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 GlyphString. Alternatively, use GlyphStringRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying PangoGlyphString instance.

    Declaration

    Swift

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

    Typed pointer to the underlying PangoGlyphString instance.

    Default Implementation

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

    Declaration

    Swift

    var glyph_string_ptr: UnsafeMutablePointer<PangoGlyphString>! { get }
  • Required Initialiser for types conforming to GlyphStringProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

GlyphString Record: GlyphStringProtocol extension (methods and fields)

  • copy() Extension method

    Copy a glyph string and associated storage.

    Declaration

    Swift

    @inlinable
    func copy() -> Pango.GlyphStringRef!
  • Compute the logical and ink extents of a glyph string.

    See the documentation for [methodPango.Font.get_glyph_extents] for details about the interpretation of the rectangles.

    Examples of logical (red) and ink (green) rects:

    Declaration

    Swift

    @inlinable
    func extents<FontT>(font: FontT, inkRect: RectangleRef? = nil, logicalRect: RectangleRef? = nil) where FontT : FontProtocol
  • Compute the logical and ink extents of a glyph string.

    See the documentation for [methodPango.Font.get_glyph_extents] for details about the interpretation of the rectangles.

    Examples of logical (red) and ink (green) rects:

    Declaration

    Swift

    @inlinable
    func extents<FontT, RectangleT>(font: FontT, inkRect: RectangleT?, logicalRect: RectangleT?) where FontT : FontProtocol, RectangleT : RectangleProtocol
  • Computes the extents of a sub-portion of a glyph string.

    The extents are relative to the start of the glyph string range (the origin of their coordinate system is at the start of the range, not at the start of the entire glyph string).

    Declaration

    Swift

    @inlinable
    func extentsRange<FontT>(start: Int, end: Int, font: FontT, inkRect: RectangleRef? = nil, logicalRect: RectangleRef? = nil) where FontT : FontProtocol
  • Computes the extents of a sub-portion of a glyph string.

    The extents are relative to the start of the glyph string range (the origin of their coordinate system is at the start of the range, not at the start of the entire glyph string).

    Declaration

    Swift

    @inlinable
    func extentsRange<FontT, RectangleT>(start: Int, end: Int, font: FontT, inkRect: RectangleT?, logicalRect: RectangleT?) where FontT : FontProtocol, RectangleT : RectangleProtocol
  • free() Extension method

    Free a glyph string and associated storage.

    Declaration

    Swift

    @inlinable
    func free()
  • Given a PangoGlyphString and corresponding text, determine the width corresponding to each character.

    When multiple characters compose a single cluster, the width of the entire cluster is divided equally among the characters.

    See also [methodPango.GlyphItem.get_logical_widths].

    Declaration

    Swift

    @inlinable
    func getLogicalWidths(text: UnsafePointer<CChar>!, length: Int, embeddingLevel: Int, logicalWidths: UnsafeMutablePointer<CInt>!)
  • getWidth() Extension method

    Computes the logical width of the glyph string.

    This can also be computed using [methodPango.GlyphString.extents]. However, since this only computes the width, it’s much faster. This is in fact only a convenience function that computes the sum of geometry.width for each glyph in the glyphs.

    Declaration

    Swift

    @inlinable
    func getWidth() -> Int
  • Converts from character position to x position.

    The X position is measured from the left edge of the run. Character positions are obtained using font metrics for ligatures where available, and computed by dividing up each cluster into equal portions, otherwise.

    <picture> <source srcset=“glyphstring-positions-dark.png” media=“(prefers-color-scheme: dark)”> <img alt=“Glyph positions” src=“glyphstring-positions-light.png”> </picture>

    Declaration

    Swift

    @inlinable
    func indexToX<AnalysisT>(text: UnsafePointer<CChar>!, length: Int, analysis: AnalysisT, index: Int, trailing: Bool, xPos: UnsafeMutablePointer<gint>!) where AnalysisT : AnalysisProtocol
  • Converts from character position to x position.

    This variant of [methodPango.GlyphString.index_to_x] additionally accepts a PangoLogAttr array. The grapheme boundary information in it can be used to disambiguate positioning inside some complex clusters.

    Declaration

    Swift

    @inlinable
    func indexToXFull<AnalysisT>(text: UnsafePointer<CChar>!, length: Int, analysis: AnalysisT, attrs: LogAttrRef? = nil, index: Int, trailing: Bool, xPos: UnsafeMutablePointer<gint>!) where AnalysisT : AnalysisProtocol
  • Converts from character position to x position.

    This variant of [methodPango.GlyphString.index_to_x] additionally accepts a PangoLogAttr array. The grapheme boundary information in it can be used to disambiguate positioning inside some complex clusters.

    Declaration

    Swift

    @inlinable
    func indexToXFull<AnalysisT, LogAttrT>(text: UnsafePointer<CChar>!, length: Int, analysis: AnalysisT, attrs: LogAttrT?, index: Int, trailing: Bool, xPos: UnsafeMutablePointer<gint>!) where AnalysisT : AnalysisProtocol, LogAttrT : LogAttrProtocol
  • setSize(newLen:) Extension method

    Resize a glyph string to the given length.

    Declaration

    Swift

    @inlinable
    func setSize(newLen: Int)
  • Convert from x offset to character position.

    Character positions are computed by dividing up each cluster into equal portions. In scripts where positioning within a cluster is not allowed (such as Thai), the returned value may not be a valid cursor position; the caller must combine the result with the logical attributes for the text to compute the valid cursor position.

    Declaration

    Swift

    @inlinable
    func xToIndex<AnalysisT>(text: UnsafePointer<CChar>!, length: Int, analysis: AnalysisT, xPos: Int, index: UnsafeMutablePointer<gint>!, trailing: UnsafeMutablePointer<gint>!) where AnalysisT : AnalysisProtocol
  • Convert the characters in item into glyphs.

    This is similar to [funcPango.shape_with_flags], except it takes a PangoItem instead of separate item_text and analysis arguments. It also takes log_attrs, which may be used in implementing text transforms.

    Note that the extra attributes in the analyis that is returned from [funcPango.itemize] have indices that are relative to the entire paragraph, so you do not pass the full paragraph text as paragraph_text, you need to subtract the item offset from their indices before calling [funcPango.shape_with_flags].

    Declaration

    Swift

    @inlinable
    func shape<ItemT>(item: ItemT, paragraphText: UnsafePointer<CChar>? = nil, paragraphLength: Int, logAttrs: LogAttrRef? = nil, flags: ShapeFlags) where ItemT : ItemProtocol
  • Convert the characters in item into glyphs.

    This is similar to [funcPango.shape_with_flags], except it takes a PangoItem instead of separate item_text and analysis arguments. It also takes log_attrs, which may be used in implementing text transforms.

    Note that the extra attributes in the analyis that is returned from [funcPango.itemize] have indices that are relative to the entire paragraph, so you do not pass the full paragraph text as paragraph_text, you need to subtract the item offset from their indices before calling [funcPango.shape_with_flags].

    Declaration

    Swift

    @inlinable
    func shape<ItemT, LogAttrT>(item: ItemT, paragraphText: UnsafePointer<CChar>? = nil, paragraphLength: Int, logAttrs: LogAttrT?, flags: ShapeFlags) where ItemT : ItemProtocol, LogAttrT : LogAttrProtocol
  • Convert the characters in text into glyphs.

    Given a segment of text and the corresponding PangoAnalysis structure returned from [funcPango.itemize], convert the characters into glyphs. You may also pass in only a substring of the item from [funcPango.itemize].

    This is similar to [funcPango.shape_full], except it also takes flags that can influence the shaping process.

    Note that the extra attributes in the analyis that is returned from [funcPango.itemize] have indices that are relative to the entire paragraph, so you do not pass the full paragraph text as paragraph_text, you need to subtract the item offset from their indices before calling [funcPango.shape_with_flags].

    Declaration

    Swift

    @inlinable
    func shapeWithFlags<AnalysisT>(itemText: UnsafePointer<CChar>!, itemLength: Int, paragraphText: UnsafePointer<CChar>? = nil, paragraphLength: Int, analysis: AnalysisT, flags: ShapeFlags) where AnalysisT : AnalysisProtocol
  • width Extension method

    Computes the logical width of the glyph string.

    This can also be computed using [methodPango.GlyphString.extents]. However, since this only computes the width, it’s much faster. This is in fact only a convenience function that computes the sum of geometry.width for each glyph in the glyphs.

    Declaration

    Swift

    @inlinable
    var width: Int { get }
  • numGlyphs Extension method

    number of glyphs in this glyph string

    Declaration

    Swift

    @inlinable
    var numGlyphs: gint { get set }
  • glyphs Extension method

    array of glyph information

    Declaration

    Swift

    @inlinable
    var glyphs: UnsafeMutablePointer<PangoGlyphInfo>! { get set }
  • logClusters Extension method

    logical cluster info, indexed by the byte index within the text corresponding to the glyph string

    Declaration

    Swift

    @inlinable
    var logClusters: UnsafeMutablePointer<gint>! { get set }