Class FontMap

All Implemented Interfaces:
Iterable<FontFamily>, Collection<FontFamily>, List<FontFamily>, SequencedCollection<FontFamily>, ListModel<FontFamily>, Proxy, ListModelJavaList<FontFamily>
Direct Known Subclasses:
FontMap.FontMap$Impl, FontMap.FontMap$Impl

@Generated("org.javagi.JavaGI") public abstract class FontMap extends GObject implements ListModel<FontFamily>

A PangoFontMap represents the set of fonts available for a particular rendering system.

This is a virtual object with implementations being specific to particular rendering systems.

  • Constructor Details

    • FontMap

      public FontMap(MemorySegment address)
      Create a FontMap instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • FontMap

      public FontMap()
      Create a new FontMap.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the FontMap class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected FontMap asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • addFontFile

      public boolean addFontFile(String filename) throws GErrorException

      Loads a font file with one or more fonts into the PangoFontMap.

      The added fonts will take precedence over preexisting fonts with the same name.

      Parameters:
      filename - Path to the font file
      Returns:
      True if the font file is successfully loaded into the fontmap, false if an error occurred.
      Throws:
      GErrorException - see GError
      Since:
      1.56
    • changed

      public void changed()

      Forces a change in the fontmap, which will cause any PangoContext using this fontmap to change.

      This function is only useful when implementing a new backend for Pango, something applications won't do. Backends should call this function if they have attached extra data to the fontmap and such data is changed.

      Since:
      1.34
    • createContext

      public Context createContext()

      Creates a PangoContext connected to fontmap.

      This is equivalent to Context() followed by Context.setFontMap(FontMap).

      If you are using Pango as part of a higher-level system, that system may have it's own way of create a PangoContext. For instance, the GTK toolkit has, among others, gtk_widget_get_pango_context(). Use those instead.

      Returns:
      the newly allocated PangoContext, which should be freed with g_object_unref().
      Since:
      1.22
    • getFamily

      public @Nullable FontFamily getFamily(String name)
      Gets a font family by name.
      Parameters:
      name - a family name
      Returns:
      the PangoFontFamily
      Since:
      1.46
    • getSerial

      public int getSerial()

      Returns the current serial number of fontmap.

      The serial number is initialized to an small number larger than zero when a new fontmap is created and is increased whenever the fontmap is changed. It may wrap, but will never have the value 0. Since it can wrap, never compare it with "less than", always use "not equals".

      The fontmap can only be changed using backend-specific API, like changing fontmap resolution.

      This can be used to automatically detect changes to a PangoFontMap, like in PangoContext.

      Returns:
      The current serial number of fontmap.
      Since:
      1.32.4
    • listFamilies

      public void listFamilies(@Nullable Out<FontFamily[]> families)

      List all families for a fontmap.

      Note that the returned families are not in any particular order.

      PangoFontMap also implemented the ListModel interface for enumerating families.

      Parameters:
      families - location to store a pointer to an array of PangoFontFamily *. This array should be freed with g_free().
    • loadFont

      public @Nullable Font loadFont(Context context, FontDescription desc)
      Load the font in the fontmap that is the closest match for desc.
      Parameters:
      context - the PangoContext the font will be used with
      desc - a PangoFontDescription describing the font to load
      Returns:
      the newly allocated PangoFont loaded, or null if no font matched.
    • loadFontset

      public @Nullable Fontset loadFontset(Context context, FontDescription desc, Language language)
      Load a set of fonts in the fontmap that can be used to render a font matching desc.
      Parameters:
      context - the PangoContext the font will be used with
      desc - a PangoFontDescription describing the font to load
      language - a PangoLanguage the fonts will be used for
      Returns:
      the newly allocated PangoFontset loaded, or null if no font matched.
    • reloadFont

      public Font reloadFont(Font font, double scale, @Nullable Context context, @Nullable String variations)

      Returns a new font that is like font, except that it is scaled by scale, its backend-dependent configuration (e.g. cairo font options) is replaced by the one in context, and its variations are replaced by variations.

      Note that the scaling here is meant to be linear, so this scaling can be used to render a font on a hi-dpi display without changing its optical size.

      Parameters:
      font - a font in this FontMap
      scale - the scale factor to apply
      context - a PangoContext
      variations - font variations to use
      Returns:
      the modified font
      Since:
      1.52
    • getFace

      protected FontFace getFace(Font font)