SpriteFont Class Reference

List of all members.

Public Member Functions

 SpriteFont (TextAsset def)
 Constructor.
void Load (TextAsset def)
 Loads a font from the specified font definition TextAsset and adds it to the font store.
SpriteChar GetSpriteChar (char ch)
 Returns a reference to the SpriteChar that corresponds to the specified character ID (usually the numeric Unicode value).
bool ContainsCharacter (char ch)
 Returns whether the specified character is part of this font definition.
float GetWidth (string str)
 Gets how wide the specified string would be, in pixels.
float GetWidth (string str, int start, int end)
 Gets how wide the specified string would be, in pixels.
float GetWidth (StringBuilder sb, int start, int end)
 Gets how wide the specified string would be, in pixels.
float GetWidth (char prevChar, char c)
 Gets how wide the specified character would be, in pixels, when displayed.
float GetAdvance (char c)
 Returns the xAdvance of the specified character. 0 is returned if the character isn't supported.
string RemoveUnsupportedCharacters (string str)
 Returns a version of the specified string with all characters removed which are not defined for this font.

Public Attributes

TextAsset fontDef
 The TextAsset that defines the font.

Protected Attributes

string face
 The name of the font face.

Properties

int LineHeight [get, set]
 The default height, in pixels, between lines.
int BaseHeight [get]
 The distance, in pixels, from the absolute top of a line to the baseline:.
int PixelSize [get]
 The size (height) of the font, in pixels. This is the height, in pixels of a full-height character.
float CharacterSpacing [get, set]
 An adjustable factor by which you can increase/decrease the spacing between characters. A value of 1.0 will space characters exactly as described by the font. Decreasing this value will place the characters closer together, while increasing it will place them farther apart.

Detailed Description

A class that holds information about a font intended for use with SpriteText.


Constructor & Destructor Documentation

SpriteFont.SpriteFont ( TextAsset  def  ) 

Constructor.

Parameters:
def TextAsset that defines the font.

Member Function Documentation

bool SpriteFont.ContainsCharacter ( char  ch  ) 

Returns whether the specified character is part of this font definition.

Parameters:
ch Character to check.
Returns:
True if the character exists in the font definition. False otherwise.
float SpriteFont.GetAdvance ( char  c  ) 

Returns the xAdvance of the specified character. 0 is returned if the character isn't supported.

Parameters:
c The character to look up.
Returns:
The xAdvance of the character.
SpriteChar SpriteFont.GetSpriteChar ( char  ch  ) 

Returns a reference to the SpriteChar that corresponds to the specified character ID (usually the numeric Unicode value).

Parameters:
ch The numeric value/code of the desired character. This value can be obtained from a char with Convert.ToInt32().
Returns:
Reference to the corresponding SpriteChar that contains information about the character.
float SpriteFont.GetWidth ( char  prevChar,
char  c 
)

Gets how wide the specified character would be, in pixels, when displayed.

Parameters:
prevChar The character previous to that being measured.
str The character to measure.
Returns:
The width, in pixels, of the character, as displayed (includes the xAdvance).
float SpriteFont.GetWidth ( StringBuilder  sb,
int  start,
int  end 
)

Gets how wide the specified string would be, in pixels.

Parameters:
str The string to measure.
start The index of the first character of the substring to be measured.
end The index of the last character of the substring.
Returns:
The width, in pixels, of the string.
float SpriteFont.GetWidth ( string  str,
int  start,
int  end 
)

Gets how wide the specified string would be, in pixels.

Parameters:
str The string to measure.
start The index of the first character of the substring to be measured.
end The index of the last character of the substring.
Returns:
The width, in pixels, of the string.
float SpriteFont.GetWidth ( string  str  ) 

Gets how wide the specified string would be, in pixels.

Parameters:
str The string to measure.
Returns:
The width, in pixels, of the string.
void SpriteFont.Load ( TextAsset  def  ) 

Loads a font from the specified font definition TextAsset and adds it to the font store.

Parameters:
fontDef The TextAsset that defines the font.
string SpriteFont.RemoveUnsupportedCharacters ( string  str  ) 

Returns a version of the specified string with all characters removed which are not defined for this font.

Parameters:
str The string to be stripped of unsupported characters.
Returns:
A new string containing only those characters supported by this font.

Member Data Documentation

string SpriteFont.face [protected]

The name of the font face.

TextAsset SpriteFont.fontDef

The TextAsset that defines the font.


Property Documentation

int SpriteFont.BaseHeight [get]

The distance, in pixels, from the absolute top of a line to the baseline:.

float SpriteFont.CharacterSpacing [get, set]

An adjustable factor by which you can increase/decrease the spacing between characters. A value of 1.0 will space characters exactly as described by the font. Decreasing this value will place the characters closer together, while increasing it will place them farther apart.

int SpriteFont.LineHeight [get, set]

The default height, in pixels, between lines.

int SpriteFont.PixelSize [get]

The size (height) of the font, in pixels. This is the height, in pixels of a full-height character.


The documentation for this class was generated from the following file:

Generated on Thu Sep 8 16:31:17 2011 for EZ GUI by  doxygen 1.6.1