FontDialog#

Added in version 4.10.

class FontDialog(**properties: Any)#

Superclasses: Object

Asynchronous API to present a font chooser dialog.

GtkFontDialog collects the arguments that are needed to present the dialog to the user, such as a title for the dialog and whether it should be modal.

The dialog is shown with the choose_font function or its variants.

See FontDialogButton for a convenient control that uses GtkFontDialog and presents the results.

Constructors#

class FontDialog
classmethod new() FontDialog#

Creates a new GtkFontDialog object.

Added in version 4.10.

Methods#

class FontDialog
async choose_face(self, parent: Window | None = None, initial_value: FontFace | None = None) FontFace#

This is the awaitable version of choose_face().

Added in version 4.10.

Parameters:
  • parent – the parent window

  • initial_value – the initial value

choose_face(parent: Window | None = None, initial_value: FontFace | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#

Presents a font chooser dialog to the user.

The font chooser dialog will be set up for selecting a font face.

A font face represents a font family and style, but no specific font size.

Added in version 4.10.

Parameters:
  • parent – the parent window

  • initial_value – the initial value

  • cancellable – a cancellable to cancel the operation

  • callback – a callback to call when the operation is complete

  • user_data – data to pass to callback

choose_face_finish(result: AsyncResult) FontFace#

Finishes the choose_face call.

Note that this function returns a DISMISSED error if the user cancels the dialog.

Added in version 4.10.

Parameters:

result – the result

async choose_family(self, parent: Window | None = None, initial_value: FontFamily | None = None) FontFamily#

This is the awaitable version of choose_family().

Added in version 4.10.

Parameters:
  • parent – the parent window

  • initial_value – the initial value

choose_family(parent: Window | None = None, initial_value: FontFamily | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#

Presents a font chooser dialog to the user.

The font chooser dialog will be set up for selecting a font family.

Added in version 4.10.

Parameters:
  • parent – the parent window

  • initial_value – the initial value

  • cancellable – a cancellable to cancel the operation

  • callback – a callback to call when the operation is complete

  • user_data – data to pass to callback

choose_family_finish(result: AsyncResult) FontFamily#

Finishes the choose_family call.

Note that this function returns a DISMISSED error if the user cancels the dialog.

Added in version 4.10.

Parameters:

result – the result

async choose_font(self, parent: Window | None = None, initial_value: FontDescription | None = None) FontDescription#

This is the awaitable version of choose_font().

Added in version 4.10.

Parameters:
  • parent – the parent window

  • initial_value – the font to select initially

choose_font(parent: Window | None = None, initial_value: FontDescription | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#

Presents a font chooser dialog to the user.

The font chooser dialog will be set up for selecting a font.

If you want to let the user select font features as well, use choose_font_and_features instead.

Added in version 4.10.

Parameters:
  • parent – the parent window

  • initial_value – the font to select initially

  • cancellable – a cancellable to cancel the operation

  • callback – a callback to call when the operation is complete

  • user_data – data to pass to callback

async choose_font_and_features(self, parent: Window | None = None, initial_value: FontDescription | None = None) tuple[bool, FontDescription, str, Language]#

This is the awaitable version of choose_font_and_features().

Added in version 4.10.

Parameters:
  • parent – the parent window

  • initial_value – the font to select initially

choose_font_and_features(parent: Window | None = None, initial_value: FontDescription | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#

Presents a font chooser dialog to the user.

The font chooser dialog will be set up for selecting a font and specify features for the selected font.

Font features affect how the font is rendered, for example enabling glyph variants or ligatures.

Added in version 4.10.

Parameters:
  • parent – the parent window

  • initial_value – the font to select initially

  • cancellable – a cancellable to cancel the operation

  • callback – a callback to call when the operation is complete

  • user_data – data to pass to callback

choose_font_and_features_finish(result: AsyncResult) tuple[bool, FontDescription, str, Language]#

Finishes the choose_font_and_features call.

The selected font and features are returned in font_desc and font_features.

Note that this function returns a DISMISSED error if the user cancels the dialog.

Added in version 4.10.

Parameters:

result – the result

choose_font_finish(result: AsyncResult) FontDescription#

Finishes the choose_font call.

Note that this function returns a DISMISSED error if the user cancels the dialog.

Added in version 4.10.

Parameters:

result – the result

get_filter() Filter | None#

Returns the filter that decides which fonts to display in the font chooser dialog.

Added in version 4.10.

get_font_map() FontMap | None#

Returns the fontmap from which fonts are selected, or NULL for the default fontmap.

Added in version 4.10.

get_language() Language | None#

Returns the language for which font features are applied.

Added in version 4.10.

get_modal() bool#

Returns whether the font chooser dialog blocks interaction with the parent window while it is presented.

Added in version 4.10.

get_title() str#

Returns the title that will be shown on the font chooser dialog.

Added in version 4.10.

set_filter(filter: Filter | None = None) None#

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

The filter must be able to handle both PangoFontFamily and PangoFontFace objects.

Added in version 4.10.

Parameters:

filter – the filter

set_font_map(fontmap: FontMap | None = None) None#

Sets the fontmap from which fonts are selected.

If fontmap is NULL, the default fontmap is used.

Added in version 4.10.

Parameters:

fontmap – the fontmap

set_language(language: Language) None#

Sets the language for which font features are applied.

Added in version 4.10.

Parameters:

language – the language for font features

set_modal(modal: bool) None#

Sets whether the font chooser dialog blocks interaction with the parent window while it is presented.

Added in version 4.10.

Parameters:

modal – the new value

set_title(title: str) None#

Sets the title that will be shown on the font chooser dialog.

Added in version 4.10.

Parameters:

title – the new title

Properties#

class FontDialog
props.filter: Filter#

A filter to restrict what fonts are shown in the font chooser dialog.

Added in version 4.10.

props.font_map: FontMap#

A custom font map to select fonts from.

A custom font map can be used to present application-specific fonts instead of or in addition to the normal system fonts.

Added in version 4.10.

props.language: Language#

The language for which the font features are selected.

Added in version 4.10.

props.modal: bool#

Whether the font chooser dialog is modal.

Added in version 4.10.

props.title: str#

A title that may be shown on the font chooser dialog that is presented by choose_font.

Added in version 4.10.