## GtkFontChooserDialog

GtkFontChooserDialog — A dialog box for selecting fonts

## Synopsis

    #include <gtk/gtk.h>

    struct              GtkFontChooserDialog;
    GtkWidget *         gtk_font_chooser_dialog_new         (const gchar *title,
                                                             GtkWindow *window);
    GtkWidget *         gtk_font_chooser_dialog_get_font_chooser
                                                            (GtkFontChooserDialog *fcd);
    gchar *             gtk_font_chooser_dialog_get_font_name
                                                            (GtkFontChooserDialog *fcd);
    gboolean            gtk_font_chooser_dialog_set_font_name
                                                            (GtkFontChooserDialog *fcd,
                                                             const gchar *fontname);
    const gchar *       gtk_font_chooser_dialog_get_preview_text
                                                            (GtkFontChooserDialog *fcd);
    void                gtk_font_chooser_dialog_set_preview_text
                                                            (GtkFontChooserDialog *fcd,
                                                             const gchar *text);

## Description

The GtkFontChooserDialog widget is a dialog box for selecting a font.

To set the font which is initially selected, use `gtk_font_chooser_dialog_set_font_name()`.

To get the selected font use `gtk_font_chooser_dialog_get_font_name()`.

To change the text which is shown in the preview area, use `gtk_font_chooser_dialog_set_preview_text()`.

### GtkFontChooserDialog as GtkBuildable

The GtkFontChooserDialog implementation of the GtkBuildable interface exposes the embedded GtkFontChooser as internal child with the name "font_chooser". It also exposes the buttons with the names "select_button" and "cancel_button.

## Details

### struct GtkFontChooserDialog

    struct GtkFontChooserDialog {
      GtkDialog parent_instance;
    };

### gtk_font_chooser_dialog_new ()

    GtkWidget *         gtk_font_chooser_dialog_new         (const gchar *title,
                                                             GtkWindow *window);

### gtk_font_chooser_dialog_get_font_chooser ()

    GtkWidget *         gtk_font_chooser_dialog_get_font_chooser
                                                            (GtkFontChooserDialog *fcd);

Retrieves the GtkFontChooser widget embedded in the dialog.

`fcd` : | a GtkFontChooserDialog
Returns : | the embedded GtkFontChooser. [transfer none]

Since 3.2

### gtk_font_chooser_dialog_get_font_name ()

    gchar *             gtk_font_chooser_dialog_get_font_name
                                                            (GtkFontChooserDialog *fcd);

Gets the currently-selected font name.

Note that this can be a different string than what you set with `gtk_font_chooser_dialog_set_font_name()`, 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_equal()` if you want to compare two font descriptions.

`fcd` : | a GtkFontChooserDialog
Returns : | A string with the name of the current font, or `NULL` if no font is selected. You must free this string with `g_free()`.

Since 3.2

### gtk_font_chooser_dialog_set_font_name ()

    gboolean            gtk_font_chooser_dialog_set_font_name
                                                            (GtkFontChooserDialog *fcd,
                                                             const gchar *fontname);

Sets the currently selected font.

`fcd` : | a GtkFontChooserDialog
`fontname` : | a font name like "Helvetica 12" or "Times Bold 18"
Returns : | `TRUE` if the font selected in `fcd` is now the `fontname` specified, `FALSE` otherwise.

Since 3.2

### gtk_font_chooser_dialog_get_preview_text ()

    const gchar *       gtk_font_chooser_dialog_get_preview_text
                                                            (GtkFontChooserDialog *fcd);

Gets the text displayed in the preview area.

`fcd` : | a GtkFontChooserDialog
Returns : | the text displayed in the preview area. This string is owned by the widget and should not be modified or freed

Since 3.2

### gtk_font_chooser_dialog_set_preview_text ()

    void                gtk_font_chooser_dialog_set_preview_text
                                                            (GtkFontChooserDialog *fcd,
                                                             const gchar *text);

Sets the text displayed in the preview area.

`fcd` : | a GtkFontChooserDialog
`text` : | the text to display in the preview area

Since 3.2

## See Also

GtkFontChooser, GtkDialog