gtkmm 4.14.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Related Symbols | List of all members
Gtk::FontChooser Class Reference

An interface implemented by widgets displaying fonts. More...

#include <gtkmm/fontchooser.h>

Inheritance diagram for Gtk::FontChooser:
Inheritance graph
[legend]

Public Types

enum class  Level {
  Level::FAMILY = 0x0 ,
  Level::STYLE = 1 << 0 ,
  Level::SIZE = 1 << 1 ,
  Level::VARIATIONS = 1 << 2 ,
  Level::FEATURES = 1 << 3
}
 Specifies the granularity of font selection that is desired in a Gtk::FontChooser. More...
 
typedef sigc::slot< bool(const Glib::RefPtr< const Pango::FontFamily > &, const Glib::RefPtr< const Pango::FontFace > &) SlotFontFilter)
 Font filter callback.
 

Public Member Functions

 FontChooser (FontChooser &&src) noexcept
 
FontChooseroperator= (FontChooser &&src) noexcept
 
 ~FontChooser () noexcept override
 
GtkFontChoosergobj ()
 Provides access to the underlying C GObject.
 
const GtkFontChoosergobj () const
 Provides access to the underlying C GObject.
 
Glib::RefPtr< Pango::FontFamily > get_font_family ()
 Gets the Pango::FontFamily representing the selected font family.
 
Glib::RefPtr< const Pango::FontFamily > get_font_family () const
 Gets the Pango::FontFamily representing the selected font family.
 
Glib::RefPtr< Pango::FontFace > get_font_face ()
 Gets the Pango::FontFace representing the selected font group details (i.e. family, slant, weight, width, etc).
 
Glib::RefPtr< const Pango::FontFace > get_font_face () const
 Gets the Pango::FontFace representing the selected font group details (i.e. family, slant, weight, width, etc).
 
int get_font_size () const
 The selected font size.
 
Pango::FontDescription get_font_desc () const
 Gets the currently-selected font.
 
void set_font_desc (const Pango::FontDescription &font_desc)
 Sets the currently-selected font from font_desc.
 
Glib::ustring get_font () const
 Gets the currently-selected font name.
 
void set_font (const Glib::ustring &fontname)
 Sets the currently-selected font.
 
Glib::ustring get_preview_text () const
 Gets the text displayed in the preview area.
 
void set_preview_text (const Glib::ustring &text)
 Sets the text displayed in the preview area.
 
bool get_show_preview_entry () const
 Returns whether the preview entry is shown or not.
 
void set_show_preview_entry (bool show_preview_entry=true)
 Shows or hides the editable preview entry.
 
void set_filter_func (const SlotFontFilter &slot)
 Adds a filter function that decides which fonts to display in the font chooser.
 
void set_font_map (const Glib::RefPtr< Pango::FontMap > &fontmap)
 Sets a custom font map to use for this font chooser widget.
 
Glib::RefPtr< Pango::FontMap > get_font_map ()
 Gets the custom font map of this font chooser widget, or nullptr if it does not have one.
 
Glib::RefPtr< const Pango::FontMap > get_font_map () const
 Gets the custom font map of this font chooser widget, or nullptr if it does not have one.
 
void set_level (Level level)
 Sets the desired level of granularity for selecting fonts.
 
Level get_level () const
 Returns the current level of granularity for selecting fonts.
 
Glib::ustring get_font_features () const
 Gets the currently-selected font features.
 
Glib::ustring get_language () const
 Gets the language that is used for font features.
 
void set_language (const Glib::ustring &language)
 Sets the language to use for font features.
 
Glib::PropertyProxy< Glib::ustring > property_font ()
 The font description as a string, e.g. "Sans Italic 12".
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_font () const
 The font description as a string, e.g. "Sans Italic 12".
 
Glib::PropertyProxy< Pango::FontDescription > property_font_desc ()
 The font description as a Pango::FontDescription.
 
Glib::PropertyProxy_ReadOnly< Pango::FontDescription > property_font_desc () const
 The font description as a Pango::FontDescription.
 
Glib::PropertyProxy< Glib::ustring > property_preview_text ()
 The string with which to preview the font.
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_preview_text () const
 The string with which to preview the font.
 
Glib::PropertyProxy< bool > property_show_preview_entry ()
 Whether to show an entry to change the preview text.
 
Glib::PropertyProxy_ReadOnly< bool > property_show_preview_entry () const
 Whether to show an entry to change the preview text.
 
Glib::PropertyProxy< Levelproperty_level ()
 The level of granularity to offer for selecting fonts.
 
Glib::PropertyProxy_ReadOnly< Levelproperty_level () const
 The level of granularity to offer for selecting fonts.
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_font_features () const
 The selected font features.
 
Glib::PropertyProxy< Glib::ustring > property_language ()
 The language for which the font features were selected.
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_language () const
 The language for which the font features were selected.
 

