gtk.font_chooser_mixin

Module for [FontChooser] interface mixin

Templates 2

tmplFontChooserT()

#GtkFontChooser is an interface that can be implemented by widgets displaying the list of fonts. In GTK+, the main objects that implement this interface are #GtkFontChooserWidget, #GtkFontChooserDialog and #GtkFontButton. The GtkFontChooser interface has been introducted in GTK+ 3.2.

Functions
string font()

Get font property.

Returns

The font description as a string, e.g. "Sans Italic 12".
void font(string propval)

Set font property.

Parameters

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

Get fontDesc property.

Returns

The font description as a #PangoFontDescription.

Set fontDesc property.

Parameters

propvalThe font description as a #PangoFontDescription.
string fontFeatures()

Get fontFeatures property.

Returns

The selected font features, in a format that is compatible with

CSS and with Pango attributes.

string language()

Get language property.

Returns

The language for which the #GtkFontChooser:font-features were

selected, in a format that is compatible with CSS and with Pango attributes.

void language(string propval)

Set language property.

Parameters

propvalThe language for which the #GtkFontChooser:font-features were selected, in a format that is compatible with CSS and with Pango attributes.

Get level property.

Returns

The level of granularity to offer for selecting fonts.
void level(gtk.types.FontChooserLevel propval)

Set level property.

Parameters

propvalThe level of granularity to offer for selecting fonts.
string previewText()

Get previewText property.

Returns

The string with which to preview the font.
void previewText(string propval)

Set previewText property.

Parameters

propvalThe string with which to preview the font.
bool showPreviewEntry()

Get showPreviewEntry property.

Returns

Whether to show an entry to change the preview text.
void showPreviewEntry(bool propval)

Set showPreviewEntry property.

Parameters

propvalWhether to show an entry to change the preview text.
string getFont()

Gets the currently-selected font name.

Note that this can be a different string than what you set with [gtk.font_chooser.FontChooser.setFont], 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.font_description.FontDescription.equal] if you want to compare two font descriptions.

Returns

A string with the name

of the current font, or null if no font is selected. You must free this string with [glib.global.gfree].

Gets the currently-selected font.

Note that this can be a different string than what you set with [gtk.font_chooser.FontChooser.setFont], 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.font_description.FontDescription.equal] if you want to compare two font descriptions.

Returns

A #PangoFontDescription for the

current font, or null if no font is selected.

Gets the #PangoFontFace representing the selected font group details (i.e. family, slant, weight, width, etc).

If the selected font is not installed, returns null.

Returns

A #PangoFontFace representing the

selected font group details, or null. The returned object is owned by fontchooser and must not be modified or freed.

Gets the #PangoFontFamily representing the selected font family. Font families are a collection of font faces.

If the selected font is not installed, returns null.

Returns

A #PangoFontFamily representing the

selected font family, or null. The returned object is owned by fontchooser and must not be modified or freed.

string getFontFeatures()

Gets the currently-selected font features.

Returns

the currently selected font features

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

Returns

a #PangoFontMap, or null
int getFontSize()

The selected font size.

Returns

A n integer representing the selected font size,

or -1 if no font size is selected.

string getLanguage()

Gets the language that is used for font features.

Returns

the currently selected language

Returns the current level of granularity for selecting fonts.

Returns

the current granularity level
string getPreviewText()

Gets the text displayed in the preview area.

Returns

the text displayed in the

preview area

bool getShowPreviewEntry()

Returns whether the preview entry is shown or not.

Returns

true if the preview entry is shown

or false if it is hidden.

void setFilterFunc(gtk.types.FontFilterFunc filter = null)

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

Parameters

filtera #GtkFontFilterFunc, or null
void setFont(string fontname)

Sets the currently-selected font.

Parameters

fontnamea font name like “Helvetica 12” or “Times Bold 18”
void setFontDesc(pango.font_description.FontDescription fontDesc)

Sets the currently-selected font from font_desc.

Parameters

fontDesca #PangoFontDescription
void setFontMap(pango.font_map.FontMap fontmap = null)

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);

Parameters

fontmapa #PangoFontMap
void setLanguage(string language)

Sets the language to use for font features.

Parameters

languagea language
void setLevel(gtk.types.FontChooserLevel level)

Sets the desired level of granularity for selecting fonts.

Parameters

levelthe desired level of granularity
void setPreviewText(string text)

Sets the text displayed in the preview area. The text is used to show how the selected font looks.

Parameters

textthe text to display in the preview area
void setShowPreviewEntry(bool showPreviewEntry)

Shows or hides the editable preview entry.

Parameters

showPreviewEntrywhether to show the editable preview entry or not
gulong connectFontActivated(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == string))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.font_chooser.FontChooser))) && Parameters!T.length < 3)

Connect to FontActivated signal.

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.

Parameters

callbacksignal callback delegate or function to connect void callback(string fontname, gtk.font_chooser.FontChooser fontChooser) fontname the font name (optional) fontChooser the instance the signal is connected to (optional)
afterYes.After to execute callback after default handler, No.After to execute before (default)

Returns

Signal ID
tmplFontChooserGidBuilderT()
Functions
T font(string propval)

Set font property.

Parameters

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

Returns

Builder instance for fluent chaining

Set fontDesc property.

Parameters

propvalThe font description as a #PangoFontDescription.

Returns

Builder instance for fluent chaining
T language(string propval)

Set language property.

Parameters

propvalThe language for which the #GtkFontChooser:font-features were selected, in a format that is compatible with CSS and with Pango attributes.

Returns

Builder instance for fluent chaining

Set level property.

Parameters

propvalThe level of granularity to offer for selecting fonts.

Returns

Builder instance for fluent chaining
T previewText(string propval)

Set previewText property.

Parameters

propvalThe string with which to preview the font.

Returns

Builder instance for fluent chaining
T showPreviewEntry(bool propval)

Set showPreviewEntry property.

Parameters

propvalWhether to show an entry to change the preview text.

Returns

Builder instance for fluent chaining