Layout

open class Layout(pointer: <Error class: unknown class><<Error class: unknown class>>)

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):

Pango Layout Parameters

The following images demonstrate the effect of alignment and justification on the layout of text:

align=leftalign=left, justify
align=centeralign=center, justify
align=rightalign=right, justify

It is possible, as well, to ignore the 2-D setup, and simply treat the results of a PangoLayout as a list of lines.

Skipped during bindings generation

  • method get_context: C function pango_layout_get_context is ignored

  • parameter attrs: attrs: Out parameter is not supported

  • parameter n_attrs: n_attrs: Out parameter is not supported

  • parameter width: width: Out parameter is not supported

  • parameter width: width: Out parameter is not supported

  • parameter line: line: Out parameter is not supported

  • parameter new_index: new_index: Out parameter is not supported

  • parameter accel_char: accel_char: Out parameter is not supported

  • parameter index_: index_: Out parameter is not supported

  • parameter context: C Type PangoContext is ignored

  • parameter context: C Type PangoContext is ignored

Constructors

Link copied to clipboard
constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val pangoLayoutPointer: <Error class: unknown class><<Error class: unknown class>>

Functions

Link copied to clipboard
open fun contextChanged()

Forces recomputation of any state in the PangoLayout that might depend on the layout's context.

Link copied to clipboard
open fun copy(): Layout

Creates a deep copy-by-value of the layout.

Link copied to clipboard

Gets the alignment for the layout: how partial lines are positioned within the horizontal space available.

Link copied to clipboard
open fun getAttributes(): AttrList?

Gets the attribute list for the layout, if any.

Link copied to clipboard
open fun getAutoDir(): Boolean

Gets whether to calculate the base direction for the layout according to its contents.

Link copied to clipboard
open fun getBaseline(): Int

Gets the Y position of baseline of the first line in @layout.

Link copied to clipboard
open fun getCaretPos(index: Int, strongPos: Rectangle?, weakPos: Rectangle?)

Given an index within a layout, determines the positions that of the strong and weak cursors if the insertion point is at that index.

Link copied to clipboard

Returns the number of Unicode characters in the the text of @layout.

Link copied to clipboard
open fun getCursorPos(index: Int, strongPos: Rectangle?, weakPos: Rectangle?)

Given an index within a layout, determines the positions that of the strong and weak cursors if the insertion point is at that index.

Link copied to clipboard
open fun getDirection(index: Int): Direction

Gets the text direction at the given character position in @layout.

Link copied to clipboard

Gets the type of ellipsization being performed for @layout.

Link copied to clipboard
open fun getExtents(inkRect: Rectangle?, logicalRect: Rectangle?)

Computes the logical and ink extents of @layout.

Link copied to clipboard

Gets the font description for the layout, if any.

Link copied to clipboard
open fun getHeight(): Int

Gets the height of layout used for ellipsization.

Link copied to clipboard
open fun getIndent(): Int

Gets the paragraph indent width in Pango units.

Link copied to clipboard
open fun getIter(): LayoutIter

Returns an iterator to iterate over the visual extents of the layout.

Link copied to clipboard
open fun getJustify(): Boolean

Gets whether each complete line should be stretched to fill the entire width of the layout.

Link copied to clipboard

Gets whether the last line should be stretched to fill the entire width of the layout.

Link copied to clipboard
open fun getLine(line: Int): LayoutLine?

Retrieves a particular line from a PangoLayout.

Link copied to clipboard
open fun getLineCount(): Int

Retrieves the count of lines for the @layout.

Link copied to clipboard
open fun getLineReadonly(line: Int): LayoutLine?

Retrieves a particular line from a PangoLayout.

Link copied to clipboard
open fun getLines(): <Error class: unknown class>

Returns the lines of the @layout as a list.

Link copied to clipboard
open fun getLineSpacing(): Float

Gets the line spacing factor of @layout.

Link copied to clipboard
open fun getLinesReadonly(): <Error class: unknown class>

