Next: , Previous: GtkFontButton, Up: Top

87 GtkFontSelection

A widget for selecting fonts

87.1 Overview

The <gtk-font-selection> widget lists the available fonts, styles and sizes, allowing the user to select a font. It is used in the <gtk-font-selection-dialog> widget to provide a dialog box for selecting fonts.

To set the font which is initially selected, use gtk-font-selection-set-font-name.

To get the selected font use gtk-font-selection-get-font-name.

To change the text which is shown in the preview area, use gtk-font-selection-set-preview-text.

87.2 Usage

— Class: <gtk-font-selection>

Derives from <gtk-vbox>.

This class defines the following slots:

The X string that represents this font
The GdkFont that is currently selected
The text to display in order to demonstrate the selected font
— Function: gtk-font-selection-new ⇒  (ret <gtk-widget>)

Creates a new <gtk-font-selection>.

a new <gtk-font-selection>.
— Function: gtk-font-selection-get-font-name (self <gtk-font-selection>) ⇒  (ret mchars)
— Method: get-font-name

Gets the currently-selected font name. Note that this can be a different string than what you set with gtk-font-selection-set-font-name, as the font selection 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-equal if you want to compare two font descriptions.

a <gtk-font-selection>
A string with the name of the current font, or #f if no font is selected. You must free this string with g-free.
— Function: gtk-font-selection-set-font-name (self <gtk-font-selection>) (fontname mchars) ⇒  (ret bool)
— Method: set-font-name

Sets the currently-selected font. Note that the fontsel needs to know the screen in which it will appear for this to work; this can be guaranteed by simply making sure that the fontsel is inserted in a toplevel window before you call this function.

a <gtk-font-selection>
a font name like "Helvetica 12" or "Times Bold 18"
#t if the font could be set successfully; #f if no such font exists or if the fontsel doesn't belong to a particular screen yet.
— Function: gtk-font-selection-get-preview-text (self <gtk-font-selection>) ⇒  (ret mchars)
— Method: get-preview-text

Gets the text displayed in the preview area.

a <gtk-font-selection>.
the text displayed in the preview area. This string is owned by the widget and should not be modified or freed.
— Function: gtk-font-selection-set-preview-text (self <gtk-font-selection>) (text mchars)
— Method: set-preview-text

Sets the text displayed in the preview area.

a <gtk-font-selection>.
the text to display in the preview area.