Class FontChooser

All Implemented Interfaces:
PointerInterface

public class FontChooser extends Interface
`GtkFontChooser` is an interface that can be implemented by widgets
for choosing fonts.

In GTK, the main objects that implement this interface are
[class@Gtk.FontChooserWidget], [class@Gtk.FontChooserDialog] and
[class@Gtk.FontButton].

https://docs.gtk.org/gtk4/iface.FontChooser.html

  • Field Details

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getFont

      public Str getFont()
      Gets the currently-selected font name.

      Note that this can be a different string than what you set with
      [method@Gtk.FontChooser.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 [method@Pango.FontDescription.equal] if you want to compare two
      font descriptions.
      Returns:
      A string with the name of the current font
    • getFontDesc

      public FontDescription getFontDesc()
      Gets the currently-selected font.

      Note that this can be a different string than what you set with
      [method@Gtk.FontChooser.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 [method@Pango.FontDescription.equal] if you want to compare two
      font descriptions.
      Returns:
      A `PangoFontDescription` for the current font
    • getFontFace

      public FontFace getFontFace()
      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
    • getFontFamily

      public FontFamily getFontFamily()
      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
    • getFontFeatures

      public Str getFontFeatures()
      Gets the currently-selected font features.

      The format of the returned string is compatible with the
      [CSS font-feature-settings property](https://www.w3.org/TR/css-fonts-4/#font-rend-desc).
      It can be passed to [func@Pango.AttrFontFeatures.new].
      Returns:
      the currently selected font features
    • getFontMap

      public FontMap getFontMap()
      Gets the custom font map of this font chooser widget,
      or %NULL if it does not have one.
      Returns:
      a `PangoFontMap`
    • getFontSize

      public int getFontSize()
      The selected font size.
      Returns:
      A n integer representing the selected font size, or -1 if no font size is selected.
    • getLanguage

      public Str getLanguage()
      Gets the language that is used for font features.
      Returns:
      the currently selected language
    • getLevel

      public int getLevel()
      Returns the current level of granularity for selecting fonts.
      Returns:
      the current granularity level
    • getPreviewText

      public Str getPreviewText()
      Gets the text displayed in the preview area.
      Returns:
      the text displayed in the preview area
    • getShowPreviewEntry

      public boolean getShowPreviewEntry()
      Returns whether the preview entry is shown or not.
      Returns:
      %TRUE if the preview entry is shown or %FALSE if it is hidden.
    • setFilterFunc

      public void setFilterFunc(FontChooser.OnFontFilterFunc filter, @Nullable Pointer user_data, FontChooser.OnDestroyNotify destroy)
      Adds a filter function that decides which fonts to display
      in the font chooser.
      Parameters:
      filter - a `GtkFontFilterFunc`
      user_data - data to pass to @filter
      destroy - function to call to free @data when it is no longer needed
    • setFont

      public void setFont(@Nonnull Str fontname)
      Sets the currently-selected font.
      Parameters:
      fontname - a font name like “Helvetica 12” or “Times Bold 18”
    • setFont

      public void setFont(String fontname)
      Sets the currently-selected font.
      Parameters:
      fontname - a font name like “Helvetica 12” or “Times Bold 18”
    • setFontDesc

      public void setFontDesc(@Nonnull FontDescription font_desc)
      Sets the currently-selected font from @font_desc.
      Parameters:
      font_desc - a `PangoFontDescription`
    • setFontMap

      public void setFontMap(@Nullable FontMap 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.

      ```c
      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:

      ```c
      context = gtk_widget_get_pango_context (label);
      pango_context_set_font_map (context, fontmap);
      ```
      Parameters:
      fontmap - a `PangoFontMap`
    • setLanguage

      public void setLanguage(@Nonnull Str language)
      Sets the language to use for font features.
      Parameters:
      language - a language
    • setLanguage

      public void setLanguage(String language)
      Sets the language to use for font features.
      Parameters:
      language - a language
    • setLevel

      public void setLevel(int level)
      Sets the desired level of granularity for selecting fonts.
      Parameters:
      level - the desired level of granularity
    • setPreviewText

      public void setPreviewText(@Nonnull Str text)
      Sets the text displayed in the preview area.

      The @text is used to show how the selected font looks.
      Parameters:
      text - the text to display in the preview area
    • setPreviewText

      public void setPreviewText(String text)
      Sets the text displayed in the preview area.

      The @text is used to show how the selected font looks.
      Parameters:
      text - the text to display in the preview area
    • setShowPreviewEntry

      public void setShowPreviewEntry(boolean show_preview_entry)
      Shows or hides the editable preview entry.
      Parameters:
      show_preview_entry - whether to show the editable preview entry or not
    • onFontActivated

      public SignalHandler onFontActivated(FontChooser.OnFontActivated signal)
      Connect to signal "font-activated".
      See FontChooser.OnFontActivated.onFontActivated(ch.bailu.gtk.type.Str) for signal description.
      Field SIGNAL_ON_FONT_ACTIVATED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()