Class Font

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
Font.Font$Impl, Font.Font$Impl

@Generated("org.javagi.JavaGI") public abstract class Font extends GObject
A PangoFont is used to represent a font in a rendering-system-independent manner.
  • Constructor Details

    • Font

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

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

    • getType

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

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

      protected Font 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
    • descriptionsFree

      @Deprecated public static void descriptionsFree(@Nullable FontDescription @Nullable [] descs)
      Deprecated.
      Just use pango_font_description_free in a loop
      Frees an array of font descriptions.
      Parameters:
      descs - a pointer to an array of PangoFontDescription, may be null
    • deserialize

      public static @Nullable Font deserialize(Context context, byte[] bytes) throws GErrorException

      Loads data previously created via serialize().

      For a discussion of the supported format, see that function.

      Note: to verify that the returned font is identical to the one that was serialized, you can compare bytes to the result of serializing the font again.

      Parameters:
      context - a PangoContext
      bytes - the bytes containing the data
      Returns:
      a new PangoFont
      Throws:
      GErrorException - see GError
      Since:
      1.50
    • describe

      public FontDescription describe()

      Returns a description of the font, with font size set in points.

      Use describeWithAbsoluteSize() if you want the font size in device units.

      Returns:
      a newly-allocated PangoFontDescription object.
    • describeWithAbsoluteSize

      public FontDescription describeWithAbsoluteSize()

      Returns a description of the font, with absolute font size set in device units.

      Use describe() if you want the font size in points.

      Returns:
      a newly-allocated PangoFontDescription object.
      Since:
      1.14
    • getCoverage

      public Coverage getCoverage(Language language)
      Computes the coverage map for a given font and language tag.
      Parameters:
      language - the language tag
      Returns:
      a newly-allocated PangoCoverage object.
    • getFace

      public @Nullable FontFace getFace()

      Gets the PangoFontFace to which this Font belongs.

      Note that this function can return NULL in cases where the font outlives its font map.

      Returns:
      the PangoFontFace
      Since:
      1.46
    • getFontMap

      public @Nullable FontMap getFontMap()

      Gets the font map for which the font was created.

      Note that the font maintains a weak reference to the font map, so if all references to font map are dropped, the font map will be finalized even if there are fonts created with the font map that are still alive. In that case this function will return null.

      It is the responsibility of the user to ensure that the font map is kept alive. In most uses this is not an issue as a PangoContext holds a reference to the font map.

      Returns:
      the PangoFontMap for the font
      Since:
      1.10
    • getGlyphExtents

      public void getGlyphExtents(Glyph glyph, @Nullable Rectangle inkRect, @Nullable Rectangle logicalRect)

      Gets the logical and ink extents of a glyph within a font.

      The coordinate system for each rectangle has its origin at the base line and horizontal origin of the character with increasing coordinates extending to the right and down. The macros PANGO_ASCENT(), PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert from the extents rectangle to more traditional font metrics. The units of the rectangles are in 1/PANGO_SCALE of a device unit.

      If this Font is null, this function gracefully sets some sane values in the output variables and returns.

      Parameters:
      glyph - the glyph index
      inkRect - rectangle used to store the extents of the glyph as drawn
      logicalRect - rectangle used to store the logical extents of the glyph
    • getHbFont

      public @Nullable Font getHbFont()

      Get a hb_font_t object backing this font.

      Note that the objects returned by this function are cached and immutable. If you need to make changes to the hb_font_t, use hb_font_create_sub_font().

      Returns:
      the hb_font_t object backing the font
      Since:
      1.44
    • getMetrics

      public FontMetrics getMetrics(@Nullable Language language)

      Gets overall metric information for a font.

      Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language.

      If this Font is null, this function gracefully sets some sane values in the output variables and returns.

      Parameters:
      language - language tag used to determine which script to get the metrics for, or null to indicate to get the metrics for the entire font.
      Returns:
      a PangoFontMetrics object. The caller must call FontMetrics.unref() when finished using the object.
    • hasChar

      public boolean hasChar(int wc)
      Returns whether the font provides a glyph for this character.
      Parameters:
      wc - a Unicode character
      Returns:
      TRUE if this Font can render wc
      Since:
      1.44
    • serialize

      public byte[] serialize()

      Serializes the this Font in a way that can be uniquely identified.

      There are no guarantees about the format of the output across different versions of Pango.

      The intended use of this function is testing, benchmarking and debugging. The format is not meant as a permanent storage format.

      To recreate a font from its serialized form, use deserialize(Context, byte[]).

      Returns:
      a GBytes containing the serialized form of this Font
      Since:
      1.50
    • createHbFont

      protected Font createHbFont()
    • describeAbsolute

      protected FontDescription describeAbsolute()