Gtk.Font_Chooser

Entities

Simple Types

Access Types

Subtypes

Constants

Subprograms

Generic Instantiations

Description

Gtk.Font_Chooser.Gtk_Font_Chooser is an interface that can be implemented by widgets displaying the list of fonts. In GTK+, the main objects that implement this interface are Gtk.Font_Chooser_Widget.Gtk_Font_Chooser_Widget, Gtk.Font_Chooser_Dialog.Gtk_Font_Chooser_Dialog and Gtk.Font_Button.Gtk_Font_Button. The GtkFontChooser interface has been introducted in GTK+ 3.2.

"+"

function "+" (W : Gtk_Font_Chooser) return Gtk_Font_Chooser
Parameters
W
Return Value

Cb_GObject_UTF8_String_Void

type Cb_GObject_UTF8_String_Void is not null access procedure
  (Self     : access Glib.Object.GObject_Record'Class;
   Fontname : UTF8_String);
Parameters
Self
Fontname

Cb_Gtk_Font_Chooser_UTF8_String_Void

type Cb_Gtk_Font_Chooser_UTF8_String_Void is not null access procedure
  (Self     : Gtk_Font_Chooser;
   Fontname : UTF8_String);
Parameters
Self
Fontname

Font_Chooser_Interface_Descr

subtype Font_Chooser_Interface_Descr is Glib.Object.Interface_Description;

Font_Chooser_Level_Family

Font_Chooser_Level_Family : constant Gtk_Font_Chooser_Level := 0;

Font_Chooser_Level_Features

Font_Chooser_Level_Features : constant Gtk_Font_Chooser_Level := 8;

Font_Chooser_Level_Size

Font_Chooser_Level_Size : constant Gtk_Font_Chooser_Level := 2;

Font_Chooser_Level_Style

Font_Chooser_Level_Style : constant Gtk_Font_Chooser_Level := 1;

Font_Chooser_Level_Variations

Font_Chooser_Level_Variations : constant Gtk_Font_Chooser_Level := 4;

Font_Desc_Property

Font_Desc_Property : constant Pango.Font.Property_Font_Description;

Type: Pango.Font.Pango_Font_Description The font description as a Pango.Font.Pango_Font_Description.

Font_Features_Property

Font_Features_Property : constant Glib.Properties.Property_String;

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

Font_Property

Font_Property : constant Glib.Properties.Property_String;

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

Get_Font

function Get_Font (Self : Gtk_Font_Chooser) return UTF8_String

Gets the currently-selected font name. Note that this can be a different string than what you set with Gtk.Font_Chooser.Set_Font, 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.Equal if you want to compare two font descriptions. Since: gtk+ 3.2

Parameters
Self
Return Value

A string with the name of the current font, or null if no font is selected. You must free this string with g_free.

Get_Font_Desc

function Get_Font_Desc
   (Self : Gtk_Font_Chooser) return Pango.Font.Pango_Font_Description

Gets the currently-selected font. Note that this can be a different string than what you set with Gtk.Font_Chooser.Set_Font, 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.Equal if you want to compare two font descriptions. Since: gtk+ 3.2

Parameters
Self
Return Value

A Pango.Font.Pango_Font_Description for the current font, or null if no font is selected.

Get_Font_Face

function Get_Font_Face
   (Self : Gtk_Font_Chooser) return Pango.Font_Face.Pango_Font_Face

Gets the Pango.Font_Face.Pango_Font_Face representing the selected font group details (i.e. family, slant, weight, width, etc). If the selected font is not installed, returns null. Since: gtk+ 3.2

Parameters
Self
Return Value

A Pango.Font_Face.Pango_Font_Face representing the selected font group details, or null. The returned object is owned by Fontchooser and must not be modified or freed.

Get_Font_Family

function Get_Font_Family
   (Self : Gtk_Font_Chooser) return Pango.Font_Family.Pango_Font_Family

Gets the Pango.Font_Family.Pango_Font_Family representing the selected font family. Font families are a collection of font faces. If the selected font is not installed, returns null. Since: gtk+ 3.2

Parameters
Self
Return Value

A Pango.Font_Family.Pango_Font_Family representing the selected font family, or null. The returned object is owned by Fontchooser and must not be modified or freed.

Get_Font_Features

function Get_Font_Features (Self : Gtk_Font_Chooser) return UTF8_String

Gets the currently-selected font features. Since: gtk+ 3.24

Parameters
Self
Return Value

the currently selected font features

Get_Font_Map

function Get_Font_Map
   (Self : Gtk_Font_Chooser) return Pango.Font_Map.Pango_Font_Map

Gets the custom font map of this font chooser widget, or null if it does not have one. Since: gtk+ 3.18

Parameters
Self
Return Value

a Pango.Font_Map.Pango_Font_Map, or null

Get_Font_Size

function Get_Font_Size (Self : Gtk_Font_Chooser) return Glib.Gint

The selected font size. Since: gtk+ 3.2

Parameters
Self
Return Value

A n integer representing the selected font size, or -1 if no font size is selected.

Get_Language

function Get_Language (Self : Gtk_Font_Chooser) return UTF8_String

Gets the language that is used for font features. Since: gtk+ 3.24

Parameters
Self
Return Value

the currently selected language

Get_Level

function Get_Level
   (Self : Gtk_Font_Chooser) return Gtk_Font_Chooser_Level

Returns the current level of granularity for selecting fonts. Since: gtk+ 3.24

Parameters
Self
Return Value

the current granularity level

Get_Preview_Text

function Get_Preview_Text (Self : Gtk_Font_Chooser) return UTF8_String

Gets the text displayed in the preview area. Since: gtk+ 3.2

Parameters
Self
Return Value

the text displayed in the preview area

Get_Show_Preview_Entry

function Get_Show_Preview_Entry (Self : Gtk_Font_Chooser) return Boolean

Returns whether the preview entry is shown or not. Since: gtk+ 3.2

Parameters
Self
Return Value

True if the preview entry is shown or False if it is hidden.

Get_Type

function Get_Type return Glib.GType
Return Value

Gtk_Font_Chooser

type Gtk_Font_Chooser is new Glib.Types.GType_Interface;

Gtk_Font_Chooser_Level

type Gtk_Font_Chooser_Level is mod 2 ** Integer'Size;

This enumeration specifies the granularity of font selection that is desired in a font chooser.

This enumeration may be extended in the future; applications should ignore unknown values.

Gtk_Font_Chooser_Level_Properties

package Gtk_Font_Chooser_Level_Properties is
   new Generic_Internal_Discrete_Property (Gtk_Font_Chooser_Level);

Gtk_Font_Filter_Func

type Gtk_Font_Filter_Func is access function
  (Family : not null access Pango.Font_Family.Pango_Font_Family_Record'Class;
   Face   : not null access Pango.Font_Face.Pango_Font_Face_Record'Class)
return Boolean;

The type of function that is used for deciding what fonts get shown in a Gtk.Font_Chooser.Gtk_Font_Chooser. See Gtk.Font_Chooser.Set_Filter_Func.

Parameters
Family

a Pango.Font_Family.Pango_Font_Family

Face

a Pango.Font_Face.Pango_Font_Face belonging to Family

Return Value

True if the font should be displayed

Language_Property

Language_Property : constant Glib.Properties.Property_String;

The language for which the Gtk.Font_Chooser.Gtk_Font_Chooser:font-features were selected, in a format that is compatible with CSS and with Pango attributes.

Level_Property

Level_Property : constant Gtk.Font_Chooser.Property_Gtk_Font_Chooser_Level;

Type: Gtk_Font_Chooser_Level The level of granularity to offer for selecting fonts.

Null_Gtk_Font_Chooser

Null_Gtk_Font_Chooser : constant Gtk_Font_Chooser;

On_Font_Activated

procedure On_Font_Activated
   (Self  : Gtk_Font_Chooser;
    Call  : Cb_GObject_UTF8_String_Void;
    Slot  : not null access Glib.Object.GObject_Record'Class;
    After : Boolean := False)

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
Self
Call
Slot
After

On_Font_Activated

procedure On_Font_Activated
   (Self  : Gtk_Font_Chooser;
    Call  : Cb_Gtk_Font_Chooser_UTF8_String_Void;
    After : Boolean := False)

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
Self
Call
After

Preview_Text_Property

Preview_Text_Property : constant Glib.Properties.Property_String;

The string with which to preview the font.

Property_Gtk_Font_Chooser_Level

type Property_Gtk_Font_Chooser_Level is new Gtk_Font_Chooser_Level_Properties.Property;

Set_Filter_Func

procedure Set_Filter_Func
   (Self   : Gtk_Font_Chooser;
    Filter : Gtk_Font_Filter_Func)

Adds a filter function that decides which fonts to display in the font chooser. Since: gtk+ 3.2

Parameters
Self
Filter

a Gtk_Font_Filter_Func, or null

Set_Font

procedure Set_Font (Self : Gtk_Font_Chooser; Fontname : UTF8_String)

Sets the currently-selected font. Since: gtk+ 3.2

Parameters
Self
Fontname

a font name like "Helvetica 12" or "Times Bold 18"

Set_Font_Activated

procedure Set_Font_Activated
  (Self    : Font_Chooser_Interface_Descr;
   Handler : Virtual_Font_Activated)
Parameters
Self
Handler

Set_Font_Desc

procedure Set_Font_Desc
   (Self      : Gtk_Font_Chooser;
    Font_Desc : Pango.Font.Pango_Font_Description)

Sets the currently-selected font from Font_Desc. Since: gtk+ 3.2

Parameters
Self
Font_Desc

a Pango.Font.Pango_Font_Description

Set_Font_Map

procedure Set_Font_Map
   (Self    : Gtk_Font_Chooser;
    Fontmap : access Pango.Font_Map.Pango_Font_Map_Record'Class)

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

Since: gtk+ 3.18

Parameters
Self
Fontmap

a Pango.Font_Map.Pango_Font_Map

Set_Get_Font_Face

procedure Set_Get_Font_Face
  (Self    : Font_Chooser_Interface_Descr;
   Handler : Virtual_Get_Font_Face)
Parameters
Self
Handler

Set_Get_Font_Family

procedure Set_Get_Font_Family
  (Self    : Font_Chooser_Interface_Descr;
   Handler : Virtual_Get_Font_Family)
Parameters
Self
Handler

Set_Get_Font_Map

procedure Set_Get_Font_Map
  (Self    : Font_Chooser_Interface_Descr;
   Handler : Virtual_Get_Font_Map)
Parameters
Self
Handler

Set_Get_Font_Size

procedure Set_Get_Font_Size
  (Self    : Font_Chooser_Interface_Descr;
   Handler : Virtual_Get_Font_Size)
Parameters
Self
Handler

Set_Language

procedure Set_Language (Self : Gtk_Font_Chooser; Language : UTF8_String)

Sets the language to use for font features. Since: gtk+ 3.24

Parameters
Self
Language

a language

Set_Level

procedure Set_Level
   (Self  : Gtk_Font_Chooser;
    Level : Gtk_Font_Chooser_Level)

Sets the desired level of granularity for selecting fonts. Since: gtk+ 3.24

Parameters
Self
Level

the desired level of granularity

Set_Preview_Text

procedure Set_Preview_Text (Self : Gtk_Font_Chooser; Text : UTF8_String)

Sets the text displayed in the preview area. The Text is used to show how the selected font looks. Since: gtk+ 3.2

Parameters
Self
Text

the text to display in the preview area

Set_Set_Filter_Func

procedure Set_Set_Filter_Func
  (Self    : Font_Chooser_Interface_Descr;
   Handler : Virtual_Set_Filter_Func)
Parameters
Self
Handler

Set_Set_Font_Map

procedure Set_Set_Font_Map
  (Self    : Font_Chooser_Interface_Descr;
   Handler : Virtual_Set_Font_Map)

See Glib.Object.Add_Interface

Parameters
Self
Handler

Set_Show_Preview_Entry

procedure Set_Show_Preview_Entry
   (Self               : Gtk_Font_Chooser;
    Show_Preview_Entry : Boolean)

Shows or hides the editable preview entry. Since: gtk+ 3.2

Parameters
Self
Show_Preview_Entry

whether to show the editable preview entry or not

Show_Preview_Entry_Property

Show_Preview_Entry_Property : constant Glib.Properties.Property_Boolean;

Whether to show an entry to change the preview text.

Signal_Font_Activated

Signal_Font_Activated : constant Glib.Signal_Name := "font-activated";

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.

Virtual_Font_Activated

type Virtual_Font_Activated is access procedure
  (Self     : Gtk_Font_Chooser;
   Fontname : Gtkada.Types.Chars_Ptr);
Parameters
Self
Fontname

Virtual_Get_Font_Face

type Virtual_Get_Font_Face is access function (Self : Gtk_Font_Chooser) return System.Address;

Gets the Pango.Font_Face.Pango_Font_Face representing the selected font group details (i.e. family, slant, weight, width, etc). If the selected font is not installed, returns null. Since: gtk+ 3.2

Parameters
Self
Return Value

A Pango.Font_Face.Pango_Font_Face representing the selected font group details, or null. The returned object is owned by Fontchooser and must not be modified or freed.

Virtual_Get_Font_Family

type Virtual_Get_Font_Family is access function (Self : Gtk_Font_Chooser) return System.Address;

Gets the Pango.Font_Family.Pango_Font_Family representing the selected font family. Font families are a collection of font faces. If the selected font is not installed, returns null. Since: gtk+ 3.2

Parameters
Self
Return Value

A Pango.Font_Family.Pango_Font_Family representing the selected font family, or null. The returned object is owned by Fontchooser and must not be modified or freed.

Virtual_Get_Font_Map

type Virtual_Get_Font_Map is access function (Self : Gtk_Font_Chooser) return System.Address;

Gets the custom font map of this font chooser widget, or null if it does not have one. Since: gtk+ 3.18

Parameters
Self
Return Value

a Pango.Font_Map.Pango_Font_Map, or null

Virtual_Get_Font_Size

type Virtual_Get_Font_Size is access function (Self : Gtk_Font_Chooser) return Glib.Gint;

The selected font size. Since: gtk+ 3.2

Parameters
Self
Return Value

A n integer representing the selected font size, or -1 if no font size is selected.

Virtual_Set_Filter_Func

type Virtual_Set_Filter_Func is access procedure
  (Self      : Gtk_Font_Chooser;
   Filter    : System.Address;
   User_Data : System.Address;
   Destroy   : Glib.G_Destroy_Notify_Address);

Adds a filter function that decides which fonts to display in the font chooser. Since: gtk+ 3.2

Parameters
Self
Filter

a Gtk_Font_Filter_Func, or null

User_Data

data to pass to Filter

Destroy

function to call to free Data when it is no longer needed

Virtual_Set_Font_Map

type Virtual_Set_Font_Map is access procedure (Self : Gtk_Font_Chooser; Fontmap : System.Address);

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

Since: gtk+ 3.18

Parameters
Self
Fontmap

a Pango.Font_Map.Pango_Font_Map