gtkmm: Gtk::FontDialog Class Reference

gtkmm 4.14.0

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gtk::FontDialog Class Reference
Dialogs

A Gtk::FontDialog 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. More...

`#include <gtkmm/fontdialog.h>`

Inheritance diagram for Gtk::FontDialog:
[legend]

## Public Member Functions
| FontDialog (FontDialog &&src) noexcept
FontDialog & | operator= (FontDialog &&src) noexcept
| ~FontDialog () noexcept override
GtkFontDialog * | gobj ()
| Provides access to the underlying C GObject.
const GtkFontDialog * | gobj () const
| Provides access to the underlying C GObject.
GtkFontDialog * | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::ustring | get_title () const
| Returns the title that will be shown on the font chooser dialog.
void | set_title (const Glib::ustring &title)
| Sets the title that will be shown on the font chooser dialog.
bool | get_modal () const
| Returns whether the font chooser dialog blocks interaction with the parent window while it is presented.
void | set_modal (bool modal=true)
| Sets whether the font chooser dialog blocks interaction with the parent window while it is presented.
Pango::Language | get_language () const
| Returns the language for which font features are applied.
void | set_language (const Pango::Language &language)
| Sets the language for which font features are applied.
Glib::RefPtr< Pango::FontMap > | get_font_map ()
| Returns the fontmap from which fonts are selected, or `nullptr` for the default fontmap.
Glib::RefPtr< const Pango::FontMap > | get_font_map () const
| Returns the fontmap from which fonts are selected, or `nullptr` for the default fontmap.
void | set_font_map (const Glib::RefPtr< Pango::FontMap > &fontmap)
| Sets the fontmap from which fonts are selected.
Glib::RefPtr< Filter > | get_filter ()
| Returns the filter that decides which fonts to display in the font chooser dialog.
Glib::RefPtr< const Filter > | get_filter () const
| Returns the filter that decides which fonts to display in the font chooser dialog.
void | set_filter (const Glib::RefPtr< Filter > &filter)
| Adds a filter that decides which fonts to display in the font chooser dialog.
void | choose_family (Window & parent, const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Pango::FontFamily > &initial_value={}, const Glib::RefPtr< Gio::Cancellable > &cancellable={})
| This function initiates a font selection operation by presenting a dialog to the user for selecting a font family.
void | choose_family (const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Pango::FontFamily > &initial_value={}, const Glib::RefPtr< Gio::Cancellable > &cancellable={})
| A choose_family() convenience overload.
Glib::RefPtr< Pango::FontFamily > | choose_family_finish (const Glib::RefPtr< Gio::AsyncResult > &result)
| Finishes the choose_family() call and returns the resulting family.
void | choose_face (Window & parent, const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Pango::FontFace > &initial_value={}, const Glib::RefPtr< Gio::Cancellable > &cancellable={})
| 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).
void | choose_face (const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Pango::FontFace > &initial_value={}, const Glib::RefPtr< Gio::Cancellable > &cancellable={})
| A choose_face() convenience overload.
Glib::RefPtr< Pango::FontFace > | choose_face_finish (const Glib::RefPtr< Gio::AsyncResult > &result)
| Finishes the choose_face() call and returns the resulting font face.
void | choose_font (Window & parent, const Gio::SlotAsyncReady &slot, const Pango::FontDescription &initial_value, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) const
| This function initiates a font selection operation by presenting a dialog to the user for selecting a font.
void | choose_font (Window & parent, const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) const
| A choose_font() convenience overload.
void | choose_font (const Gio::SlotAsyncReady &slot, const Pango::FontDescription &initial_value, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) const
| A choose_font() convenience overload.
void | choose_font (const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) const
| A choose_font() convenience overload.
Pango::FontDescription | choose_font_finish (const Glib::RefPtr< Gio::AsyncResult > &result) const
| Finishes the choose_font() call and returns the resulting font description.
void | choose_font_and_features (Window & parent, const Gio::SlotAsyncReady &slot, const Pango::FontDescription &initial_value, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) const
| This function initiates a font selection operation by presenting a dialog to the user for selecting a font and font features.
void | choose_font_and_features (Window & parent, const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) const
| A choose_font_and_features() convenience overload.
void | choose_font_and_features (const Gio::SlotAsyncReady &slot, const Pango::FontDescription &initial_value, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) const
| A choose_font_and_features() convenience overload.
void | choose_font_and_features (const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) const
| A choose_font_and_features() convenience overload.
std::tuple< Pango::FontDescription, Glib::ustring, Pango::Language > | choose_font_and_features_finish (const Glib::RefPtr< Gio::AsyncResult > &result) const
| Finishes the choose_font_and_features() call and returns the resulting font description and font features.
Glib::PropertyProxy< Glib::ustring > | property_title ()
| A title that may be shown on the font chooser dialog that is presented by Gtk::FontDialog::choose_font().
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_title () const
| A title that may be shown on the font chooser dialog that is presented by Gtk::FontDialog::choose_font().
Glib::PropertyProxy< bool > | property_modal ()
| Whether the font chooser dialog is modal.
Glib::PropertyProxy_ReadOnly< bool > | property_modal () const
| Whether the font chooser dialog is modal.
Glib::PropertyProxy< Pango::Language > | property_language ()
| The language for which the font features are selected.
Glib::PropertyProxy_ReadOnly< Pango::Language > | property_language () const
| The language for which the font features are selected.
Glib::PropertyProxy< Glib::RefPtr< Pango::FontMap > > | property_font_map ()
| Sets a custom font map to select fonts from.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Pango::FontMap > > | property_font_map () const
| Sets a custom font map to select fonts from.
Glib::PropertyProxy< Glib::RefPtr< Filter > > | property_filter ()
| Sets a filter to restrict what fonts are shown in the font chooser dialog.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Filter > > | property_filter () const
| Sets a filter to restrict what fonts are shown in the font chooser dialog.

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.
static Glib::RefPtr< FontDialog > | create ()

