FontDialog
Added in version 4.10.
Superclasses: Object
A GtkFontDialog
object collects the arguments that
are needed to present a font chooser 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. This API follows the GIO async pattern,
and the result can be obtained by calling the corresponding
finish function, such as choose_font_finish
.
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
- choose_face(parent: Window | None = None, initial_value: FontFace | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
This function initiates a font selection operation by presenting a dialog to the user for selecting a font face (i.e. a font family and style, but not a specific font size).
The
callback
will be called when the dialog is dismissed. It should callchoose_face_finish
to obtain the result.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
initial_value – the initial value
cancellable – a
GCancellable
to cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- choose_face_finish(result: AsyncResult) FontFace | None
Finishes the
choose_face
call and returns the resulting font face.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- choose_family(parent: Window | None = None, initial_value: FontFamily | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
This function initiates a font selection operation by presenting a dialog to the user for selecting a font family.
The
callback
will be called when the dialog is dismissed. It should callchoose_family_finish
to obtain the result.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
initial_value – the initial value
cancellable – a
GCancellable
to cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- choose_family_finish(result: AsyncResult) FontFamily | None
Finishes the
choose_family
call and returns the resulting family.This function never returns an error. If the operation is not finished successfully, the value passed as
initial_value
tochoose_family
is returned.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- choose_font(parent: Window | None = None, initial_value: FontDescription | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
This function initiates a font selection operation by presenting a dialog to the user for selecting a font.
The
callback
will be called when the dialog is dismissed. It should callchoose_font_finish
to obtain the result.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
GtkWindow
initial_value – the font to select initially
cancellable – a
GCancellable
to cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- choose_font_and_features(parent: Window | None = None, initial_value: FontDescription | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
This function initiates a font selection operation by presenting a dialog to the user for selecting a font and font features.
Font features affect how the font is rendered, for example enabling glyph variants or ligatures.
The
callback
will be called when the dialog is dismissed. It should callchoose_font_and_features_finish
to obtain the result.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
initial_value – the font to select initially
cancellable – a
GCancellable
to cancel the operationcallback – 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 and returns the resulting font description and font features.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- choose_font_finish(result: AsyncResult) FontDescription | None
Finishes the
choose_font
call and returns the resulting font description.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- 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
GtkFilter
must be able to handle bothPangoFontFamily
andPangoFontFace
objects.Added in version 4.10.
- Parameters:
filter – a
GtkFilter
- set_font_map(fontmap: FontMap | None = None) None
Sets the fontmap from which fonts are selected.
If
fontmap
isNULL
, 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
Properties
- class FontDialog
- props.filter: Filter
Sets a filter to restrict what fonts are shown in the font chooser dialog.
Added in version 4.10.
- props.font_map: FontMap
Sets 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.title: str
A title that may be shown on the font chooser dialog that is presented by
choose_font
.Added in version 4.10.