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
isAUTO
, it is first replaced with the preferred gravity ofscript
. To get the preferred gravity of a script, passAUTO
andSTRONG
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
isAUTO
, it is first replaced with the preferred gravity ofscript
.Added in version 1.26.
- Parameters:
wide –
True
for wide characters as returned byunichar_iswide()
base_gravity – base gravity of the paragraph
hint – orientation hint