Class AngelCodeFont

java.lang.Object
zombie.core.fonts.AngelCodeFont
All Implemented Interfaces:
AssetStateObserver, Font

public final class AngelCodeFont extends Object implements Font, AssetStateObserver
A font implementation that will parse BMFont format font files. The font files can be output by Hiero, which is included with Slick, and also the AngelCode font tool available at:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    The definition of a single character as defined in the AngelCode file format
    static final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The characters building up the font
    static float
     
    static float
     
    static Color
     
    static float
     
    static float
     
    static int
     
    static int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AngelCodeFont(String _fntFile, String imgFile)
    Create a new font based on a font definition from AngelCode's tool and the font image generated from the tool.
    AngelCodeFont(String _fntFile, Texture image)
    Create a new font based on a font definition from AngelCode's tool and the font image generated from the tool.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    drawString(float x, float y, float scale, String text, float r, float g, float b, float a)
     
    void
    drawString(float x, float y, float scale, String text, float r, float g, float b, float a, int startIndex, int endIndex)
     
    void
    drawString(float x, float y, String text)
    Description copied from interface: Font
    void
    drawString(float x, float y, String text, float r, float g, float b, float a)
     
    void
    drawString(float x, float y, String text, float r, float g, float b, float a, int startIndex, int endIndex)
     
    void
    drawString(float x, float y, String text, Color col)
    Description copied from interface: Font
    void
    drawString(float x, float y, String text, Color col, int startIndex, int endIndex)
    Description copied from interface: Font
    int
    Description copied from interface: Font
    int
    getHeight(String string, boolean boolean0, boolean boolean1)
     
    int
    Description copied from interface: Font
    int
    Description copied from interface: Font
    int
    getWidth(String text, boolean xAdvance)
     
    int
    getWidth(String text, int start, int end)
     
    int
    getWidth(String text, int start, int end, boolean xadvance)
     
    int
    Returns the distance from the y drawing location to the top most pixel of the specified text.
    boolean
     
    void
    onStateChanged(Asset.State oldState, Asset.State newState, Asset asset)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • chars

      public AngelCodeFont.CharDef[] chars
      The characters building up the font
    • xoff

      public static int xoff
    • yoff

      public static int yoff
    • curCol

      public static Color curCol
    • curR

      public static float curR
    • curG

      public static float curG
    • curB

      public static float curB
    • curA

      public static float curA
  • Constructor Details

    • AngelCodeFont

      public AngelCodeFont(String _fntFile, Texture image) throws FileNotFoundException
      Create a new font based on a font definition from AngelCode's tool and the font image generated from the tool.
      Parameters:
      _fntFile - The location of the font defnition file
      image - The image to use for the font
      Throws:
      FileNotFoundException
    • AngelCodeFont

      public AngelCodeFont(String _fntFile, String imgFile) throws FileNotFoundException
      Create a new font based on a font definition from AngelCode's tool and the font image generated from the tool.
      Parameters:
      _fntFile - The location of the font defnition file
      imgFile - The location of the font image
      Throws:
      FileNotFoundException
  • Method Details

    • drawString

      public void drawString(float x, float y, String text)
      Description copied from interface: Font
      Specified by:
      drawString in interface Font
      Parameters:
      x - The x location at which to draw the string
      y - The y location at which to draw the string
      text - The text to be displayed
    • drawString

      public void drawString(float x, float y, String text, Color col)
      Description copied from interface: Font
      Specified by:
      drawString in interface Font
      Parameters:
      x - The x location at which to draw the string
      y - The y location at which to draw the string
      text - The text to be displayed
      col - The colour to draw with
    • drawString

      public void drawString(float x, float y, String text, float r, float g, float b, float a)
    • drawString

      public void drawString(float x, float y, float scale, String text, float r, float g, float b, float a)
    • drawString

      public void drawString(float x, float y, String text, Color col, int startIndex, int endIndex)
      Description copied from interface: Font
      Specified by:
      drawString in interface Font
      Parameters:
      x - The x location at which to draw the string
      y - The y location at which to draw the string
      text - The text to be displayed
      col - The colour to draw with
      startIndex - The index of the first character to draw
      endIndex - The index of the last character from the string to draw
    • drawString

      public void drawString(float x, float y, String text, float r, float g, float b, float a, int startIndex, int endIndex)
    • drawString

      public void drawString(float x, float y, float scale, String text, float r, float g, float b, float a, int startIndex, int endIndex)
    • getHeight

      public int getHeight(String text)
      Description copied from interface: Font
      Specified by:
      getHeight in interface Font
      Parameters:
      text - The string to obtain the rendered with of
      Returns:
      The width of the given string
    • getHeight

      public int getHeight(String string, boolean boolean0, boolean boolean1)
    • getLineHeight

      public int getLineHeight()
      Description copied from interface: Font
      Specified by:
      getLineHeight in interface Font
      Returns:
      The maxium height of any line drawn by this font
    • getWidth

      public int getWidth(String text)
      Description copied from interface: Font
      Specified by:
      getWidth in interface Font
      Parameters:
      text - The string to obtain the rendered with of
      Returns:
      The width of the given string
    • getWidth

      public int getWidth(String text, boolean xAdvance)
      Specified by:
      getWidth in interface Font
    • getWidth

      public int getWidth(String text, int start, int end)
      Specified by:
      getWidth in interface Font
    • getWidth

      public int getWidth(String text, int start, int end, boolean xadvance)
      Specified by:
      getWidth in interface Font
    • getYOffset

      public int getYOffset(String text)
      Returns the distance from the y drawing location to the top most pixel of the specified text.
      Parameters:
      text - The text that is to be tested
      Returns:
      The yoffset from the y draw location at which text will start
    • onStateChanged

      public void onStateChanged(Asset.State oldState, Asset.State newState, Asset asset)
      Specified by:
      onStateChanged in interface AssetStateObserver
    • isEmpty

      public boolean isEmpty()
    • destroy

      public void destroy()