GtkFontButton: GTK+ 3 Reference Manual

## GtkFontButton GtkFontButton — A button to launch a font chooser dialog |

## Functions

GtkWidget * | gtk_font_button_new ()
GtkWidget * | gtk_font_button_new_with_font ()
gboolean | gtk_font_button_set_font_name ()
const gchar * | gtk_font_button_get_font_name ()
void | gtk_font_button_set_show_style ()
gboolean | gtk_font_button_get_show_style ()
void | gtk_font_button_set_show_size ()
gboolean | gtk_font_button_get_show_size ()
void | gtk_font_button_set_use_font ()
gboolean | gtk_font_button_get_use_font ()
void | gtk_font_button_set_use_size ()
gboolean | gtk_font_button_get_use_size ()
void | gtk_font_button_set_title ()
const gchar * | gtk_font_button_get_title ()

## Properties

char * | font-name | Read / Write
gboolean | show-size | Read / Write
gboolean | show-style | Read / Write
char * | title | Read / Write
gboolean | use-font | Read / Write
gboolean | use-size | Read / Write

## Signals

void | font-set | Run First

## Types and Values

struct | GtkFontButton

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GtkWidget
                ╰── GtkContainer
                    ╰── GtkBin
                        ╰── GtkButton
                            ╰── GtkFontButton

## Implemented Interfaces

GtkFontButton implements AtkImplementorIface, GtkBuildable, GtkActionable, GtkActivatable and GtkFontChooser.

## Includes

    #include <gtk/gtk.h>

## Description

The GtkFontButton is a button which displays the currently selected font an allows to open a font chooser dialog to change the font. It is suitable widget for selecting a font in a preference dialog.

### CSS nodes

GtkFontButton has a single CSS node with name button and style class .font.

## Functions

### gtk_font_button_new ()

    GtkWidget *
    gtk_font_button_new (void);

Creates a new font picker widget.

#### Returns

a new font picker widget.

Since: 2.4

### gtk_font_button_new_with_font ()

    GtkWidget *
    gtk_font_button_new_with_font (const gchar *fontname);

Creates a new font picker widget.

#### Parameters

fontname | Name of font to display in font chooser dialog |

#### Returns

a new font picker widget.

Since: 2.4

### gtk_font_button_set_font_name ()

    gboolean
    gtk_font_button_set_font_name (GtkFontButton *font_button,
                                   const gchar *fontname);

`gtk_font_button_set_font_name` has been deprecated since version 3.22 and should not be used in newly-written code.

Use `gtk_font_chooser_set_font()` instead

Sets or updates the currently-displayed font in font picker dialog.

#### Parameters

font_button | a GtkFontButton |
fontname | Name of font to display in font chooser dialog |

#### Returns

`TRUE`

Since: 2.4

### gtk_font_button_get_font_name ()

    const gchar *
    gtk_font_button_get_font_name (GtkFontButton *font_button);

`gtk_font_button_get_font_name` has been deprecated since version 3.22 and should not be used in newly-written code.

Use `gtk_font_chooser_get_font()` instead

Retrieves the name of the currently selected font. This name includes style and size information as well. If you want to render something with the font, use this string with `pango_font_description_from_string()` . If you’re interested in peeking certain values (family name, style, size, weight) just query these properties from the PangoFontDescription object.

#### Parameters

font_button | a GtkFontButton |

#### Returns

an internal copy of the font name which must not be freed.

Since: 2.4

### gtk_font_button_set_show_style ()

    void
    gtk_font_button_set_show_style (GtkFontButton *font_button,
                                    gboolean show_style);

If `show_style` is `TRUE`, the font style will be displayed along with name of the selected font.

#### Parameters

font_button | a GtkFontButton |
show_style | `TRUE` if font style should be displayed in label. |

Since: 2.4

### gtk_font_button_get_show_style ()

    gboolean
    gtk_font_button_get_show_style (GtkFontButton *font_button);

Returns whether the name of the font style will be shown in the label.

#### Parameters

font_button | a GtkFontButton |

#### Returns

whether the font style will be shown in the label.

Since: 2.4

### gtk_font_button_set_show_size ()

    void
    gtk_font_button_set_show_size (GtkFontButton *font_button,
                                   gboolean show_size);

If `show_size` is `TRUE`, the font size will be displayed along with the name of the selected font.

#### Parameters