## Protected Member Functions
| FontDialog ()

## Related Symbols
(Note that these are not member symbols.)
Glib::RefPtr< Gtk::FontDialog > | wrap (GtkFontDialog *object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

A Gtk::FontDialog 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() method or its variants. This API follows the GIO async pattern, and the result can be obtained by calling the corresponding finish method, such as choose_font_finish().

See Gtk::FontDialogButton for a convenient control that uses Gtk::FontDialog and presents the results.

Since gtkmm 4.10

## Constructor & Destructor Documentation

## ◆ FontDialog() [1/2]

Gtk::FontDialog::FontDialog | ( | FontDialog && | src | ) |
| noexcept

## ◆ ~FontDialog()

Gtk::FontDialog::~FontDialog | ( |  | ) |
| overridenoexcept

## ◆ FontDialog() [2/2]

Gtk::FontDialog::FontDialog | ( |  | ) |
| protected

## Member Function Documentation

## ◆ choose_face() [1/2]

void Gtk::FontDialog::choose_face | ( | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Pango::FontFace > & | initial_value = {},
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} )

A choose_face() convenience overload.

## ◆ choose_face() [2/2]

void Gtk::FontDialog::choose_face | ( | Window & | parent,
|  | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Pango::FontFace > & | initial_value = {},
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} )

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 slot will be called when the dialog is dismissed. It should call choose_face_finish() to obtain the result.

Since gtkmm 4.10

Parameters

  parent | The parent `Gtk::Window`.
  initial_value | The initial value.
  cancellable | A `Cancellable` to cancel the operation.
  slot | A callback to call when the operation is complete.

## ◆ choose_face_finish()

Glib::RefPtr< Pango::FontFace > Gtk::FontDialog::choose_face_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |

Finishes the choose_face() call and returns the resulting font face.

Since gtkmm 4.10

Parameters

  result | A `Gio::AsyncResult`.

Returns
  The selected font face.

Exceptions

  Gtk::DialogError |

## ◆ choose_family() [1/2]

void Gtk::FontDialog::choose_family | ( | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Pango::FontFamily > & | initial_value = {},
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} )

A choose_family() convenience overload.

## ◆ choose_family() [2/2]

void Gtk::FontDialog::choose_family | ( | Window & | parent,
|  | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Pango::FontFamily > & | initial_value = {},
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} )

This function initiates a font selection operation by presenting a dialog to the user for selecting a font family.

The slot will be called when the dialog is dismissed. It should call choose_family_finish() to obtain the result.

Since gtkmm 4.10

Parameters

  parent | The parent `Gtk::Window`.
  initial_value | The initial value.
  cancellable | A `Cancellable` to cancel the operation.
  slot | A callback to call when the operation is complete.

## ◆ choose_family_finish()

Glib::RefPtr< Pango::FontFamily > Gtk::FontDialog::choose_family_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |

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 to choose_family() is returned.

Since gtkmm 4.10

Parameters

  result | A `Gio::AsyncResult`.

Returns
  The selected family.

Exceptions

  Gtk::DialogError |

## ◆ choose_font() [1/4]

