:right-sidebar: True LayoutLine =================================================================== .. currentmodule:: gi.repository.Pango .. class:: LayoutLine(*args, **kwargs) :no-contents-entry: A ``PangoLayoutLine`` represents one of the lines resulting from laying out a paragraph via ``PangoLayout``\. ``PangoLayoutLine`` structures are obtained by calling :obj:`~gi.repository.Pango.Layout.get_line` and are only valid until the text, attributes, or settings of the parent ``PangoLayout`` are modified. Methods ------- .. rst-class:: interim-class .. class:: LayoutLine :no-index: .. method:: get_extents() -> ~typing.Tuple[~gi.repository.Pango.Rectangle, ~gi.repository.Pango.Rectangle] Computes the logical and ink extents of a layout line. See :obj:`~gi.repository.Pango.Font.get_glyph_extents` for details about the interpretation of the rectangles. .. method:: get_height() -> int Computes the height of the line, as the maximum of the heights of fonts used in this line. Note that the actual baseline-to-baseline distance between lines of text is influenced by other factors, such as :obj:`~gi.repository.Pango.Layout.set_spacing` and :obj:`~gi.repository.Pango.Layout.set_line_spacing`\. .. versionadded:: 1.44 .. method:: get_length() -> int Returns the length of the line, in bytes. .. versionadded:: 1.50 .. method:: get_pixel_extents() -> ~typing.Tuple[~gi.repository.Pango.Rectangle, ~gi.repository.Pango.Rectangle] Computes the logical and ink extents of ``layout_line`` in device units. This function just calls :obj:`~gi.repository.Pango.LayoutLine.get_extents` followed by two :obj:`~gi.repository.Pango.extents_to_pixels` calls, rounding ``ink_rect`` and ``logical_rect`` such that the rounded rectangles fully contain the unrounded one (that is, passes them as first argument to :obj:`~gi.repository.Pango.extents_to_pixels`\). .. method:: get_resolved_direction() -> ~gi.repository.Pango.Direction Returns the resolved direction of the line. .. versionadded:: 1.50 .. method:: get_start_index() -> int Returns the start index of the line, as byte index into the text of the layout. .. versionadded:: 1.50 .. method:: get_x_ranges(start_index: int, end_index: int) -> list[int] Gets a list of visual ranges corresponding to a given logical range. This list is not necessarily minimal - there may be consecutive ranges which are adjacent. The ranges will be sorted from left to right. The ranges are with respect to the left edge of the entire layout, not with respect to the line. :param start_index: Start byte index of the logical range. If this value is less than the start index for the line, then the first range will extend all the way to the leading edge of the layout. Otherwise, it will start at the leading edge of the first character. :param end_index: Ending byte index of the logical range. If this value is greater than the end index for the line, then the last range will extend all the way to the trailing edge of the layout. Otherwise, it will end at the trailing edge of the last character. .. method:: index_to_x(index_: int, trailing: bool) -> int Converts an index within a line to a X position. :param index_: byte offset of a grapheme within the layout :param trailing: an integer indicating the edge of the grapheme to retrieve the position of. If > 0, the trailing edge of the grapheme, if 0, the leading of the grapheme .. method:: is_paragraph_start() -> bool Returns whether this is the first line of the paragraph. .. versionadded:: 1.50 .. method:: x_to_index(x_pos: int) -> ~typing.Tuple[bool, int, int] Converts from x offset to the byte index of the corresponding character within the text of the layout. If ``x_pos`` is outside the line, ``index_`` and ``trailing`` will point to the very first or very last position in the line. This determination is based on the resolved direction of the paragraph; for example, if the resolved direction is right-to-left, then an X position to the right of the line (after it) results in 0 being stored in ``index_`` and ``trailing``\. An X position to the left of the line results in ``index_`` pointing to the (logical) last grapheme in the line and ``trailing`` being set to the number of characters in that grapheme. The reverse is true for a left-to-right line. :param x_pos: the X offset (in Pango units) from the left edge of the line. Fields ------ .. rst-class:: interim-class .. class:: LayoutLine :no-index: .. attribute:: layout The layout this line belongs to, might be :const:`None` .. attribute:: length Length of line in bytes .. attribute:: resolved_dir ``Resolved`` PangoDirection of line .. attribute:: runs List of runs in the line, from left to right .. attribute:: start_index Start of line as byte index into layout->text