:right-sidebar: True Font =================================================================== .. currentmodule:: gi.repository.Pango .. class:: Font(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: Font(**properties) Methods ------- .. rst-class:: interim-class .. class:: Font :no-index: .. method:: describe() -> ~gi.repository.Pango.FontDescription Returns a description of the font, with font size set in points. Use :obj:`~gi.repository.Pango.Font.describe_with_absolute_size` if you want the font size in device units. .. method:: describe_with_absolute_size() -> ~gi.repository.Pango.FontDescription Returns a description of the font, with absolute font size set in device units. Use :obj:`~gi.repository.Pango.Font.describe` if you want the font size in points. .. versionadded:: 1.14 .. method:: descriptions_free(descs: ~typing.Sequence[~gi.repository.Pango.FontDescription] | None = None) -> None Frees an array of font descriptions. :param descs: a pointer to an array of ``PangoFontDescription``, may be :const:`None` .. method:: deserialize(context: ~gi.repository.Pango.Context, bytes: ~gi.repository.GLib.Bytes) -> ~gi.repository.Pango.Font | None Loads data previously created via :obj:`~gi.repository.Pango.Font.serialize`. For a discussion of the supported format, see that function. Note: to verify that the returned font is identical to the one that was serialized, you can compare ``bytes`` to the result of serializing the font again. .. versionadded:: 1.50 :param context: a ``PangoContext`` :param bytes: the bytes containing the data .. method:: get_coverage(language: ~gi.repository.Pango.Language) -> ~gi.repository.Pango.Coverage Computes the coverage map for a given font and language tag. :param language: the language tag .. method:: get_face() -> ~gi.repository.Pango.FontFace Gets the ``PangoFontFace`` to which ``font`` belongs. .. versionadded:: 1.46 .. method:: get_features() -> tuple[list[~gi.repository.HarfBuzz.feature_t], int] Obtain the OpenType features that are provided by the font. These are passed to the rendering system, together with features that have been explicitly set via attributes. Note that this does not include OpenType features which the rendering system enables by default. .. versionadded:: 1.44 .. method:: get_font_map() -> ~gi.repository.Pango.FontMap | None Gets the font map for which the font was created. Note that the font maintains a *weak* reference to the font map, so if all references to font map are dropped, the font map will be finalized even if there are fonts created with the font map that are still alive. In that case this function will return :const:`None`. It is the responsibility of the user to ensure that the font map is kept alive. In most uses this is not an issue as a ``PangoContext`` holds a reference to the font map. .. versionadded:: 1.10 .. method:: get_glyph_extents(glyph: int) -> tuple[~gi.repository.Pango.Rectangle, ~gi.repository.Pango.Rectangle] Gets the logical and ink extents of a glyph within a font. The coordinate system for each rectangle has its origin at the base line and horizontal origin of the character with increasing coordinates extending to the right and down. The macros :func:`~gi.repository.Pango.ASCENT`, :func:`~gi.repository.Pango.DESCENT`, :func:`~gi.repository.Pango.LBEARING`, and :func:`~gi.repository.Pango.RBEARING` can be used to convert from the extents rectangle to more traditional font metrics. The units of the rectangles are in 1/PANGO_SCALE of a device unit. If ``font`` is :const:`None`, this function gracefully sets some sane values in the output variables and returns. :param glyph: the glyph index .. method:: get_languages() -> list[~gi.repository.Pango.Language] | None Returns the languages that are supported by ``font``. If the font backend does not provide this information, :const:`None` is returned. For the fontconfig backend, this corresponds to the FC_LANG member of the FcPattern. The returned array is only valid as long as the font and its fontmap are valid. .. versionadded:: 1.50 .. method:: get_metrics(language: ~gi.repository.Pango.Language | None = None) -> ~gi.repository.Pango.FontMetrics Gets overall metric information for a font. Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language. If ``font`` is :const:`None`, this function gracefully sets some sane values in the output variables and returns. :param language: language tag used to determine which script to get the metrics for, or :const:`None` to indicate to get the metrics for the entire font. .. method:: has_char(wc: str) -> bool Returns whether the font provides a glyph for this character. .. versionadded:: 1.44 :param wc: a Unicode character .. method:: serialize() -> ~gi.repository.GLib.Bytes Serializes the ``font`` in a way that can be uniquely identified. There are no guarantees about the format of the output across different versions of Pango. The intended use of this function is testing, benchmarking and debugging. The format is not meant as a permanent storage format. To recreate a font from its serialized form, use :obj:`~gi.repository.Pango.Font.deserialize`. .. versionadded:: 1.50 Virtual Methods --------------- .. rst-class:: interim-class .. class:: Font :no-index: .. method:: do_create_hb_font() -> ~gi.repository.HarfBuzz.font_t .. method:: do_describe() -> ~gi.repository.Pango.FontDescription Returns a description of the font, with font size set in points. Use :obj:`~gi.repository.Pango.Font.describe_with_absolute_size` if you want the font size in device units. .. method:: do_describe_absolute() -> ~gi.repository.Pango.FontDescription .. method:: do_get_coverage(language: ~gi.repository.Pango.Language) -> ~gi.repository.Pango.Coverage Computes the coverage map for a given font and language tag. :param language: the language tag .. method:: do_get_features() -> tuple[list[~gi.repository.HarfBuzz.feature_t], int] Obtain the OpenType features that are provided by the font. These are passed to the rendering system, together with features that have been explicitly set via attributes. Note that this does not include OpenType features which the rendering system enables by default. .. versionadded:: 1.44 .. method:: do_get_font_map() -> ~gi.repository.Pango.FontMap | None Gets the font map for which the font was created. Note that the font maintains a *weak* reference to the font map, so if all references to font map are dropped, the font map will be finalized even if there are fonts created with the font map that are still alive. In that case this function will return :const:`None`. It is the responsibility of the user to ensure that the font map is kept alive. In most uses this is not an issue as a ``PangoContext`` holds a reference to the font map. .. versionadded:: 1.10 .. method:: do_get_glyph_extents(glyph: int) -> tuple[~gi.repository.Pango.Rectangle, ~gi.repository.Pango.Rectangle] Gets the logical and ink extents of a glyph within a font. The coordinate system for each rectangle has its origin at the base line and horizontal origin of the character with increasing coordinates extending to the right and down. The macros :func:`~gi.repository.Pango.ASCENT`, :func:`~gi.repository.Pango.DESCENT`, :func:`~gi.repository.Pango.LBEARING`, and :func:`~gi.repository.Pango.RBEARING` can be used to convert from the extents rectangle to more traditional font metrics. The units of the rectangles are in 1/PANGO_SCALE of a device unit. If ``font`` is :const:`None`, this function gracefully sets some sane values in the output variables and returns. :param glyph: the glyph index .. method:: do_get_metrics(language: ~gi.repository.Pango.Language | None = None) -> ~gi.repository.Pango.FontMetrics Gets overall metric information for a font. Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language. If ``font`` is :const:`None`, this function gracefully sets some sane values in the output variables and returns. :param language: language tag used to determine which script to get the metrics for, or :const:`None` to indicate to get the metrics for the entire font. Fields ------ .. rst-class:: interim-class .. class:: Font :no-index: .. attribute:: parent_instance