A widget for selecting fonts
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
.
Derives from
<gtk-vbox>
.This class defines the following slots:
font-name
- The X string that represents this font
font
- The GdkFont that is currently selected
preview-text
- The text to display in order to demonstrate the selected font
<gtk-widget>
)Creates a new
<gtk-font-selection>
.
- ret
- a new
<gtk-font-selection>
.
<gtk-font-selection>
) ⇒ (ret mchars
)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". Usepango-font-description-equal
if you want to compare two font descriptions.
- fontsel
- a
<gtk-font-selection>
- ret
- A string with the name of the current font, or
#f
if no font is selected. You must free this string withg-free
.
<gtk-font-selection>
) (fontname mchars
) ⇒ (ret bool
)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.
- fontsel
- a
<gtk-font-selection>
- fontname
- a font name like "Helvetica 12" or "Times Bold 18"
- ret
#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.
<gtk-font-selection>
) ⇒ (ret mchars
)Gets the text displayed in the preview area.
- fontsel
- a
<gtk-font-selection>
.- ret
- the text displayed in the preview area. This string is owned by the widget and should not be modified or freed.