Gravity#

Added in version 1.16.

class Gravity#

PangoGravity represents the orientation of glyphs in a segment of text.

This is useful when rendering vertical text layouts. In those situations, the layout is rotated using a non-identity Matrix, and then glyph orientation is controlled using PangoGravity.

Not every value in this enumeration makes sense for every usage of PangoGravity; for example, AUTO only can be passed to set_base_gravity and can only be returned by get_base_gravity.

See also: GravityHint

Methods#

class Gravity
get_for_matrix() Gravity#

Finds the gravity that best matches the rotation component in a PangoMatrix.

Added in version 1.16.

get_for_script(base_gravity: Gravity, hint: GravityHint) Gravity#

Returns the gravity to use in laying out a PangoItem.

The gravity is determined based on the script, base gravity, and hint.

If base_gravity is AUTO, it is first replaced with the preferred gravity of script. To get the preferred gravity of a script, pass AUTO and STRONG in.

Added in version 1.16.

Parameters:
  • base_gravity – base gravity of the paragraph

  • hint – orientation hint

get_for_script_and_width(wide: bool, base_gravity: Gravity, hint: GravityHint) Gravity#

Returns the gravity to use in laying out a single character or PangoItem.

The gravity is determined based on the script, East Asian width, base gravity, and hint,

This function is similar to get_for_script except that this function makes a distinction between narrow/half-width and wide/full-width characters also. Wide/full-width characters always stand upright, that is, they always take the base gravity, whereas narrow/full-width characters are always rotated in vertical context.

If base_gravity is AUTO, it is first replaced with the preferred gravity of script.

Added in version 1.26.

Parameters:
  • wideTrue for wide characters as returned by unichar_iswide()

  • base_gravity – base gravity of the paragraph

  • hint – orientation hint

to_rotation() float#

Converts a PangoGravity value to its natural rotation in radians.

Note that rotate takes angle in degrees, not radians. So, to call Matrix,rotate with the output of this function you should multiply it by (180. / G_PI).

Added in version 1.16.

Fields#

class Gravity
AUTO#

The type of the None singleton.

EAST#

The type of the None singleton.

NORTH#

The type of the None singleton.

SOUTH#

The type of the None singleton.

WEST#

The type of the None singleton.