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.
-
Untyped pointer to the underlying
PangoItem
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
item_ptr
Default implementationTyped 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)
-
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 [method
Pango.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 methodCopy an existing
PangoItem
structure.Declaration
Swift
@inlinable func copy() -> Pango.ItemRef!
-
free()
Extension methodFree a
PangoItem
and all associated memory.Declaration
Swift
@inlinable func free()
-
split(splitIndex:
Extension methodsplitOffset: ) Modifies
orig
to cover only the text aftersplit_index
, and returns a new item that covers the text beforesplit_index
that used to be inorig
.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 oforig
(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, sopango_item_split()
can’t count the char length of the split items itself.Declaration
Swift
@inlinable func split(splitIndex: Int, splitOffset: Int) -> Pango.ItemRef!
-
shapeItem(paragraphText:
Extension methodparagraphLength: logAttrs: glyphs: flags: ) Convert the characters in
item
into glyphs.This is similar to [func
Pango.shape_with_flags
], except it takes aPangoItem
instead of separateitem_text
andanalysis
arguments. It also takeslog_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 asparagraph_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
-
shapeItem(paragraphText:
Extension methodparagraphLength: logAttrs: glyphs: flags: ) Convert the characters in
item
into glyphs.This is similar to [func
Pango.shape_with_flags
], except it takes aPangoItem
instead of separateitem_text
andanalysis
arguments. It also takeslog_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 asparagraph_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 methodbyte offset of the start of this item in text.
Declaration
Swift
@inlinable var offset: gint { get set }
-
length
Extension methodlength of this item in bytes.
Declaration
Swift
@inlinable var length: gint { get set }
-
numChars
Extension methodnumber of Unicode characters in the item.
Declaration
Swift
@inlinable var numChars: gint { get set }
-
analysis
Extension methodanalysis results for the item.
Declaration
Swift
@inlinable var analysis: PangoAnalysis { get set }