Pango.TabArray

Fields

None

Methods

class

from_string (text)

class

new (initial_size, positions_in_pixels)

copy ()

free ()

get_decimal_point (tab_index)

get_positions_in_pixels ()

get_size ()

get_tab (tab_index)

get_tabs ()

resize (new_size)

set_decimal_point (tab_index, decimal_point)

set_positions_in_pixels (positions_in_pixels)

set_tab (tab_index, alignment, location)

sort ()

to_string ()

Details

class Pango.TabArray

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.

classmethod from_string(text)[source]
Parameters:

text (str) – a string

Returns:

a new PangoTabArray

Return type:

Pango.TabArray or None

Deserializes a PangoTabArray from a string.

This is the counterpart to [method`Pango`.TabArray.to_string]. See that functions for details about the format.

New in version 1.50.

classmethod new(initial_size, positions_in_pixels)[source]
Parameters:
  • initial_size (int) – Initial number of tab stops to allocate, can be 0

  • positions_in_pixels (bool) – whether positions are in pixel units

Returns:

the newly allocated PangoTabArray, which should be freed with [method`Pango`.TabArray.free].

Return type:

Pango.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.

copy()[source]
Returns:

the newly allocated PangoTabArray, which should be freed with [method`Pango`.TabArray.free].

Return type:

Pango.TabArray

Copies a PangoTabArray.

free()[source]

Frees a tab array and associated resources.

get_decimal_point(tab_index)[source]
Parameters:

tab_index (int) – the index of a tab stop

Return type:

str

Gets the Unicode character to use as decimal point.

This is only relevant for tabs with Pango.TabAlign.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.

New in version 1.50.

get_positions_in_pixels()[source]
Returns:

whether positions are in pixels.

Return type:

bool

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

get_size()[source]
Returns:

the number of tab stops in the array.

Return type:

int

Gets the number of tab stops in self.

get_tab(tab_index)[source]
Parameters:

tab_index (int) – tab stop index

Returns:

alignment:

location to store alignment

location:

location to store tab position

Return type:

(alignment: Pango.TabAlign, location: int)

Gets the alignment and position of a tab stop.

get_tabs()[source]
Returns:

alignments:

location to store an array of tab stop alignments

locations:

location to store an array of tab positions

Return type:

(alignments: Pango.TabAlign, locations: [int])

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

The arrays are of length [method`Pango`.TabArray.get_size]. You must free the returned array.

resize(new_size)[source]
Parameters:

new_size (int) – new size of the array

Resizes a tab array.

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

set_decimal_point(tab_index, decimal_point)[source]
Parameters:
  • tab_index (int) – the index of a tab stop

  • decimal_point (str) – the decimal point to use

Sets the Unicode character to use as decimal point.

This is only relevant for tabs with Pango.TabAlign.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.

New in version 1.50.

set_positions_in_pixels(positions_in_pixels)[source]
Parameters:

positions_in_pixels (bool) – whether positions are in pixels

Sets whether positions in this array are specified in pixels.

New in version 1.50.

set_tab(tab_index, alignment, location)[source]
Parameters:
  • tab_index (int) – the index of a tab stop

  • alignment (Pango.TabAlign) – tab alignment

  • location (int) – tab location in Pango units

Sets the alignment and location of a tab stop.

sort()[source]

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

New in version 1.50.

to_string()[source]
Returns:

a newly allocated string

Return type:

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.

New in version 1.50.