LayoutRef
public struct LayoutRef : LayoutProtocol, GWeakCapturing
A PangoLayout
structure represents an entire paragraph of text.
While complete access to the layout capabilities of Pango is provided
using the detailed interfaces for itemization and shaping, using
that functionality directly involves writing a fairly large amount
of code. PangoLayout
provides a high-level driver for formatting
entire paragraphs of text at once. This includes paragraph-level
functionality such as line breaking, justification, alignment and
ellipsization.
A PangoLayout
is initialized with a PangoContext
, UTF-8 string
and set of attributes for that string. Once that is done, the set of
formatted lines can be extracted from the object, the layout can be
rendered, and conversion between logical character positions within
the layout’s text, and the physical position of the resulting glyphs
can be made.
There are a number of parameters to adjust the formatting of a
PangoLayout
. The following image shows adjustable parameters
(on the left) and font metrics (on the right):
<picture> <source srcset=“layout-dark.png” media=“(prefers-color-scheme: dark)”> <img alt=“Pango Layout Parameters” src=“layout-light.png”> </picture>
The following images demonstrate the effect of alignment and justification on the layout of text:
It is possible, as well, to ignore the 2-D setup,
and simply treat the results of a PangoLayout
as a list of lines.
The LayoutRef
type acts as a lightweight Swift reference to an underlying PangoLayout
instance.
It exposes methods that can operate on this data type through LayoutProtocol
conformance.
Use LayoutRef
only as an unowned
reference to an existing PangoLayout
instance.
-
Untyped pointer to the underlying `PangoLayout` instance.
For type-safe access, use the generated, typed pointer
layout_ptr
property instead.Declaration
Swift
public let ptr: UnsafeMutableRawPointer!
-
Designated initialiser from the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafeMutablePointer<PangoLayout>)
-
Designated initialiser from a constant pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafePointer<PangoLayout>)
-
Conditional initialiser from an optional pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafeMutablePointer<PangoLayout>?)
-
Conditional initialiser from an optional, non-mutable pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafePointer<PangoLayout>?)
-
Conditional initialiser from an optional
gpointer
Declaration
Swift
@inlinable init!(gpointer g: gpointer?)
-
Conditional initialiser from an optional, non-mutable
gconstpointer
Declaration
Swift
@inlinable init!(gconstpointer g: gconstpointer?)
-
Reference intialiser for a related type that implements
LayoutProtocol
Declaration
Swift
@inlinable init<T>(_ other: T) where T : LayoutProtocol
-
This factory is syntactic sugar for setting weak pointers wrapped in
GWeak<T>
Declaration
Swift
@inlinable static func unowned<T>(_ other: T) -> LayoutRef where T : LayoutProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
LayoutProtocol
.Declaration
Swift
@inlinable init<T>(cPointer: UnsafeMutablePointer<T>)
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
LayoutProtocol
.Declaration
Swift
@inlinable init<T>(constPointer: UnsafePointer<T>)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
LayoutProtocol
.Declaration
Swift
@inlinable init(mutating raw: UnsafeRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
LayoutProtocol
.Declaration
Swift
@inlinable init(raw: UnsafeMutableRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
LayoutProtocol
.Declaration
Swift
@inlinable init(opaquePointer: OpaquePointer)
-
Create a new `PangoLayout` object with attributes initialized to
default values for a particular
PangoContext
.Declaration
Swift
@inlinable init<ContextT>(context: ContextT) where ContextT : ContextProtocol
-
Loads data previously created via [method
Pango.Layout.serialize
].For a discussion of the supported format, see that function.
Note: to verify that the returned layout is identical to the one that was serialized, you can compare
bytes
to the result of serializing the layout again.Declaration
Swift
@inlinable static func deserialize<ContextT, GLibBytesT>(context: ContextT, bytes: GLibBytesT, flags: LayoutDeserializeFlags) throws -> Pango.LayoutRef! where ContextT : ContextProtocol, GLibBytesT : BytesProtocol