Gtk.FontChooser¶
- Implementations:
Gtk.FontButton,Gtk.FontChooserDialog,Gtk.FontChooserWidget
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w |
Font description as a string, e.g. “Sans Italic 12” |
||
r/w |
Font description as a |
||
r |
Font features as a string |
||
r/w/en |
Language for which features have been selected |
||
r/w/en |
Whether to select family, face or font |
||
r/w |
The text to display in order to demonstrate the selected font |
||
r/w/en |
Whether the preview text entry is shown or not |
Signals¶
Name |
Short Description |
|---|---|
Emitted when a font is activated. |
Fields¶
None
Class Details¶
- class Gtk.FontChooser¶
- Bases:
- Structure:
Gtk.FontChooseris an interface that can be implemented by widgets displaying the list of fonts. In GTK+, the main objects that implement this interface areGtk.FontChooserWidget,Gtk.FontChooserDialogandGtk.FontButton. TheGtk.FontChooserinterface has been introducted in GTK+ 3.2.- get_font()[source]¶
- Returns:
A string with the name of the current font, or
Noneif no font is selected. You must free this string withGLib.free().- Return type:
Gets the currently-selected font name.
Note that this can be a different string than what you set with
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
Pango.FontDescription.equal() if you want to compare two font descriptions.New in version 3.2.
- get_font_desc()[source]¶
- Returns:
A
Pango.FontDescriptionfor the current font, orNoneif no font is selected.- Return type:
Gets the currently-selected font.
Note that this can be a different string than what you set with
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
Pango.FontDescription.equal() if you want to compare two font descriptions.New in version 3.2.
- get_font_face()[source]¶
- Returns:
A
Pango.FontFacerepresenting the selected font group details, orNone. The returned object is owned by self and must not be modified or freed.- Return type:
Gets the
Pango.FontFacerepresenting the selected font group details (i.e. family, slant, weight, width, etc).If the selected font is not installed, returns
None.New in version 3.2.
- get_font_family()[source]¶
- Returns:
A
Pango.FontFamilyrepresenting the selected font family, orNone. The returned object is owned by self and must not be modified or freed.- Return type:
Gets the
Pango.FontFamilyrepresenting the selected font family. Font families are a collection of font faces.If the selected font is not installed, returns
None.New in version 3.2.
- get_font_features()[source]¶
- Returns:
the currently selected font features
- Return type:
Gets the currently-selected font features.
New in version 3.24.
- get_font_map()[source]¶
- Returns:
a
Pango.FontMap, orNone- Return type:
Gets the custom font map of this font chooser widget, or
Noneif it does not have one.New in version 3.18.
- get_font_size()[source]¶
- Returns:
A n integer representing the selected font size, or -1 if no font size is selected.
- Return type:
The selected font size.
New in version 3.2.
- get_language()[source]¶
- Returns:
the currently selected language
- Return type:
Gets the language that is used for font features.
New in version 3.24.
- get_level()[source]¶
- Returns:
the current granularity level
- Return type:
Returns the current level of granularity for selecting fonts.
New in version 3.24.
- get_preview_text()[source]¶
- Returns:
the text displayed in the preview area
- Return type:
Gets the text displayed in the preview area.
New in version 3.2.
- get_show_preview_entry()[source]¶
-
Returns whether the preview entry is shown or not.
New in version 3.2.
- set_filter_func(filter, *user_data)[source]¶
- Parameters:
filter (
Gtk.FontFilterFuncorNone) – aGtk.FontFilterFunc, orNone
Adds a filter function that decides which fonts to display in the font chooser.
New in version 3.2.
- set_font(fontname)[source]¶
- Parameters:
fontname (
str) – a font name like “Helvetica 12” or “Times Bold 18”
Sets the currently-selected font.
New in version 3.2.
- set_font_desc(font_desc)[source]¶
- Parameters:
font_desc (
Pango.FontDescription) – aPango.FontDescription
Sets the currently-selected font from font_desc.
New in version 3.2.
- set_font_map(fontmap)[source]¶
- Parameters:
fontmap (
Pango.FontMaporNone) – aPango.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.
FcConfig *config; PangoFontMap *fontmap; config = FcInitLoadConfigAndFonts (); FcConfigAppFontAddFile (config, my_app_font_file); fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT); pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config); gtk_font_chooser_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:
context = gtk_widget_get_pango_context (label); pango_context_set_font_map (context, fontmap);
New in version 3.18.
- set_language(language)[source]¶
- Parameters:
language (
str) – a language
Sets the language to use for font features.
New in version 3.24.
- set_level(level)[source]¶
- Parameters:
level (
Gtk.FontChooserLevel) – the desired level of granularity
Sets the desired level of granularity for selecting fonts.
New in version 3.24.
- 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.
New in version 3.2.
- 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.
New in version 3.2.
- do_get_font_face() virtual¶
- Returns:
A
Pango.FontFacerepresenting the selected font group details, orNone. The returned object is owned by fontchooser and must not be modified or freed.- Return type:
Gets the
Pango.FontFacerepresenting the selected font group details (i.e. family, slant, weight, width, etc).If the selected font is not installed, returns
None.New in version 3.2.
- do_get_font_family() virtual¶
- Returns:
A
Pango.FontFamilyrepresenting the selected font family, orNone. The returned object is owned by fontchooser and must not be modified or freed.- Return type:
Gets the
Pango.FontFamilyrepresenting the selected font family. Font families are a collection of font faces.If the selected font is not installed, returns
None.New in version 3.2.
- do_get_font_map() virtual¶
- Returns:
a
Pango.FontMap, orNone- Return type:
Gets the custom font map of this font chooser widget, or
Noneif it does not have one.New in version 3.18.
- do_get_font_size() virtual¶
- Returns:
A n integer representing the selected font size, or -1 if no font size is selected.
- Return type:
The selected font size.
New in version 3.2.
- do_set_filter_func(filter, *user_data) virtual¶
- Parameters:
filter (
Gtk.FontFilterFuncorNone) – aGtk.FontFilterFunc, orNone
Adds a filter function that decides which fonts to display in the font chooser.
New in version 3.2.
- do_set_font_map(fontmap) virtual¶
- Parameters:
fontmap (
Pango.FontMaporNone) – aPango.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.
FcConfig *config; PangoFontMap *fontmap; config = FcInitLoadConfigAndFonts (); FcConfigAppFontAddFile (config, my_app_font_file); fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT); pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config); gtk_font_chooser_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:
context = gtk_widget_get_pango_context (label); pango_context_set_font_map (context, fontmap);
New in version 3.18.
Signal Details¶
- Gtk.FontChooser.signals.font_activated(font_chooser, fontname)¶
- Signal Name:
font-activated- Flags:
- Parameters:
font_chooser (
Gtk.FontChooser) – The object which received the signalfontname (
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.
Property Details¶
- Gtk.FontChooser.props.font¶
-
The font description as a string, e.g. “Sans Italic 12”.
- Gtk.FontChooser.props.font_desc¶
- Name:
font-desc- Type:
- Default Value:
- Flags:
The font description as a
Pango.FontDescription.
- Gtk.FontChooser.props.font_features¶
-
The selected font features, in a format that is compatible with CSS and with Pango attributes.
New in version 3.24.1.
- Gtk.FontChooser.props.language¶
- Name:
language- Type:
- Default Value:
''- Flags:
The language for which the
Gtk.FontChooser:font-featureswere selected, in a format that is compatible with CSS and with Pango attributes.New in version 3.24.1.
- Gtk.FontChooser.props.level¶
- Name:
level- Type:
- Default Value:
- Flags:
The level of granularity to offer for selecting fonts.
New in version 3.24.1.
- Gtk.FontChooser.props.preview_text¶
- Name:
preview-text- Type:
- Default Value:
'The quick brown fox jumps over the lazy dog.'- Flags:
The string with which to preview the font.