void Gtk::FontDialog::choose_font | ( | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} ) const

A choose_font() convenience overload.

## ◆ choose_font() [2/4]

void Gtk::FontDialog::choose_font | ( | const Gio::SlotAsyncReady & | slot,
|  | const Pango::FontDescription & | initial_value,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} ) const

A choose_font() convenience overload.

## ◆ choose_font() [3/4]

void Gtk::FontDialog::choose_font | ( | Window & | parent,
|  | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} ) const

A choose_font() convenience overload.

## ◆ choose_font() [4/4]

void Gtk::FontDialog::choose_font | ( | Window & | parent,
|  | const Gio::SlotAsyncReady & | slot,
|  | const Pango::FontDescription & | initial_value,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} ) const

This function initiates a font selection operation by presenting a dialog to the user for selecting a font.

The slot will be called when the dialog is dismissed. It should call choose_font_finish() to obtain the result.

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

Since gtkmm 4.10

Parameters

  parent | The parent `Gtk::Window`.
  initial_value | The font to select initially.
  cancellable | A `Cancellable` to cancel the operation.
  slot | A callback to call when the operation is complete.

## ◆ choose_font_and_features() [1/4]

void Gtk::FontDialog::choose_font_and_features | ( | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} ) const

A choose_font_and_features() convenience overload.

## ◆ choose_font_and_features() [2/4]

void Gtk::FontDialog::choose_font_and_features | ( | const Gio::SlotAsyncReady & | slot,
|  | const Pango::FontDescription & | initial_value,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} ) const

A choose_font_and_features() convenience overload.

## ◆ choose_font_and_features() [3/4]

void Gtk::FontDialog::choose_font_and_features | ( | Window & | parent,
|  | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} ) const

A choose_font_and_features() convenience overload.

## ◆ choose_font_and_features() [4/4]

void Gtk::FontDialog::choose_font_and_features | ( | Window & | parent,
|  | const Gio::SlotAsyncReady & | slot,
|  | const Pango::FontDescription & | initial_value,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} ) const

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 slot will be called when the dialog is dismissed. It should call choose_font_and_features_finish() to obtain the result.

Since gtkmm 4.10

Parameters

  parent | The parent `Gtk::Window`.
  initial_value | The font to select initially.
  cancellable | A `Cancellable` to cancel the operation.
  slot | A callback to call when the operation is complete.

## ◆ choose_font_and_features_finish()

std::tuple< Pango::FontDescription, Glib::ustring, Pango::Language > Gtk::FontDialog::choose_font_and_features_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) | const

Finishes the choose_font_and_features() call and returns the resulting font description and font features.

You can use structured binding or std::tie() to get the return value.

auto [font_desc, font_features, language] =
font_dialog->choose_font_and_features_finish(result);
// or
Pango::FontDescription font_desc;
Glib::ustring font_features;
Pango::Language language;
std::tie(font_desc, font_features, language) =
font_dialog->choose_font_and_features_finish(result);
// or, if you don't need all return values, for instance
std::tie(font_desc, font_features, std::ignore) =
font_dialog->choose_font_and_features_finish(result);
std::tie
constexpr tuple< _Elements &... > tie(_Elements &... __args) noexcept
Pango::FontDescription
Pango::Language

Since gtkmm 4.10

Parameters

  result | A Gio::AsyncResult.

Returns
  {font_desc, font_features, language} A Pango::FontDescription, a Glib::ustring with font features, and a Pango::Language.

Exceptions

  Gtk::DialogError |

## ◆ choose_font_finish()

Pango::FontDescription Gtk::FontDialog::choose_font_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) | const

Finishes the choose_font() call and returns the resulting font description.

Since gtkmm 4.10

Parameters

  result | A `Gio::AsyncResult`.

Returns
  The selected font.

Exceptions

  Gtk::DialogError |

## ◆ create()

static Glib::RefPtr< FontDialog > Gtk::FontDialog::create | ( |  | ) |
| static

## ◆ get_filter() [1/2]

Glib::RefPtr< Filter > Gtk::FontDialog::get_filter | ( |  | ) |

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

Since gtkmm 4.10

Returns
  The filter.

## ◆ get_filter() [2/2]

Glib::RefPtr< const Filter > Gtk::FontDialog::get_filter | ( |  | ) | const

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

Since gtkmm 4.10

Returns
  The filter.

## ◆ get_font_map() [1/2]

Glib::RefPtr< Pango::FontMap > Gtk::FontDialog::get_font_map | ( |  | ) |

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

Since gtkmm 4.10

Returns
  The fontmap.

