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.
-
Untyped pointer to the underlying
PangoGlyphString
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
glyph_string_ptr
Default implementationTyped 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)
-
copy()
Extension methodCopy a glyph string and associated storage.
Declaration
Swift
@inlinable func copy() -> Pango.GlyphStringRef!
-
extents(font:
Extension methodinkRect: logicalRect: ) Compute the logical and ink extents of a glyph string.
See the documentation for [method
Pango.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
-
extents(font:
Extension methodinkRect: logicalRect: ) Compute the logical and ink extents of a glyph string.
See the documentation for [method
Pango.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
-
extentsRange(start:
Extension methodend: font: inkRect: logicalRect: ) 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
-
extentsRange(start:
Extension methodend: font: inkRect: logicalRect: ) 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 methodFree a glyph string and associated storage.
Declaration
Swift
@inlinable func free()
-
getLogicalWidths(text:
Extension methodlength: embeddingLevel: logicalWidths: ) 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 [method
Pango.GlyphItem.get_logical_widths
].Declaration
Swift
@inlinable func getLogicalWidths(text: UnsafePointer<CChar>!, length: Int, embeddingLevel: Int, logicalWidths: UnsafeMutablePointer<CInt>!)
-
getWidth()
Extension methodComputes the logical width of the glyph string.
This can also be computed using [method
Pango.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 ofgeometry.width
for each glyph in theglyphs
.Declaration
Swift
@inlinable func getWidth() -> Int
-
indexToX(text:
Extension methodlength: analysis: index: trailing: xPos: ) 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
-
indexToXFull(text:
Extension methodlength: analysis: attrs: index: trailing: xPos: ) Converts from character position to x position.
This variant of [method
Pango.GlyphString.index_to_x
] additionally accepts aPangoLogAttr
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
-
indexToXFull(text:
Extension methodlength: analysis: attrs: index: trailing: xPos: ) Converts from character position to x position.
This variant of [method
Pango.GlyphString.index_to_x
] additionally accepts aPangoLogAttr
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)
-
xToIndex(text:
Extension methodlength: analysis: xPos: index: trailing: ) 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
-
shape(item:
Extension methodparagraphText: paragraphLength: logAttrs: 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 shape<ItemT>(item: ItemT, paragraphText: UnsafePointer<CChar>? = nil, paragraphLength: Int, logAttrs: LogAttrRef? = nil, flags: ShapeFlags) where ItemT : ItemProtocol
-
shape(item:
Extension methodparagraphText: paragraphLength: logAttrs: 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 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 [func
Pango.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 asparagraph_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 methodComputes the logical width of the glyph string.
This can also be computed using [method
Pango.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 ofgeometry.width
for each glyph in theglyphs
.Declaration
Swift
@inlinable var width: Int { get }
-
numGlyphs
Extension methodnumber of glyphs in this glyph string
Declaration
Swift
@inlinable var numGlyphs: gint { get set }
-
glyphs
Extension methodarray of glyph information
Declaration
Swift
@inlinable var glyphs: UnsafeMutablePointer<PangoGlyphInfo>! { get set }
-
logClusters
Extension methodlogical cluster info, indexed by the byte index within the text corresponding to the glyph string
Declaration
Swift
@inlinable var logClusters: UnsafeMutablePointer<gint>! { get set }