:right-sidebar: True GlyphItem =================================================================== .. currentmodule:: gi.repository.Pango .. class:: GlyphItem(*args, **kwargs) :no-contents-entry: A ``PangoGlyphItem`` is a pair of a ``PangoItem`` and the glyphs resulting from shaping the items text. As an example of the usage of ``PangoGlyphItem``\, the results of shaping text with ``PangoLayout`` is a list of ``PangoLayoutLine``\, each of which contains a list of ``PangoGlyphItem``\. Methods ------- .. rst-class:: interim-class .. class:: GlyphItem :no-index: .. method:: apply_attrs(text: str, list: ~gi.repository.Pango.AttrList) -> list[~gi.repository.Pango.GlyphItem] Splits a shaped item (``PangoGlyphItem``\) into multiple items based on an attribute list. The idea is that if you have attributes that don't affect shaping, such as color or underline, to avoid affecting shaping, you filter them out (:obj:`~gi.repository.Pango.AttrList.filter`\), apply the shaping process and then reapply them to the result using this function. All attributes that start or end inside a cluster are applied to that cluster; for instance, if half of a cluster is underlined and the other-half strikethrough, then the cluster will end up with both underline and strikethrough attributes. In these cases, it may happen that ``item``\->extra_attrs for some of the result items can have multiple attributes of the same type. This function takes ownership of ``glyph_item``\; it will be reused as one of the elements in the list. .. versionadded:: 1.2 :param text: text that ``list`` applies to :param list: a ``PangoAttrList`` .. method:: free() -> None Frees a ``PangoGlyphItem`` and resources to which it points. .. versionadded:: 1.6 .. method:: get_logical_widths(text: str, logical_widths: list[int]) -> None Given a ``PangoGlyphItem`` and the corresponding text, determine the width corresponding to each character. When multiple characters compose a single cluster, the width of the entire cluster is divided equally among the characters. See also :obj:`~gi.repository.Pango.GlyphString.get_logical_widths`\. .. versionadded:: 1.26 :param text: text that ``glyph_item`` corresponds to (glyph_item->item->offset is an offset from the start of ``text``\) :param logical_widths: an array whose length is the number of characters in glyph_item (equal to glyph_item->item->num_chars) to be filled in with the resulting character widths. .. method:: letter_space(text: str, log_attrs: list[~gi.repository.Pango.LogAttr], letter_spacing: int) -> None Adds spacing between the graphemes of ``glyph_item`` to give the effect of typographic letter spacing. .. versionadded:: 1.6 :param text: text that ``glyph_item`` corresponds to (glyph_item->item->offset is an offset from the start of ``text``\) :param log_attrs: logical attributes for the item (the first logical attribute refers to the position before the first character in the item) :param letter_spacing: amount of letter spacing to add in Pango units. May be negative, though too large negative values will give ugly results. .. method:: split(text: str, split_index: int) -> ~gi.repository.Pango.GlyphItem | None Modifies ``orig`` to cover only the text after ``split_index``\, and returns a new item that covers the text before ``split_index`` that used to be in ``orig``\. You can think of ``split_index`` as the length of the returned item. ``split_index`` may not be 0, and it may not be greater than or equal to the length of ``orig`` (that is, there must be at least one byte assigned to each item, you can't create a zero-length item). This function is similar in function to :func:`~gi.repository.Pango.Item.split` (and uses it internally.) .. versionadded:: 1.2 :param text: text to which positions in ``orig`` apply :param split_index: byte index of position to split item, relative to the start of the item Fields ------ .. rst-class:: interim-class .. class:: GlyphItem :no-index: .. attribute:: end_x_offset Horizontal displacement to apply after th glyph item. Positive values shift right .. attribute:: glyphs Corresponding ``PangoGlyphString`` .. attribute:: item Corresponding ``PangoItem`` .. attribute:: start_x_offset Horizontal displacement to apply before the glyph item. Positive values shift right .. attribute:: y_offset Shift of the baseline, relative to the baseline of the containing line. Positive values shift upwards