java.lang.Object
dev.prozilla.pine.common.system.resource.text.Font
All Implemented Interfaces:
Lifecycle

public class Font extends Object implements Lifecycle
Contains a font texture for drawing text.
  • Field Details

    • path

      public String path
    • COLOR_DEFAULT

      public static final Color COLOR_DEFAULT
  • Constructor Details

    • Font

      public Font()
      Creates a default anti-aliased font with monospaced glyphs and default size 16.
    • Font

      public Font(boolean antiAlias)
      Creates a default font with monospaced glyphs and default size 16.
      Parameters:
      antiAlias - Whether the font should be anti-aliased or not
    • Font

      public Font(int size)
      Creates a default anti-aliased font with monospaced glyphs and specified size.
      Parameters:
      size - Font size
    • Font

      public Font(int size, boolean antiAlias)
      Creates a default font with monospaced glyphs and specified size.
      Parameters:
      size - Font size
      antiAlias - Whether the font should be anti-aliased or not
    • Font

      public Font(InputStream in, int size) throws FontFormatException, IOException
      Creates an anti-aliased Font from an input stream.
      Parameters:
      in - The input stream
      size - Font size
      Throws:
      FontFormatException - if fontFile does not contain the required font tables for the specified format
      IOException - If font can't be read
    • Font

      public Font(InputStream in, int size, boolean antiAlias) throws FontFormatException, IOException
      Creates a Font from an input stream.
      Parameters:
      in - The input stream
      size - Font size
      antiAlias - Whether the font should be anti-aliased or not
      Throws:
      FontFormatException - if fontFile does not contain the required font tables for the specified format
      IOException - If font can't be read
    • Font

      public Font(Font font)
      Creates an anti-aliased font from an AWT Font.
      Parameters:
      font - The AWT Font
    • Font

      public Font(Font font, boolean antiAlias)
      Creates a font from an AWT Font.
      Parameters:
      font - The AWT Font
      antiAlias - Whether the font should be anti-aliased or not
  • Method Details

    • getWidth

      public int getWidth(CharSequence text)
      Gets the width of the specified text.
      Parameters:
      text - The text
      Returns:
      Width of text
    • getHeight

      public int getHeight(CharSequence text)
      Gets the height of the specified text.
      Parameters:
      text - The text
      Returns:
      Height of text
    • drawText

      public void drawText(Renderer renderer, CharSequence text, float x, float y, float z, Color c)
      Draw text at the specified position and color.
      Parameters:
      renderer - The renderer to use
      text - TextRenderer to draw
      x - X coordinate of the text position
      y - Y coordinate of the text position
      c - Color to use
    • drawText

      public void drawText(Renderer renderer, CharSequence text, float x, float y, float z)
      Draw text at the specified position.
      Parameters:
      renderer - The renderer to use
      text - TextRenderer to draw
      x - X coordinate of the text position
      y - Y coordinate of the text position
    • setSize

      public Font setSize(int size)
      Creates a new font from the same font file, but with a different size.
    • destroy

      public void destroy()
      Deletes the font.
      Specified by:
      destroy in interface Lifecycle
    • generateKey

      public static String generateKey(String path, int size)