Gtk.FontChooser¶
- Implementations:
Gtk.FontButton
,Gtk.FontChooserDialog
,Gtk.FontChooserWidget
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
|
||
r/w |
|
||
r |
|
||
r/w/en |
|
||
r/w/en |
|
||
r/w |
|
||
r/w/en |
|
Signals¶
Name |
Short Description |
---|---|
Emitted when a font is activated. |
Fields¶
None
Class Details¶
- class Gtk.FontChooser¶
- Bases:
- Structure:
GtkFontChooser
is an interface that can be implemented by widgets for choosing fonts.In GTK, the main objects that implement this interface are [class`Gtk`.FontChooserWidget], [class`Gtk`.FontChooserDialog] and [class`Gtk`.FontButton].
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_font()[source]¶
-
Gets the currently-selected font name.
Note that this can be a different string than what you set with [method`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 [method`Pango`.FontDescription.equal] if you want to compare two font descriptions.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_font_desc()[source]¶
- Returns:
A
PangoFontDescription
for the current font- Return type:
Gets the currently-selected font.
Note that this can be a different string than what you set with [method`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 [method`Pango`.FontDescription.equal] if you want to compare two font descriptions.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_font_face()[source]¶
- Returns:
A
PangoFontFace
representing the selected font group details- Return type:
Gets the
PangoFontFace
representing the selected font group details (i.e. family, slant, weight, width, etc).If the selected font is not installed, returns
None
.Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_font_family()[source]¶
- Returns:
A
PangoFontFamily
representing the selected font family- Return type:
Gets the
PangoFontFamily
representing the selected font family.Font families are a collection of font faces.
If the selected font is not installed, returns
None
.Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_font_features()[source]¶
- Returns:
the currently selected font features
- Return type:
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 [func`Pango`.AttrFontFeatures.new].
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_font_map()[source]¶
- Returns:
a
PangoFontMap
- Return type:
Gets the custom font map of this font chooser widget, or
None
if it does not have one.Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- 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.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_language()[source]¶
- Returns:
the currently selected language
- Return type:
Gets the language that is used for font features.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_level()[source]¶
- Returns:
the current granularity level
- Return type:
Returns the current level of granularity for selecting fonts.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_preview_text()[source]¶
- Returns:
the text displayed in the preview area
- Return type:
Gets the text displayed in the preview area.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- get_show_preview_entry()[source]¶
-
Returns whether the preview entry is shown or not.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- set_filter_func(filter, *user_data)[source]¶
- Parameters:
filter (
Gtk.FontFilterFunc
orNone
) – aGtkFontFilterFunc
Adds a filter function that decides which fonts to display in the font chooser.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- set_font(fontname)[source]¶
- Parameters:
fontname (
str
) – a font name like “Helvetica 12” or “Times Bold 18”
Sets the currently-selected font.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- set_font_desc(font_desc)[source]¶
- Parameters:
font_desc (
Pango.FontDescription
) – aPangoFontDescription
Sets the currently-selected font from font_desc.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- set_font_map(fontmap)[source]¶
- Parameters:
fontmap (
Pango.FontMap
orNone
) – aPangoFontMap
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 FcConfig *config;
Pango.FontMap
*fontmap;config = FcInitLoadConfigAndFonts (); FcConfigAppFontAddFile (config, my_app_font_file);
fontmap =
PangoCairo.FontMap.new_for_font_type
(cairo.FontType.FT
); pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config);Gtk.FontChooser.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:
``c context = gtk_widget_get_pango_context (label); pango_context_set_font_map (context, fontmap); ``
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- set_language(language)[source]¶
- Parameters:
language (
str
) – a language
Sets the language to use for font features.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- set_level(level)[source]¶
- Parameters:
level (
Gtk.FontChooserLevel
) – the desired level of granularity
Sets the desired level of granularity for selecting fonts.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- 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.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- 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.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- do_get_font_face() virtual¶
- Returns:
A
PangoFontFace
representing the selected font group details- Return type:
Gets the
PangoFontFace
representing the selected font group details (i.e. family, slant, weight, width, etc).If the selected font is not installed, returns
None
.Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- do_get_font_family() virtual¶
- Returns:
A
PangoFontFamily
representing the selected font family- Return type:
Gets the
PangoFontFamily
representing the selected font family.Font families are a collection of font faces.
If the selected font is not installed, returns
None
.Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- do_get_font_map() virtual¶
- Returns:
a
PangoFontMap
- Return type:
Gets the custom font map of this font chooser widget, or
None
if it does not have one.Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- 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.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- do_set_filter_func(filter, *user_data) virtual¶
- Parameters:
filter (
Gtk.FontFilterFunc
orNone
) – aGtkFontFilterFunc
Adds a filter function that decides which fonts to display in the font chooser.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- do_set_font_map(fontmap) virtual¶
- Parameters:
fontmap (
Pango.FontMap
orNone
) – aPangoFontMap
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 FcConfig *config;
Pango.FontMap
*fontmap;config = FcInitLoadConfigAndFonts (); FcConfigAppFontAddFile (config, my_app_font_file);
fontmap =
PangoCairo.FontMap.new_for_font_type
(cairo.FontType.FT
); pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config);Gtk.FontChooser.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:
``c context = gtk_widget_get_pango_context (label); pango_context_set_font_map (context, fontmap); ``
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
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.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
Property Details¶
- Gtk.FontChooser.props.font¶
-
The font description as a string, e.g. “Sans Italic 12”.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- Gtk.FontChooser.props.font_desc¶
- Name:
font-desc
- Type:
- Default Value:
- Flags:
The font description as a
PangoFontDescription
.Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- Gtk.FontChooser.props.font_features¶
-
The selected font features.
The format of the string is compatible with CSS and with Pango attributes.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- Gtk.FontChooser.props.language¶
- Name:
language
- Type:
- Default Value:
''
- Flags:
The language for which the font features were selected.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- Gtk.FontChooser.props.level¶
- Name:
level
- Type:
- Default Value:
- Flags:
The level of granularity to offer for selecting fonts.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead
- 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.
Deprecated since version 4.10: Use [class`Gtk`.FontDialog] and [class`Gtk`.FontDialogButton] instead