## ◆ get_font_map() [2/2]

Glib::RefPtr< const Pango::FontMap > Gtk::FontDialog::get_font_map | ( |  | ) | const

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

Since gtkmm 4.10

Returns
  The fontmap.

## ◆ get_language()

Pango::Language Gtk::FontDialog::get_language | ( |  | ) | const

Returns the language for which font features are applied.

Since gtkmm 4.10

Returns
  The language for font features.

## ◆ get_modal()

bool Gtk::FontDialog::get_modal | ( |  | ) | const

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

Since gtkmm 4.10

Returns
  `true` if the font chooser dialog is modal.

## ◆ get_title()

Glib::ustring Gtk::FontDialog::get_title | ( |  | ) | const

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

Since gtkmm 4.10

Returns
  The title.

## ◆ get_type()

static GType Gtk::FontDialog::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ gobj() [1/2]

GtkFontDialog * Gtk::FontDialog::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GtkFontDialog * Gtk::FontDialog::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ gobj_copy()

GtkFontDialog * Gtk::FontDialog::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

## ◆ operator=()

FontDialog & Gtk::FontDialog::operator= | ( | FontDialog && | src | ) |
| noexcept

## ◆ property_filter() [1/2]

Glib::PropertyProxy< Glib::RefPtr< Filter > > Gtk::FontDialog::property_filter | ( |  | ) |

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

Since gtkmm 4.10

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_filter() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Filter > > Gtk::FontDialog::property_filter | ( |  | ) | const

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

Since gtkmm 4.10

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_font_map() [1/2]

Glib::PropertyProxy< Glib::RefPtr< Pango::FontMap > > Gtk::FontDialog::property_font_map | ( |  | ) |

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.

Since gtkmm 4.10

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_font_map() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Pango::FontMap > > Gtk::FontDialog::property_font_map | ( |  | ) | const

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.

Since gtkmm 4.10

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_language() [1/2]

Glib::PropertyProxy< Pango::Language > Gtk::FontDialog::property_language | ( |  | ) |

The language for which the font features are selected.

Since gtkmm 4.10

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_language() [2/2]

Glib::PropertyProxy_ReadOnly< Pango::Language > Gtk::FontDialog::property_language | ( |  | ) | const

The language for which the font features are selected.

Since gtkmm 4.10

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_modal() [1/2]

Glib::PropertyProxy< bool > Gtk::FontDialog::property_modal | ( |  | ) |

Whether the font chooser dialog is modal.

Since gtkmm 4.10

Default value: `true`

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_modal() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::FontDialog::property_modal | ( |  | ) | const

Whether the font chooser dialog is modal.

Since gtkmm 4.10

Default value: `true`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_title() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::FontDialog::property_title | ( |  | ) |

A title that may be shown on the font chooser dialog that is presented by Gtk::FontDialog::choose_font().

Since gtkmm 4.10

Default value: ""

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_title() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FontDialog::property_title | ( |  | ) | const

A title that may be shown on the font chooser dialog that is presented by Gtk::FontDialog::choose_font().

Since gtkmm 4.10

Default value: ""

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ set_filter()

void Gtk::FontDialog::set_filter | ( | const Glib::RefPtr< Filter > & | filter | ) |

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

The `Gtk::Filter` must be able to handle both `Pango::FontFamily` and `Pango::FontFace` objects.

Since gtkmm 4.10

Parameters

  filter | A `Gtk::Filter`.

## ◆ set_font_map()

void Gtk::FontDialog::set_font_map | ( | const Glib::RefPtr< Pango::FontMap > & | fontmap | ) |

Sets the fontmap from which fonts are selected.

If fontmap is `nullptr`, the default fontmap is used.

Since gtkmm 4.10

Parameters

  fontmap | The fontmap.

## ◆ set_language()

void Gtk::FontDialog::set_language | ( | const Pango::Language & | language | ) |

Sets the language for which font features are applied.

Since gtkmm 4.10

Parameters

  language | The language for font features.

## ◆ set_modal()

void Gtk::FontDialog::set_modal | ( | bool | modal = true | ) |

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

Since gtkmm 4.10

Parameters

  modal | The new value.

## ◆ set_title()

void Gtk::FontDialog::set_title | ( | const Glib::ustring & | title | ) |

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

Since gtkmm 4.10

Parameters

  title | The new title.

## Friends And Related Symbol Documentation

## ◆ wrap()

Glib::RefPtr< Gtk::FontDialog > wrap | ( | GtkFontDialog * | object,
|  | bool | take_copy = false )
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.