:right-sidebar: True FontChooser =================================================================== .. currentmodule:: gi.repository.Gtk .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. class:: FontChooser(*args, **kwargs) :no-contents-entry: Implementations: :class:`~gi.repository.Gtk.FontButton`, :class:`~gi.repository.Gtk.FontChooserDialog`, :class:`~gi.repository.Gtk.FontChooserWidget` ``GtkFontChooser`` is an interface that can be implemented by widgets for choosing fonts. In GTK, the main objects that implement this interface are :obj:`~gi.repository.Gtk.FontChooserWidget`\, :obj:`~gi.repository.Gtk.FontChooserDialog` and :obj:`~gi.repository.Gtk.FontButton`\. Methods ------- .. rst-class:: interim-class .. class:: FontChooser :no-index: .. method:: get_font() -> str | None Gets the currently-selected font name. Note that this can be a different string than what you set with :obj:`~gi.repository.Gtk.FontChooser.set_font`\, as the font chooser widget may normalize font names and thus return a string with a different structure. For example, “Helvetica Italic Bold 12” could be normalized to “Helvetica Bold Italic 12”. Use :obj:`~gi.repository.Pango.FontDescription.equal` if you want to compare two font descriptions. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_font_desc() -> ~gi.repository.Pango.FontDescription | None Gets the currently-selected font. Note that this can be a different string than what you set with :obj:`~gi.repository.Gtk.FontChooser.set_font`\, as the font chooser widget may normalize font names and thus return a string with a different structure. For example, “Helvetica Italic Bold 12” could be normalized to “Helvetica Bold Italic 12”. Use :obj:`~gi.repository.Pango.FontDescription.equal` if you want to compare two font descriptions. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_font_face() -> ~gi.repository.Pango.FontFace | None Gets the ``PangoFontFace`` representing the selected font group details (i.e. family, slant, weight, width, etc). If the selected font is not installed, returns :const:`None`. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_font_family() -> ~gi.repository.Pango.FontFamily | None Gets the ``PangoFontFamily`` representing the selected font family. Font families are a collection of font faces. If the selected font is not installed, returns :const:`None`. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_font_features() -> str Gets the currently-selected font features. The format of the returned string is compatible with the `CSS font-feature-settings property `__\. It can be passed to :obj:`~gi.repository.Pango.AttrFontFeatures.new`\. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_font_map() -> ~gi.repository.Pango.FontMap | None Gets the custom font map of this font chooser widget, or :const:`None` if it does not have one. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_font_size() -> int The selected font size. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_language() -> str Gets the language that is used for font features. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_level() -> ~gi.repository.Gtk.FontChooserLevel Returns the current level of granularity for selecting fonts. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_preview_text() -> str Gets the text displayed in the preview area. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: get_show_preview_entry() -> bool Returns whether the preview entry is shown or not. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: set_filter_func(filter: ~typing.Callable[[~gi.repository.Pango.FontFamily, ~gi.repository.Pango.FontFace, ~typing.Any], bool] | None = None, user_data: ~typing.Any = None) -> None Adds a filter function that decides which fonts to display in the font chooser. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param filter: a ``GtkFontFilterFunc`` :param user_data: data to pass to ``filter`` .. method:: set_font(fontname: str) -> None Sets the currently-selected font. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param fontname: a font name like “Helvetica 12” or “Times Bold 18” .. method:: set_font_desc(font_desc: ~gi.repository.Pango.FontDescription) -> None Sets the currently-selected font from ``font_desc``\. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param font_desc: a ``PangoFontDescription`` .. method:: set_font_map(fontmap: ~gi.repository.Pango.FontMap | None = None) -> None Sets a custom font map to use for this font chooser widget. A custom font map can be used to present application-specific fonts instead of or in addition to the normal system fonts. .. code-block:: c :dedent: FcConfig *config; PangoFontMap *fontmap; config = FcInitLoadConfigAndFonts (); FcConfigAppFontAddFile (config, my_app_font_file); fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT); pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config); gtk_font_chooser_set_font_map (font_chooser, fontmap); Note that other GTK widgets will only be able to use the application-specific font if it is present in the font map they use: .. code-block:: c :dedent: context = gtk_widget_get_pango_context (label); pango_context_set_font_map (context, fontmap); .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param fontmap: a ``PangoFontMap`` .. method:: set_language(language: str) -> None Sets the language to use for font features. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param language: a language .. method:: set_level(level: ~gi.repository.Gtk.FontChooserLevel) -> None Sets the desired level of granularity for selecting fonts. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param level: the desired level of granularity .. method:: set_preview_text(text: str) -> None Sets the text displayed in the preview area. The ``text`` is used to show how the selected font looks. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param text: the text to display in the preview area .. method:: set_show_preview_entry(show_preview_entry: bool) -> None Shows or hides the editable preview entry. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param show_preview_entry: whether to show the editable preview entry or not Properties ---------- .. rst-class:: interim-class .. class:: FontChooser :no-index: .. attribute:: props.font :type: str The type of the None singleton. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. attribute:: props.font_desc :type: ~gi.repository.Pango.FontDescription The type of the None singleton. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. attribute:: props.font_features :type: str The type of the None singleton. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. attribute:: props.language :type: str The type of the None singleton. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. attribute:: props.level :type: ~gi.repository.Gtk.FontChooserLevel The type of the None singleton. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. attribute:: props.preview_text :type: str The type of the None singleton. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. attribute:: props.show_preview_entry :type: bool The type of the None singleton. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead Signals ------- .. rst-class:: interim-class .. class:: FontChooser.signals :no-index: .. method:: font_activated(fontname: str) -> None The type of the None singleton. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param fontname: the font name Virtual Methods --------------- .. rst-class:: interim-class .. class:: FontChooser :no-index: .. method:: do_font_activated(fontname: str) -> None The type of the None singleton. :param fontname: .. method:: do_get_font_face() -> ~gi.repository.Pango.FontFace | None Gets the ``PangoFontFace`` representing the selected font group details (i.e. family, slant, weight, width, etc). If the selected font is not installed, returns :const:`None`. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: do_get_font_family() -> ~gi.repository.Pango.FontFamily | None Gets the ``PangoFontFamily`` representing the selected font family. Font families are a collection of font faces. If the selected font is not installed, returns :const:`None`. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: do_get_font_map() -> ~gi.repository.Pango.FontMap | None Gets the custom font map of this font chooser widget, or :const:`None` if it does not have one. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: do_get_font_size() -> int The selected font size. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead .. method:: do_set_filter_func(filter: ~typing.Callable[[~gi.repository.Pango.FontFamily, ~gi.repository.Pango.FontFace, ~typing.Any], bool] | None = None, user_data: ~typing.Any = None) -> None Adds a filter function that decides which fonts to display in the font chooser. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param filter: a ``GtkFontFilterFunc`` :param user_data: data to pass to ``filter`` .. method:: do_set_font_map(fontmap: ~gi.repository.Pango.FontMap | None = None) -> None Sets a custom font map to use for this font chooser widget. A custom font map can be used to present application-specific fonts instead of or in addition to the normal system fonts. .. code-block:: c :dedent: FcConfig *config; PangoFontMap *fontmap; config = FcInitLoadConfigAndFonts (); FcConfigAppFontAddFile (config, my_app_font_file); fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT); pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config); gtk_font_chooser_set_font_map (font_chooser, fontmap); Note that other GTK widgets will only be able to use the application-specific font if it is present in the font map they use: .. code-block:: c :dedent: context = gtk_widget_get_pango_context (label); pango_context_set_font_map (context, fontmap); .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.FontDialog` and :obj:`~gi.repository.Gtk.FontDialogButton` instead :param fontmap: a ``PangoFontMap``