java.lang.Object
dev.prozilla.pine.common.asset.text.Font
All Implemented Interfaces:
Asset, Destructible

public class Font extends Object implements Asset
Contains a font texture for drawing text.

Font textures are created using stb_truetype

  • Field Details

  • Constructor Details

  • Method Details

    • getWidth

      public float getWidth(CharSequence text)
      Calculates the width of a character sequence in this font.
      Parameters:
      text - The character sequence
      Returns:
      The width of the character sequence.
    • getHeight

      public float getHeight(CharSequence text)
      Calculates the height of a character sequence in this font.
      Parameters:
      text - The character sequence
      Returns:
      The height of the character sequence.
    • getSize

      public int getSize()
    • drawText

      public void drawText(Renderer renderer, CharSequence text, float x, float y, float z)
      Draws text on the screen at the given coordinates with the default text color using this font.
      Parameters:
      renderer - The renderer to use
      text - The text to draw
      x - The x position
      y - The y position
      z - The z position
    • drawText

      public void drawText(Renderer renderer, CharSequence text, float x, float y, float z, Color c)
      Draws text on the screen at the given coordinates using this font.
      Parameters:
      renderer - The renderer to use
      text - The text to draw
      x - The x position
      y - The y position
      z - The z position
      c - The color to draw the text in
    • setSize

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

      public String getPath()
      Description copied from interface: Asset
      Returns the path to the file this asset was loaded from.
      Specified by:
      getPath in interface Asset
      Returns:
      The path of this asset.
    • destroy

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

      public static String generateKey(String path, int size)