Class BitmapFont

java.lang.Object
rosequartz.gfx.BitmapFont
All Implemented Interfaces:
Font<BitmapFont>

public class BitmapFont extends Object implements Font<BitmapFont>
Represents a bitmap-font made from a texture.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BitmapFont​(Texture texture)
    Creates a bitmap-font from a texture containing all glyphs.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    getTextHeight​(String text, float height, float spacingVertical)
    Gets the height of a given text.
    float
    getTextWidth​(String text, float height, float spacingHorizontal)
    Gets the width of a given text.
    glyph​(char glyph, int glyphX, int glyphY, int glyphWidth, int glyphHeight)
    Defines the source position of a glpyh.
    render​(String text, float x, float y, float height, float spacingHorizontal, float spacingVertical)
    Render a given text onto the current target frame buffer using texture coordinates.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • glyph

      public BitmapFont glyph(char glyph, int glyphX, int glyphY, int glyphWidth, int glyphHeight)
      Defines the source position of a glpyh.
      Parameters:
      glyph - glyph to define
      glyphX - position of the top left corner of the glyph on the source texture on the x-axis in pixels
      glyphY - position of the top left corner of the glyph on the source texture on the y-axis in pixels
      glyphWidth - width of the glyph on the source texture in pixels
      glyphHeight - height of the glyph on the source texture in pixels
      Returns:
      this
    • getTextWidth

      public float getTextWidth(String text, float height, float spacingHorizontal)
      Description copied from interface: Font
      Gets the width of a given text.
      Specified by:
      getTextWidth in interface Font<BitmapFont>
      Parameters:
      text - text to calculate width of
      height - height of the text
      spacingHorizontal - spacing between characters on the x-axis
    • getTextHeight

      public float getTextHeight(String text, float height, float spacingVertical)
      Description copied from interface: Font
      Gets the height of a given text.
      Specified by:
      getTextHeight in interface Font<BitmapFont>
      Parameters:
      text - text to calculate width of
      height - height of the text
      spacingVertical - spacing between characters on the y-axis
    • render

      public BitmapFont render(String text, float x, float y, float height, float spacingHorizontal, float spacingVertical) throws NotOnGraphicsThreadException
      Description copied from interface: Font
      Render a given text onto the current target frame buffer using texture coordinates.
      Specified by:
      render in interface Font<BitmapFont>
      Parameters:
      text - text to render
      x - position of the bottom left corner of the rendered text on the x-axis
      y - position of the bottom left corner of the rendered text on the y-axis
      height - height of the text
      spacingHorizontal - space between every character on the x-axis
      spacingVertical - space between every character on the y-axis
      Throws:
      NotOnGraphicsThreadException