TabArray

class TabArray(**kwargs)

A PangoTabArray contains an array of tab stops.

PangoTabArray can be used to set tab stops in a PangoLayout. Each tab stop has an alignment, a position, and optionally a character to use as decimal point.

Constructors

class TabArray
classmethod new(initial_size: int, positions_in_pixels: bool) TabArray

Creates an array of initial_size tab stops.

Tab stops are specified in pixel units if positions_in_pixels is True, otherwise in Pango units. All stops are initially at position 0.

Parameters:
  • initial_size – Initial number of tab stops to allocate, can be 0

  • positions_in_pixels – whether positions are in pixel units

Methods

class TabArray
free() None

Frees a tab array and associated resources.

from_string(text: str) TabArray | None

Deserializes a PangoTabArray from a string.

This is the counterpart to to_string. See that functions for details about the format.

Added in version 1.50.

Parameters:

text – a string

get_decimal_point(tab_index: int) str

Gets the Unicode character to use as decimal point.

This is only relevant for tabs with DECIMAL alignment, which align content at the first occurrence of the decimal point character.

The default value of 0 means that Pango will use the decimal point according to the current locale.

Added in version 1.50.

Parameters:

tab_index – the index of a tab stop

get_positions_in_pixels() bool

Returns True if the tab positions are in pixels, False if they are in Pango units.

get_size() int

Gets the number of tab stops in tab_array.

get_tab(tab_index: int) tuple[TabAlign, int]

Gets the alignment and position of a tab stop.

Parameters:

tab_index – tab stop index

get_tabs() tuple[TabAlign, list[int]]

If non-None, alignments and locations are filled with allocated arrays.

The arrays are of length get_size. You must free the returned array.

resize(new_size: int) None

Resizes a tab array.

You must subsequently initialize any tabs that were added as a result of growing the array.

Parameters:

new_size – new size of the array

set_decimal_point(tab_index: int, decimal_point: str) None

Sets the Unicode character to use as decimal point.

This is only relevant for tabs with DECIMAL alignment, which align content at the first occurrence of the decimal point character.

By default, Pango uses the decimal point according to the current locale.

Added in version 1.50.

Parameters:
  • tab_index – the index of a tab stop

  • decimal_point – the decimal point to use

set_positions_in_pixels(positions_in_pixels: bool) None

Sets whether positions in this array are specified in pixels.

Added in version 1.50.

Parameters:

positions_in_pixels – whether positions are in pixels

set_tab(tab_index: int, alignment: TabAlign, location: int) None

Sets the alignment and location of a tab stop.

Parameters:
  • tab_index – the index of a tab stop

  • alignment – tab alignment

  • location – tab location in Pango units

sort() None

Utility function to ensure that the tab stops are in increasing order.

Added in version 1.50.

to_string() str

Serializes a PangoTabArray to a string.

No guarantees are made about the format of the string, it may change between Pango versions.

The intended use of this function is testing and debugging. The format is not meant as a permanent storage format.

Added in version 1.50.