Returns the lines of the @layout as a list.

Link copied to clipboard
open fun getPixelExtents(inkRect: Rectangle?, logicalRect: Rectangle?)

Computes the logical and ink extents of @layout in device units.

Link copied to clipboard
open fun getSerial(): <Error class: unknown class>

Returns the current serial number of @layout.

Link copied to clipboard

Obtains whether @layout is in single paragraph mode.

Link copied to clipboard
open fun getSpacing(): Int

Gets the amount of spacing between the lines of the layout.

Link copied to clipboard
open fun getTabs(): TabArray?

Gets the current PangoTabArray used by this layout.

Link copied to clipboard
open fun getText(): String

Gets the text in the layout.

Link copied to clipboard

Counts the number of unknown glyphs in @layout.

Link copied to clipboard
open fun getWidth(): Int

Gets the width to which the lines of the PangoLayout should wrap.

Link copied to clipboard
open fun getWrap(): WrapMode

Gets the wrap mode for the layout.

Link copied to clipboard
open fun indexToPos(index: Int, pos: Rectangle)

Converts from an index within a PangoLayout to the onscreen position corresponding to the grapheme at that index.

Link copied to clipboard
open fun isEllipsized(): Boolean

Queries whether the layout had to ellipsize any paragraphs.

Link copied to clipboard
open fun isWrapped(): Boolean

Queries whether the layout had to wrap any paragraphs.

Link copied to clipboard
open fun serialize(flags: LayoutSerializeFlags): <Error class: unknown class>

Serializes the @layout for later deserialization via func@Pango.Layout.deserialize.

Link copied to clipboard
open fun setAlignment(alignment: Alignment)

Sets the alignment for the layout: how partial lines are positioned within the horizontal space available.

Link copied to clipboard
open fun setAttributes(attrs: AttrList? = null)

Sets the text attributes for a layout object.

Link copied to clipboard
open fun setAutoDir(autoDir: Boolean)

Sets whether to calculate the base direction for the layout according to its contents.

Link copied to clipboard
open fun setEllipsize(ellipsize: EllipsizeMode)

Sets the type of ellipsization being performed for @layout.

Link copied to clipboard
open fun setFontDescription(desc: FontDescription? = null)

Sets the default font description for the layout.

Link copied to clipboard
open fun setHeight(height: Int)

Sets the height to which the PangoLayout should be ellipsized at.

Link copied to clipboard
open fun setIndent(indent: Int)

Sets the width in Pango units to indent each paragraph.

Link copied to clipboard
open fun setJustify(justify: Boolean)

Sets whether each complete line should be stretched to fill the entire width of the layout.

Link copied to clipboard
open fun setJustifyLastLine(justify: Boolean)

Sets whether the last line should be stretched to fill the entire width of the layout.

Link copied to clipboard
open fun setLineSpacing(factor: Float)

Sets a factor for line spacing.

Link copied to clipboard
open fun setMarkup(markup: String, length: Int)

Sets the layout text and attribute list from marked-up text.

Link copied to clipboard
open fun setSingleParagraphMode(setting: Boolean)

Sets the single paragraph mode of @layout.

Link copied to clipboard
open fun setSpacing(spacing: Int)

Sets the amount of spacing in Pango units between the lines of the layout.

Link copied to clipboard
open fun setTabs(tabs: TabArray? = null)

Sets the tabs to use for @layout, overriding the default tabs.

Link copied to clipboard
open fun setText(text: String, length: Int)

Sets the text of the layout.

Link copied to clipboard
open fun setWidth(width: Int)

Sets the width to which the lines of the PangoLayout should wrap or ellipsized.

Link copied to clipboard
open fun setWrap(wrap: WrapMode)

Sets the wrap mode.

Link copied to clipboard
open fun writeToFile(flags: LayoutSerializeFlags, filename: String): <Error class: unknown class><Boolean>

A convenience method to serialize a layout to a file.