Gtk.FontChooser

g GObject.GInterface GObject.GInterface Gtk.FontChooser Gtk.FontChooser GObject.GInterface->Gtk.FontChooser

Implementations:

Gtk.FontButton, Gtk.FontChooserDialog, Gtk.FontChooserWidget

Methods

get_font ()

get_font_desc ()

get_font_face ()

get_font_family ()

get_font_features ()

get_font_map ()

get_font_size ()

get_language ()

get_level ()

get_preview_text ()

get_show_preview_entry ()

set_filter_func (filter, *user_data)

set_font (fontname)

set_font_desc (font_desc)

set_font_map (fontmap)

set_language (language)

set_level (level)

set_preview_text (text)

set_show_preview_entry (show_preview_entry)

Virtual Methods

do_font_activated (fontname)

do_get_font_face ()

do_get_font_family ()

do_get_font_map ()

do_get_font_size ()

do_set_filter_func (filter, *user_data)

do_set_font_map (fontmap)

Properties

Name

Type

Flags

Short Description

font

str

r/w

deprecated

font-desc

Pango.FontDescription

r/w

deprecated

font-features

str

r

deprecated

language

str

r/w/en

deprecated

level

Gtk.FontChooserLevel

r/w/en

deprecated

preview-text

str

r/w

deprecated

show-preview-entry

bool

r/w/en

deprecated

Signals

Name

Short Description

font-activated

Emitted when a font is activated. deprecated

Fields

None

Class Details

class Gtk.FontChooser
Bases:

GObject.GInterface

Structure:

Gtk.FontChooserIface

GtkFontChooser is an interface that can be implemented by widgets for choosing fonts.

In GTK, the main objects that implement this interface are [class`Gtk`.FontChooserWidget], [class`Gtk`.FontChooserDialog] and [class`Gtk`.FontButton].

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_font()[source]
Returns:

A string with the name of the current font

Return type:

str or None

Gets the currently-selected font name.

