Module: Gtk::FontChooser

Defined in:
(unknown)

Overview

Gtk::FontChooser 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::FontChooserWidget, Gtk::FontChooserDialog and #GtkFontButton. The GtkFontChooser interface has been introducted in GTK+ 3.2.

Instance Method Summary collapse

Instance Method Details

#fontString

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.

Returns:

  • (String)

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

#font=(fontname) ⇒ nil

Sets the currently-selected font.

Parameters:

  • fontname (String)

    a font name like “Helvetica 12” or “Times Bold 18”

Returns:

  • (nil)

#font_activated(chooser, fontname) ⇒ nil

Parameters:

Returns:

  • (nil)

#font_descPango::FontDescription

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:

  • (Pango::FontDescription)

    A Pango::FontDescription for the current font, or nil if no font is selected.

#font_desc=(font_desc) ⇒ nil

Sets the currently-selected font from font_desc.

Parameters:

  • font_desc (Pango::FontDescription)

    a Pango::FontDescription

Returns:

  • (nil)

#font_facePango::FontFace

Gets the Pango::FontFace representing the selected font group details (i.e. family, slant, weight, width, etc).

If the selected font is not installed, returns nil.

Returns:

  • (Pango::FontFace)

    A Pango::FontFace representing the selected font group details, or nil. The returned object is owned by fontchooser and must not be modified or freed.

#font_familyPango::FontFamily

Gets the Pango::FontFamily representing the selected font family. Font families are a collection of font faces.

If the selected font is not installed, returns nil.

Returns:

  • (Pango::FontFamily)

    A Pango::FontFamily representing the selected font family, or nil. The returned object is owned by fontchooser and must not be modified or freed.

#font_featuresString

Gets the currently-selected font features.

Returns:

  • (String)

    the currently selected font features

#font_mapPango::FontMap

Gets the custom font map of this font chooser widget, or nil if it does not have one.

Returns:

#font_map=(fontmap) ⇒ nil

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

Parameters:

Returns:

  • (nil)

#font_sizeInteger

The selected font size.

Returns:

  • (Integer)

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

#get_font_face(fontchooser) ⇒ Pango::FontFace

Returns A Pango::FontFace representing the selected font group details, or nil. The returned object is owned by fontchooser and must not be modified or freed.

Parameters:

Returns:

  • (Pango::FontFace)

    A Pango::FontFace representing the selected font group details, or nil. The returned object is owned by fontchooser and must not be modified or freed.

#get_font_family(fontchooser) ⇒ Pango::FontFamily

Returns A Pango::FontFamily representing the selected font family, or nil. The returned object is owned by fontchooser and must not be modified or freed.

Parameters:

Returns:

  • (Pango::FontFamily)

    A Pango::FontFamily representing the selected font family, or nil. The returned object is owned by fontchooser and must not be modified or freed.

#get_font_map(fontchooser) ⇒ Pango::FontMap

Returns a Pango::FontMap, or nil.

Parameters:

Returns:

#get_font_size(fontchooser) ⇒ Integer

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

Parameters:

Returns:

  • (Integer)

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

#languageString

Gets the language that is used for font features.

Returns:

  • (String)

    the currently selected language

#language=(language) ⇒ nil

Sets the language to use for font features.

Parameters:

  • language (String)

    a language

Returns:

  • (nil)

#levelGtk::FontChooserLevel

Returns the current level of granularity for selecting fonts.

Returns:

#level=(level) ⇒ nil

Sets the desired level of granularity for selecting fonts.

Parameters:

Returns:

  • (nil)

#preview_textString

Gets the text displayed in the preview area.

Returns:

  • (String)

    the text displayed in the preview area

#preview_text=(text) ⇒ nil

Sets the text displayed in the preview area. The text is used to show how the selected font looks.

Parameters:

  • text (String)

    the text to display in the preview area

Returns:

  • (nil)

#set_filter_func(fontchooser, filter, user_data, destroy) ⇒ nil

Parameters:

  • fontchooser (Gtk::FontChooser)

    a Gtk::FontChooser

  • filter (Gtk::FontFilterFunc)

    a Gtk::FontFilterFunc, or nil

  • user_data (GObject)

    data to pass to filter

  • destroy (GLib::DestroyNotify)

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

Returns:

  • (nil)

#set_font_map(fontchooser, fontmap) ⇒ nil

Parameters:

Returns:

  • (nil)

#show_preview_entryTrueClass

Returns whether the preview entry is shown or not.

Returns:

  • (TrueClass)

    true if the preview entry is shown or false if it is hidden.

#show_preview_entry=(show_preview_entry) ⇒ nil

Shows or hides the editable preview entry.

Parameters:

  • show_preview_entry (TrueClass)

    whether to show the editable preview entry or not

Returns:

  • (nil)