font_button | a GtkFontButton |
show_size | `TRUE` if font size should be displayed in dialog. |

Since: 2.4

### gtk_font_button_get_show_size ()

    gboolean
    gtk_font_button_get_show_size (GtkFontButton *font_button);

Returns whether the font size will be shown in the label.

#### Parameters

font_button | a GtkFontButton |

#### Returns

whether the font size will be shown in the label.

Since: 2.4

### gtk_font_button_set_use_font ()

    void
    gtk_font_button_set_use_font (GtkFontButton *font_button,
                                  gboolean use_font);

If `use_font` is `TRUE`, the font name will be written using the selected font.

#### Parameters

font_button | a GtkFontButton |
use_font | If `TRUE`, font name will be written using font chosen. |

Since: 2.4

### gtk_font_button_get_use_font ()

    gboolean
    gtk_font_button_get_use_font (GtkFontButton *font_button);

Returns whether the selected font is used in the label.

#### Parameters

font_button | a GtkFontButton |

#### Returns

whether the selected font is used in the label.

Since: 2.4

### gtk_font_button_set_use_size ()

    void
    gtk_font_button_set_use_size (GtkFontButton *font_button,
                                  gboolean use_size);

If `use_size` is `TRUE`, the font name will be written using the selected size.

#### Parameters

font_button | a GtkFontButton |
use_size | If `TRUE`, font name will be written using the selected size. |

Since: 2.4

### gtk_font_button_get_use_size ()

    gboolean
    gtk_font_button_get_use_size (GtkFontButton *font_button);

Returns whether the selected size is used in the label.

#### Parameters

font_button | a GtkFontButton |

#### Returns

whether the selected size is used in the label.

Since: 2.4

### gtk_font_button_set_title ()

    void
    gtk_font_button_set_title (GtkFontButton *font_button,
                               const gchar *title);

Sets the title for the font chooser dialog.

#### Parameters

font_button | a GtkFontButton |
title | a string containing the font chooser dialog title |

Since: 2.4

### gtk_font_button_get_title ()

    const gchar *
    gtk_font_button_get_title (GtkFontButton *font_button);

Retrieves the title of the font chooser dialog.

#### Parameters

font_button | a GtkFontButton |

#### Returns

an internal copy of the title string which must not be freed.

Since: 2.4

## Types and Values

### struct GtkFontButton

    struct GtkFontButton;

## Property Details

### The `“font-name”` property

      “font-name”                char *

The name of the currently selected font.

`GtkFontButton:font-name` has been deprecated since version 3.22 and should not be used in newly-written code.

Use the “font” property instead

Owner: GtkFontButton

Flags: Read / Write

Default value: "Sans 12"

Since: 2.4

### The `“show-size”` property

      “show-size”                gboolean

If this property is set to `TRUE`, the selected font size will be shown in the label. For a more WYSIWYG way to show the selected size, see the ::use-size property.

Owner: GtkFontButton

Flags: Read / Write

Default value: TRUE

Since: 2.4

### The `“show-style”` property

      “show-style”               gboolean

If this property is set to `TRUE`, the name of the selected font style will be shown in the label. For a more WYSIWYG way to show the selected style, see the ::use-font property.

Owner: GtkFontButton

Flags: Read / Write

Default value: TRUE

Since: 2.4

### The `“title”` property

      “title”                    char *

The title of the font chooser dialog.

Owner: GtkFontButton

Flags: Read / Write

Default value: "Pick a Font"

Since: 2.4

### The `“use-font”` property

      “use-font”                 gboolean

If this property is set to `TRUE`, the label will be drawn in the selected font.

Owner: GtkFontButton

Flags: Read / Write

Default value: FALSE

Since: 2.4

### The `“use-size”` property

      “use-size”                 gboolean

If this property is set to `TRUE`, the label will be drawn with the selected font size.

Owner: GtkFontButton

Flags: Read / Write

Default value: FALSE

Since: 2.4

## Signal Details

### The `“font-set”` signal

    void
    user_function (GtkFontButton *widget,
                   gpointer       user_data)

The ::font-set signal is emitted when the user selects a font. When handling this signal, use `gtk_font_chooser_get_font()` to find out which font was just selected.

Note that this signal is only emitted when the user changes the font. If you need to react to programmatic font changes as well, use the notify::font signal.

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

Since: 2.4

## See Also

GtkFontChooserDialog, GtkColorButton.