Note that this can be a different string than what you set with [method`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 [method`Pango`.FontDescription.equal] if you want to compare two font descriptions.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_font_desc()[source]
Returns:

A PangoFontDescription for the current font

Return type:

Pango.FontDescription or None

Gets the currently-selected font.

Note that this can be a different string than what you set with [method`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 [method`Pango`.FontDescription.equal] if you want to compare two font descriptions.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_font_face()[source]
Returns:

A PangoFontFace representing the selected font group details

Return type:

Pango.FontFace or 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 None.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_font_family()[source]
Returns:

A PangoFontFamily representing the selected font family

Return type:

Pango.FontFamily or 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 None.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_font_features()[source]
Returns:

the currently selected font features

Return type:

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 [func`Pango`.AttrFontFeatures.new].

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_font_map()[source]
Returns:

a PangoFontMap

Return type:

Pango.FontMap or None

Gets the custom font map of this font chooser widget, or None if it does not have one.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_font_size()[source]
Returns:

A n integer representing the selected font size, or -1 if no font size is selected.

Return type:

int

The selected font size.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_language()[source]
Returns:

the currently selected language

Return type:

str

Gets the language that is used for font features.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_level()[source]
Returns:

the current granularity level

Return type:

Gtk.FontChooserLevel

Returns the current level of granularity for selecting fonts.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_preview_text()[source]
Returns:

the text displayed in the preview area

Return type:

str

Gets the text displayed in the preview area.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

get_show_preview_entry()[source]
Returns:

True if the preview entry is shown or False if it is hidden.

Return type:

bool

Returns whether the preview entry is shown or not.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

set_filter_func(filter, *user_data)[source]
Parameters:

Adds a filter function that decides which fonts to display in the font chooser.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

set_font(fontname)[source]
Parameters:

fontname (str) – a font name like “Helvetica 12” or “Times Bold 18”

Sets the currently-selected font.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

set_font_desc(font_desc)[source]
Parameters:

font_desc (Pango.FontDescription) – a PangoFontDescription

Sets the currently-selected font from font_desc.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

set_font_map(fontmap)[source]
Parameters:

fontmap (Pango.FontMap or None) – a PangoFontMap

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.

```c FcConfig *config; Pango.FontMap *fontmap;

config = FcInitLoadConfigAndFonts (); FcConfigAppFontAddFile (config, my_app_font_file);

fontmap = PangoCairo.FontMap.new_for_font_type (cairo.FontType.FT); pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config);

Gtk.FontChooser.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:

``c context = gtk_widget_get_pango_context (label); pango_context_set_font_map (context, fontmap); ``

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

set_language(language)[source]
Parameters:

language (str) – a language

Sets the language to use for font features.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

set_level(level)[source]
Parameters:

level (Gtk.FontChooserLevel) – the desired level of granularity

Sets the desired level of granularity for selecting fonts.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

set_preview_text(text)[source]
Parameters:

text (str) – the text to display in the preview area

Sets the text displayed in the preview area.

The text is used to show how the selected font looks.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

set_show_preview_entry(show_preview_entry)[source]
Parameters:

show_preview_entry (bool) – whether to show the editable preview entry or not

Shows or hides the editable preview entry.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

do_font_activated(fontname) virtual
Parameters:

fontname (str) –

do_get_font_face() virtual
Returns:

A PangoFontFace representing the selected font group details

Return type:

Pango.FontFace or 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 None.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

do_get_font_family() virtual
Returns:

A PangoFontFamily representing the selected font family

Return type:

Pango.FontFamily or 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 None.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

do_get_font_map() virtual
Returns:

a PangoFontMap

Return type:

Pango.FontMap or None

Gets the custom font map of this font chooser widget, or None if it does not have one.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

do_get_font_size() virtual
Returns:

A n integer representing the selected font size, or -1 if no font size is selected.

Return type:

int

The selected font size.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

do_set_filter_func(filter, *user_data) virtual
Parameters:

Adds a filter function that decides which fonts to display in the font chooser.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

do_set_font_map(fontmap) virtual
Parameters:

fontmap (Pango.FontMap or None) – a PangoFontMap

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.

```c FcConfig *config; Pango.FontMap *fontmap;

config = FcInitLoadConfigAndFonts (); FcConfigAppFontAddFile (config, my_app_font_file);

fontmap = PangoCairo.FontMap.new_for_font_type (cairo.FontType.FT); pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config);

Gtk.FontChooser.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:

``c context = gtk_widget_get_pango_context (label); pango_context_set_font_map (context, fontmap); ``

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

Signal Details

Gtk.FontChooser.signals.font_activated(font_chooser, fontname)
Signal Name:

font-activated

Flags:

RUN_FIRST

Parameters:
  • font_chooser (Gtk.FontChooser) – The object which received the signal

  • fontname (str) – the font name

Emitted when a font is activated.

This usually happens when the user double clicks an item, or an item is selected and the user presses one of the keys Space, Shift+Space, Return or Enter.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

Property Details

Gtk.FontChooser.props.font
Name:

font

Type:

str

Default Value:

'Sans 10'

Flags:

READABLE, WRITABLE

The font description as a string, e.g. “Sans Italic 12”.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

Gtk.FontChooser.props.font_desc
Name:

font-desc

Type:

Pango.FontDescription

Default Value:

None

Flags:

READABLE, WRITABLE

The font description as a PangoFontDescription.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

Gtk.FontChooser.props.font_features
Name:

font-features

Type:

str

Default Value:

''

Flags:

READABLE

The selected font features.

The format of the string is compatible with CSS and with Pango attributes.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

Gtk.FontChooser.props.language
Name:

language

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The language for which the font features were selected.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

Gtk.FontChooser.props.level
Name:

level

Type:

Gtk.FontChooserLevel

Default Value:

Gtk.FontChooserLevel.STYLE | Gtk.FontChooserLevel.SIZE

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The level of granularity to offer for selecting fonts.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

Gtk.FontChooser.props.preview_text
Name:

preview-text

Type:

str

Default Value:

'The quick brown fox jumps over the lazy dog.'

Flags:

READABLE, WRITABLE

The string with which to preview the font.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead

Gtk.FontChooser.props.show_preview_entry
Name:

show-preview-entry

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to show an entry to change the preview text.

Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead