Top |
Functions
PangoFontFamily * | gtk_font_chooser_get_font_family () |
PangoFontFace * | gtk_font_chooser_get_font_face () |
int | gtk_font_chooser_get_font_size () |
char * | gtk_font_chooser_get_font () |
void | gtk_font_chooser_set_font () |
PangoFontDescription * | gtk_font_chooser_get_font_desc () |
void | gtk_font_chooser_set_font_desc () |
char * | gtk_font_chooser_get_font_features () |
char * | gtk_font_chooser_get_language () |
void | gtk_font_chooser_set_language () |
char * | gtk_font_chooser_get_preview_text () |
void | gtk_font_chooser_set_preview_text () |
gboolean | gtk_font_chooser_get_show_preview_entry () |
void | gtk_font_chooser_set_show_preview_entry () |
GtkFontChooserLevel | gtk_font_chooser_get_level () |
void | gtk_font_chooser_set_level () |
gboolean | (*GtkFontFilterFunc) () |
void | gtk_font_chooser_set_filter_func () |
void | gtk_font_chooser_set_font_map () |
PangoFontMap * | gtk_font_chooser_get_font_map () |
Properties
char * | font | Read / Write |
PangoFontDescription * | font-desc | Read / Write |
char * | font-features | Read |
char * | language | Read / Write |
GtkFontChooserLevel | level | Read / Write |
char * | preview-text | Read / Write |
gboolean | show-preview-entry | Read / Write |
Known Implementations
GtkFontChooser is implemented by GtkFontButton, GtkFontChooserDialog and GtkFontChooserWidget.
Description
GtkFontChooser is an interface that can be implemented by widgets displaying the list of fonts. In GTK, the main objects that implement this interface are GtkFontChooserWidget, GtkFontChooserDialog and GtkFontButton.
Functions
gtk_font_chooser_get_font_family ()
PangoFontFamily *
gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser
);
Gets the PangoFontFamily representing the selected font family. Font families are a collection of font faces.
If the selected font is not installed, returns NULL
.
Returns
A PangoFontFamily representing the
selected font family, or NULL
. The returned object is owned by fontchooser
and must not be modified or freed.
[nullable][transfer none]
gtk_font_chooser_get_font_face ()
PangoFontFace *
gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser
);
Gets the PangoFontFace representing the selected font group details (i.e. family, slant, weight, width, etc).
If the selected font is not installed, returns NULL
.
Returns
A PangoFontFace representing the
selected font group details, or NULL
. The returned object is owned by
fontchooser
and must not be modified or freed.
[nullable][transfer none]
gtk_font_chooser_get_font_size ()
int
gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser
);
The selected font size.
gtk_font_chooser_get_font ()
char *
gtk_font_chooser_get_font (GtkFontChooser *fontchooser
);
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_description_equal()
if you want to compare two
font descriptions.
gtk_font_chooser_set_font ()
void gtk_font_chooser_set_font (GtkFontChooser *fontchooser
,const char *fontname
);
Sets the currently-selected font.
gtk_font_chooser_get_font_desc ()
PangoFontDescription *
gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser
);
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_description_equal()
if you want to compare two
font descriptions.
Returns
A PangoFontDescription for the
current font, or NULL
if no font is selected.
[nullable][transfer full]
gtk_font_chooser_set_font_desc ()
void gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser
,const PangoFontDescription *font_desc
);
Sets the currently-selected font from font_desc
.
gtk_font_chooser_get_font_features ()
char *
gtk_font_chooser_get_font_features (GtkFontChooser *fontchooser
);
Gets the currently-selected font features.
gtk_font_chooser_get_language ()
char *
gtk_font_chooser_get_language (GtkFontChooser *fontchooser
);
Gets the language that is used for font features.
gtk_font_chooser_set_language ()
void gtk_font_chooser_set_language (GtkFontChooser *fontchooser
,const char *language
);
Sets the language to use for font features.
gtk_font_chooser_get_preview_text ()
char *
gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser
);
Gets the text displayed in the preview area.
gtk_font_chooser_set_preview_text ()
void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser
,const char *text
);
Sets the text displayed in the preview area.
The text
is used to show how the selected font looks.
gtk_font_chooser_get_show_preview_entry ()
gboolean
gtk_font_chooser_get_show_preview_entry
(GtkFontChooser *fontchooser
);
Returns whether the preview entry is shown or not.
gtk_font_chooser_set_show_preview_entry ()
void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser
,gboolean show_preview_entry
);
Shows or hides the editable preview entry.
gtk_font_chooser_get_level ()
GtkFontChooserLevel
gtk_font_chooser_get_level (GtkFontChooser *fontchooser
);
Returns the current level of granularity for selecting fonts.
gtk_font_chooser_set_level ()
void gtk_font_chooser_set_level (GtkFontChooser *fontchooser
,GtkFontChooserLevel level
);
Sets the desired level of granularity for selecting fonts.
GtkFontFilterFunc ()
gboolean (*GtkFontFilterFunc) (const PangoFontFamily *family
,const PangoFontFace *face
,gpointer data
);
The type of function that is used for deciding what fonts get
shown in a GtkFontChooser. See gtk_font_chooser_set_filter_func()
.
Parameters
family |
||
face |
a PangoFontFace belonging to |
|
data |
user data passed to |
[closure] |
gtk_font_chooser_set_filter_func ()
void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser
,GtkFontFilterFunc filter
,gpointer user_data
,GDestroyNotify destroy
);
Adds a filter function that decides which fonts to display in the font chooser.
Parameters
fontchooser |
||
filter |
a GtkFontFilterFunc, or |
[allow-none] |
user_data |
data to pass to |
[closure] |
destroy |
function to call to free |
gtk_font_chooser_set_font_map ()
void gtk_font_chooser_set_font_map (GtkFontChooser *fontchooser
,PangoFontMap *fontmap
);
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.
1 2 3 4 5 6 7 8 9 10 |
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:
1 2 |
context = gtk_widget_get_pango_context (label); pango_context_set_font_map (context, fontmap); |
gtk_font_chooser_get_font_map ()
PangoFontMap *
gtk_font_chooser_get_font_map (GtkFontChooser *fontchooser
);
Gets the custom font map of this font chooser widget,
or NULL
if it does not have one.
Types and Values
enum GtkFontChooserLevel
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.
Property Details
The “font”
property
“font” char *
The font description as a string, e.g. "Sans Italic 12".
Owner: GtkFontChooser
Flags: Read / Write
Default value: "Sans 10"
The “font-desc”
property
“font-desc” PangoFontDescription *
The font description as a PangoFontDescription.
Owner: GtkFontChooser
Flags: Read / Write
The “font-features”
property
“font-features” char *
The selected font features, in a format that is compatible with CSS and with Pango attributes.
Owner: GtkFontChooser
Flags: Read
Default value: ""
The “language”
property
“language” char *
The language for which the “font-features” were selected, in a format that is compatible with CSS and with Pango attributes.
Owner: GtkFontChooser
Flags: Read / Write
Default value: ""
The “level”
property
“level” GtkFontChooserLevel
The level of granularity to offer for selecting fonts.
Owner: GtkFontChooser
Flags: Read / Write
Default value: GTK_FONT_CHOOSER_LEVEL_STYLE | GTK_FONT_CHOOSER_LEVEL_SIZE
The “preview-text”
property
“preview-text” char *
The string with which to preview the font.
Owner: GtkFontChooser
Flags: Read / Write
Default value: "The quick brown fox jumps over the lazy dog."
Signal Details
The “font-activated”
signal
void user_function (GtkFontChooser *self, char *fontname, gpointer user_data)
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 |
the object which received the signal |
|
fontname |
the font name |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First