Package org.xjge.core

Class Font

java.lang.Object
org.xjge.core.Font

public final class Font
extends java.lang.Object
Supplies the data parsed from a font file as an immutable object which can be passed to the drawString() method of a Widget to render text in some desired font. TrueType (.ttf) and Bitmap (.bmf) are the preferred file formats of this engine for fonts.
Since:
2.0.0
  • Constructor Summary

    Constructors
    Constructor Description
    Font​(java.lang.String filename, int size)
    Creates a new font object of the specified size using data parsed from a font file.
  • Method Summary

    Modifier and Type Method Description
    void freeTexture()
    Frees the OpenGL texture object used by this class.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Font

      public Font​(java.lang.String filename, int size)
      Creates a new font object of the specified size using data parsed from a font file. Font objects are immutable by design so if you wish to render a single font in different sizes you should create a new font object for each desired size.

      NOTE: The size specified in this constructor encompasses the entire glyph, including its advance, descent, and bearing space. As such, the actual visible portion of the glyph produced may not correspond directly to the desired size in pixels. This value will be discarded if a .bmf file is used.

      Parameters:
      filename - the name of the file to load. Expects the file extension to be included.
      size - the desired size (in pixels) to generate this fonts glyphs at
  • Method Details

    • freeTexture

      public void freeTexture()
      Frees the OpenGL texture object used by this class.