Static Public Member Functions

static void add_interface (GType gtype_implementer)
 
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 

Public Attributes

Glib::SignalProxy< void(const Glib::ustring &) signal_font_activated )()
 

Protected Member Functions

 FontChooser ()
 You should derive from this class to use it.
 
virtual void on_font_activated (const Glib::ustring &fontname)
 This is a default handler for the signal signal_font_activated().
 

Related Symbols

(Note that these are not member symbols.)

Glib::RefPtr< Gtk::FontChooserwrap (GtkFontChooser *object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Detailed Description

An interface implemented by widgets displaying fonts.

FontChooser widgets list the available fonts, styles and sizes, allowing the user to select a font.

To set the font which is initially selected, use set_font_name().

To get the selected font use get_font_name().

To change the text which is shown in the preview area, use set_preview_text().

Since gtkmm 3.2
Deprecated
4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead.

Member Typedef Documentation

◆ SlotFontFilter

typedef sigc::slot<bool(const Glib::RefPtr<const Pango::FontFamily>&, const Glib::RefPtr<const Pango::FontFace>&) Gtk::FontChooser::SlotFontFilter)

Font filter callback.

For instance,

bool on_font_fitler(const Glib::RefPtr<const Pango::FontFamily>& font_family, const Glib::RefPtr<const Pango::FontFace>& font_face);
auto make_managed(T_Args &&... args)
Create a Gtk::Object such as a widget and Gtk::manage() it in a single step.
Definition object.h:68
Parameters
font_familyA Pango FontFamily.
font_faceA Font Face belonging to the font_family.
Returns
true if the font should be displayed.

This is used for deciding what fonts should be shown in a FontChooser. See set_filter_func().

Since gtkmm 3.4

Constructor & Destructor Documentation

◆ FontChooser() [1/2]

Gtk::FontChooser::FontChooser ( )
protected

You should derive from this class to use it.

◆ FontChooser() [2/2]

Gtk::FontChooser::FontChooser ( FontChooser && src)
noexcept

◆ ~FontChooser()

Gtk::FontChooser::~FontChooser ( )
overridenoexcept

Member Function Documentation

◆ add_interface()

static void Gtk::FontChooser::add_interface ( GType gtype_implementer)
static

◆ get_font()

Glib::ustring Gtk::FontChooser::get_font ( ) const

Gets the currently-selected font name.

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

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
A string with the name of the current font.

◆ get_font_desc()

Pango::FontDescription Gtk::FontChooser::get_font_desc ( ) const

Gets the currently-selected font.

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

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
A Pango::FontDescription for the current font.

◆ get_font_face() [1/2]

Glib::RefPtr< Pango::FontFace > Gtk::FontChooser::get_font_face ( )

Gets the Pango::FontFace representing the selected font group details (i.e. family, slant, weight, width, etc).

If the selected font is not installed, returns nullptr.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
A Pango::FontFace representing the selected font group details.

◆ get_font_face() [2/2]

Glib::RefPtr< const Pango::FontFace > Gtk::FontChooser::get_font_face ( ) const

Gets the Pango::FontFace representing the selected font group details (i.e. family, slant, weight, width, etc).

If the selected font is not installed, returns nullptr.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
A Pango::FontFace representing the selected font group details.

◆ get_font_family() [1/2]

Glib::RefPtr< Pango::FontFamily > Gtk::FontChooser::get_font_family ( )

Gets the Pango::FontFamily representing the selected font family.

Font families are a collection of font faces.

If the selected font is not installed, returns nullptr.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
A Pango::FontFamily representing the selected font family.

◆ get_font_family() [2/2]

Glib::RefPtr< const Pango::FontFamily > Gtk::FontChooser::get_font_family ( ) const

Gets the Pango::FontFamily representing the selected font family.

Font families are a collection of font faces.

If the selected font is not installed, returns nullptr.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
A Pango::FontFamily representing the selected font family.

◆ get_font_features()

Glib::ustring Gtk::FontChooser::get_font_features ( ) const

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 pango_attr_font_features_new().

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
The currently selected font features.

◆ get_font_map() [1/2]

Glib::RefPtr< Pango::FontMap > Gtk::FontChooser::get_font_map ( )

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

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
A Pango::FontMap.

◆ get_font_map() [2/2]

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

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

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
A Pango::FontMap.

◆ get_font_size()

int Gtk::FontChooser::get_font_size ( ) const

The selected font size.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

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

◆ get_language()

Glib::ustring Gtk::FontChooser::get_language ( ) const

Gets the language that is used for font features.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
The currently selected language.

◆ get_level()

Level Gtk::FontChooser::get_level ( ) const

Returns the current level of granularity for selecting fonts.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
The current granularity level.

◆ get_preview_text()

Glib::ustring Gtk::FontChooser::get_preview_text ( ) const

Gets the text displayed in the preview area.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
The text displayed in the preview area.

