ItemProtocol

public protocol ItemProtocol

The PangoItem structure stores information about a segment of text.

You typically obtain PangoItems by itemizing a piece of text with [funcitemize].

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

  • ptr

    Untyped pointer to the underlying PangoItem instance.

    Declaration

    Swift

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

    Typed pointer to the underlying PangoItem instance.

    Default Implementation

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

    Declaration

    Swift

    var item_ptr: UnsafeMutablePointer<PangoItem>! { get }
  • Required Initialiser for types conforming to ItemProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Item Record: ItemProtocol extension (methods and fields)

  • applyAttrs(iter:) Extension method

    Add attributes to a PangoItem.

    The idea is that you have attributes that don’t affect itemization, such as font features, so you filter them out using [methodPango.AttrList.filter], itemize your text, then reapply the attributes to the resulting items using this function.

    The iter should be positioned before the range of the item, and will be advanced past it. This function is meant to be called in a loop over the items resulting from itemization, while passing the iter to each call.

    Declaration

    Swift

    @inlinable
    func applyAttrs<AttrIteratorT>(iter: AttrIteratorT) where AttrIteratorT : AttrIteratorProtocol
  • copy() Extension method

    Copy an existing PangoItem structure.

    Declaration

    Swift

    @inlinable
    func copy() -> Pango.ItemRef!
  • free() Extension method

    Free a PangoItem and all associated memory.

    Declaration

    Swift

    @inlinable
    func free()
  • Modifies orig to cover only the text after split_index, and returns a new item that covers the text before split_index that used to be in orig.

    You can think of split_index as the length of the returned item. split_index may not be 0, and it may not be greater than or equal to the length of orig (that is, there must be at least one byte assigned to each item, you can’t create a zero-length item). split_offset is the length of the first item in chars, and must be provided because the text used to generate the item isn’t available, so pango_item_split() can’t count the char length of the split items itself.

    Declaration

    Swift

    @inlinable
    func split(splitIndex: Int, splitOffset: Int) -> Pango.ItemRef!
  • 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 shapeItem<GlyphStringT>(paragraphText: UnsafePointer<CChar>? = nil, paragraphLength: Int, logAttrs: LogAttrRef? = nil, glyphs: GlyphStringT, flags: ShapeFlags) where GlyphStringT : GlyphStringProtocol
  • 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 shapeItem<GlyphStringT, LogAttrT>(paragraphText: UnsafePointer<CChar>? = nil, paragraphLength: Int, logAttrs: LogAttrT?, glyphs: GlyphStringT, flags: ShapeFlags) where GlyphStringT : GlyphStringProtocol, LogAttrT : LogAttrProtocol
  • offset Extension method

    byte offset of the start of this item in text.

    Declaration

    Swift

    @inlinable
    var offset: gint { get set }
  • length Extension method

    length of this item in bytes.

    Declaration

    Swift

    @inlinable
    var length: gint { get set }
  • numChars Extension method

    number of Unicode characters in the item.

    Declaration

    Swift

    @inlinable
    var numChars: gint { get set }
  • analysis Extension method

    analysis results for the item.

    Declaration

    Swift

    @inlinable
    var analysis: PangoAnalysis { get set }