:right-sidebar: True Gravity =================================================================== .. currentmodule:: gi.repository.Pango .. versionadded:: 1.16 .. class:: Gravity :no-contents-entry: ``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 :obj:`~gi.repository.Pango.Matrix`\, and then glyph orientation is controlled using ``PangoGravity``\. Not every value in this enumeration makes sense for every usage of ``PangoGravity``\; for example, :const:`~gi.repository.Pango.Gravity.AUTO` only can be passed to :obj:`~gi.repository.Pango.Context.set_base_gravity` and can only be returned by :obj:`~gi.repository.Pango.Context.get_base_gravity`\. See also: :obj:`~gi.repository.Pango.GravityHint` Methods ------- .. rst-class:: interim-class .. class:: Gravity :no-index: .. method:: get_for_matrix() -> ~gi.repository.Pango.Gravity Finds the gravity that best matches the rotation component in a ``PangoMatrix``\. .. versionadded:: 1.16 .. method:: get_for_script(base_gravity: ~gi.repository.Pango.Gravity, hint: ~gi.repository.Pango.GravityHint) -> ~gi.repository.Pango.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 :const:`~gi.repository.Pango.Gravity.AUTO`, it is first replaced with the preferred gravity of ``script``\. To get the preferred gravity of a script, pass :const:`~gi.repository.Pango.Gravity.AUTO` and :const:`~gi.repository.Pango.GravityHint.STRONG` in. .. versionadded:: 1.16 :param base_gravity: base gravity of the paragraph :param hint: orientation hint .. method:: get_for_script_and_width(wide: bool, base_gravity: ~gi.repository.Pango.Gravity, hint: ~gi.repository.Pango.GravityHint) -> ~gi.repository.Pango.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 :obj:`~gi.repository.Pango.Gravity.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 :const:`~gi.repository.Pango.Gravity.AUTO`, it is first replaced with the preferred gravity of ``script``\. .. versionadded:: 1.26 :param wide: :const:`True` for wide characters as returned by :func:`~gi.repository.GLib.unichar_iswide` :param base_gravity: base gravity of the paragraph :param hint: orientation hint .. method:: to_rotation() -> float Converts a ``PangoGravity`` value to its natural rotation in radians. Note that :obj:`~gi.repository.Pango.Matrix.rotate` takes angle in degrees, not radians. So, to call :obj:`~gi.repository.Pango.Matrix,rotate` with the output of this function you should multiply it by (180. / G_PI). .. versionadded:: 1.16 Fields ------ .. rst-class:: interim-class .. class:: Gravity :no-index: .. attribute:: AUTO The type of the None singleton. .. attribute:: EAST The type of the None singleton. .. attribute:: NORTH The type of the None singleton. .. attribute:: SOUTH The type of the None singleton. .. attribute:: WEST The type of the None singleton.