◆ get_show_preview_entry()

bool Gtk::FontChooser::get_show_preview_entry ( ) const

Returns whether the preview entry is shown or not.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Returns
true if the preview entry is shown or false if it is hidden.

◆ get_type()

static GType Gtk::FontChooser::get_type ( )
static

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

◆ gobj() [1/2]

GtkFontChooser * Gtk::FontChooser::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkFontChooser * Gtk::FontChooser::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ on_font_activated()

virtual void Gtk::FontChooser::on_font_activated ( const Glib::ustring & fontname)
protectedvirtual

This is a default handler for the signal signal_font_activated().

◆ operator=()

FontChooser & Gtk::FontChooser::operator= ( FontChooser && src)
noexcept

◆ property_font() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::FontChooser::property_font ( )

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

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Default value: "Sans 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() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FontChooser::property_font ( ) const

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

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Default value: "Sans 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_desc() [1/2]

Glib::PropertyProxy< Pango::FontDescription > Gtk::FontChooser::property_font_desc ( )

The font description as a Pango::FontDescription.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

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_desc() [2/2]

Glib::PropertyProxy_ReadOnly< Pango::FontDescription > Gtk::FontChooser::property_font_desc ( ) const

The font description as a Pango::FontDescription.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

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_features()

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FontChooser::property_font_features ( ) const

The selected font features.

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

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

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.

◆ property_language() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::FontChooser::property_language ( )

The language for which the font features were selected.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

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_language() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FontChooser::property_language ( ) const

The language for which the font features were selected.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

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.

◆ property_level() [1/2]

Glib::PropertyProxy< Level > Gtk::FontChooser::property_level ( )

The level of granularity to offer for selecting fonts.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Default value: Gtk::FontChooser::Level::STYLE | Gtk::FontChooser::Level::SIZE

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_level() [2/2]

Glib::PropertyProxy_ReadOnly< Level > Gtk::FontChooser::property_level ( ) const

The level of granularity to offer for selecting fonts.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Default value: Gtk::FontChooser::Level::STYLE | Gtk::FontChooser::Level::SIZE

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_preview_text() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::FontChooser::property_preview_text ( )

The string with which to preview the font.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Default value: "The quick brown fox jumps over the lazy dog."

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_preview_text() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FontChooser::property_preview_text ( ) const

The string with which to preview the font.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Default value: "The quick brown fox jumps over the lazy dog."

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_show_preview_entry() [1/2]

Glib::PropertyProxy< bool > Gtk::FontChooser::property_show_preview_entry ( )

Whether to show an entry to change the preview text.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

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_show_preview_entry() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::FontChooser::property_show_preview_entry ( ) const

Whether to show an entry to change the preview text.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

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.

◆ set_filter_func()

void Gtk::FontChooser::set_filter_func ( const SlotFontFilter & slot)

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

Parameters
slotA callback, to be called for each font.
Since gtkmm 3.4

◆ set_font()

void Gtk::FontChooser::set_font ( const Glib::ustring & fontname)

Sets the currently-selected font.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Parameters
fontnameA font name like “Helvetica 12” or “Times Bold 18”.

◆ set_font_desc()

void Gtk::FontChooser::set_font_desc ( const Pango::FontDescription & font_desc)

Sets the currently-selected font from font_desc.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Parameters
font_descA Pango::FontDescription.

◆ set_font_map()

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

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 example ellipted]

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 example ellipted]

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Parameters
fontmapA Pango::FontMap.

◆ set_language()

void Gtk::FontChooser::set_language ( const Glib::ustring & language)

Sets the language to use for font features.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Parameters
languageA language.

◆ set_level()

void Gtk::FontChooser::set_level ( Level level)

Sets the desired level of granularity for selecting fonts.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Parameters
levelThe desired level of granularity.

◆ set_preview_text()

void Gtk::FontChooser::set_preview_text ( const Glib::ustring & text)

Sets the text displayed in the preview area.

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

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Parameters
textThe text to display in the preview area.

◆ set_show_preview_entry()

void Gtk::FontChooser::set_show_preview_entry ( bool show_preview_entry = true)

Shows or hides the editable preview entry.

Deprecated: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Parameters
show_preview_entryWhether to show the editable preview entry or not.

Friends And Related Symbol Documentation

◆ wrap()

Glib::RefPtr< Gtk::FontChooser > wrap ( GtkFontChooser * object,
bool take_copy = false )
related

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

Parameters
objectThe C instance.
take_copyFalse 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.

Member Data Documentation

◆ signal_font_activated

Glib::SignalProxy< void(const Glib::ustring &) Gtk::FontChooser::signal_font_activated) ()
Slot Prototype:
void on_my_font_activated(const Glib::ustring& fontname)

Flags: Run First

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: 4.10: Use Gtk::FontDialog and Gtk::FontDialogButton instead

Parameters
fontnameThe font name.