zombie.core.fonts
Class AngelCodeFont

java.lang.Object
  extended by zombie.core.fonts.AngelCodeFont
All Implemented Interfaces:
Font

public class AngelCodeFont
extends java.lang.Object
implements Font

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: http://www.angelcode.com/products/bmfont/ This implementation copes with both the font display and kerning information allowing nicer looking paragraphs of text. Note that this utility only supports the text BMFont format definition file.

Author:
kevin, Nathan Sweet

Field Summary
static float curA
           
static float curB
           
static Color curCol
           
static float curG
           
static float curR
           
 int xoff
           
 int yoff
           
 
Constructor Summary
AngelCodeFont(java.lang.String fntFile, java.lang.String imgFile)
          Create a new font based on a font definition from AngelCode's tool and the font image generated from the tool.
AngelCodeFont(java.lang.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
 void drawString(float x, float y, java.lang.String text)
          Draw a string to the screen
 void drawString(float x, float y, java.lang.String text, Color col)
          Draw a string to the screen
 void drawString(float x, float y, java.lang.String text, Color col, int startIndex, int endIndex)
          Draw part of a string to the screen.
 void drawString(float x, float y, java.lang.String text, float r, float g, float b, float a)
           
 void drawString(float x, float y, java.lang.String text, float r, float g, float b, float a, int startIndex, int endIndex)
           
 int getHeight(java.lang.String text)
          get the height of the given string
 int getLineHeight()
          get the maximum height of any line drawn by this font
 int getWidth(java.lang.String text)
          get the width of the given string
 int getYOffset(java.lang.String text)
          Returns the distance from the y drawing location to the top most pixel of the specified text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xoff

public int xoff
See Also:
Font.drawString(float, float, String, Color, int, int)

yoff

public 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 Detail

AngelCodeFont

public AngelCodeFont(java.lang.String fntFile,
                     Texture image)
              throws java.io.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:
java.io.FileNotFoundException
SlickException - Indicates a failure to load either file

AngelCodeFont

public AngelCodeFont(java.lang.String fntFile,
                     java.lang.String imgFile)
              throws java.io.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:
SlickException - Indicates a failure to load either file
java.io.FileNotFoundException
Method Detail

drawString

public void drawString(float x,
                       float y,
                       java.lang.String text)
Description copied from interface: Font
Draw a string to the screen

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
See Also:
org.newdawn.slick.Font#drawString(float, float, java.lang.String)

drawString

public void drawString(float x,
                       float y,
                       java.lang.String text,
                       Color col)
Description copied from interface: Font
Draw a string to the screen

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
See Also:
org.newdawn.slick.Font#drawString(float, float, java.lang.String, org.newdawn.slick.Color)

drawString

public void drawString(float x,
                       float y,
                       java.lang.String text,
                       float r,
                       float g,
                       float b,
                       float a)

drawString

public void drawString(float x,
                       float y,
                       java.lang.String text,
                       Color col,
                       int startIndex,
                       int endIndex)
Description copied from interface: Font
Draw part of a string to the screen. Note that this will still position the text as though it's part of the bigger string.

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,
                       java.lang.String text,
                       float r,
                       float g,
                       float b,
                       float a,
                       int startIndex,
                       int endIndex)

getHeight

public int getHeight(java.lang.String text)
Description copied from interface: Font
get the height of the given string

Specified by:
getHeight in interface Font
Parameters:
text - The string to obtain the rendered with of
Returns:
The width of the given string
See Also:
org.newdawn.slick.Font#getHeight(java.lang.String)

getLineHeight

public int getLineHeight()
Description copied from interface: Font
get the maximum height of any line drawn by this font

Specified by:
getLineHeight in interface Font
Returns:
The maxium height of any line drawn by this font
See Also:
org.newdawn.slick.Font#getLineHeight()

getWidth

public int getWidth(java.lang.String text)
Description copied from interface: Font
get the width of the given string

Specified by:
getWidth in interface Font
Parameters:
text - The string to obtain the rendered with of
Returns:
The width of the given string
See Also:
org.newdawn.slick.Font#getWidth(java.lang.String)

getYOffset

public int getYOffset(java.lang.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