Font

Simple wrapper for the font class. Before a font can be used it must have process() called.
Return to Index
static new ( string font_name )
__gc ( )
__eq ( am.font rhs ) -> ( boolean )
asset ( ) -> ( string )
asset ( string asset_name ) -> ( am.font )
name ( ) -> ( string )
fixed_width ( ) -> ( boolean )
fixed_width ( boolean fixed_width ) -> ( am.font )
char_width ( integer char_code ) -> ( number )
char_width ( string char ) -> ( number )
char_height ( ) -> ( number )
kerning ( ) -> ( number )
kerning ( number kerning ) -> ( am.font )
leading ( ) -> ( number )
leading ( number leading ) -> ( am.font )
space_width ( ) -> ( number )
space_width ( number space_width ) -> ( am.font )
tab_width ( ) -> ( number )
tab_width ( number tab_width ) -> ( am.font )
measure_text ( string text , number contain_width , string/integer end_character = \0 ) -> ( number , number )
measure_line ( string text , number contain_width ) -> ( number , number )
measure_word ( string word ) -> ( number , number )
process ( ) -> ( am.font )
static new ( string font_name )
Creates a new font using the given name.
Parameters:
string font_name : Name of the font.
__gc ( )
Releases the reference counter on the font.
__eq ( am.font rhs ) -> ( boolean )
Compares this font with another font object.
Parameters:
am.font rhs : The other font to compare with.
Returns:
boolean : True if they are the same object.
asset ( ) -> ( string )
Returns the asset name currently used by this font. An empty string indicates that no asset has been set.
Returns:
string : The asset name is use.
asset ( string asset_name ) -> ( am.font )
Sets the asset name for this sprite to use.
Parameters:
string asset_name : The name of the asset to use.
Returns:
am.font : This
name ( ) -> ( string )
Returns the name of the font.
Returns:
string : The name of the font.
fixed_width ( ) -> ( boolean )
Returns if the font is a monospaced/fixed width font.
Returns:
boolean : True if a fixed width font.
fixed_width ( boolean fixed_width ) -> ( am.font )
Sets if the font should be fixed width or variable width. The width of each character is calculated based on the amount of transparent pixels on either side of each character.
Parameters:
boolean fixed_width : Weather the font is fixed width or not.
Returns:
am.font : This
char_width ( integer char_code ) -> ( number )
Returns the pixel width of the given character. This will always be the same for mono spaced fonts. The char_code should be an ASCII value.
Parameters:
integer char_code : The ASCII character to check.
Returns:
number : The width of the given character.
char_width ( string char ) -> ( number )
Returns the pixel width of the first character in the given string. This will always be the same for mono spaced fonts.
Parameters:
string char : The character to check.
Returns:
number : The width of the given character.
char_height ( ) -> ( number )
Returns the pixel height of each character. Each character is considered to have the same height.
Returns:
number : The character height.
kerning ( ) -> ( number )
Returns the kerning of the font.
Returns:
number : The kerning.
kerning ( number kerning ) -> ( am.font )
Sets the kerning of the font.
Parameters:
number kerning : The kerning to set.
Returns:
am.font : This
leading ( ) -> ( number )
Returns the leading of the font.
Returns:
number : The leading.
leading ( number leading ) -> ( am.font )
Sets the leading of the font.
Parameters:
number leading : The leading to set.
Returns:
am.font : This
space_width ( ) -> ( number )
Returns the space width of the font.
Returns:
number : The space width.
space_width ( number space_width ) -> ( am.font )
Sets the space width of the font.
Parameters:
number space_width : The space width to set.
Returns:
am.font : This
tab_width ( ) -> ( number )
Returns the tab width of the font.
Returns:
number : The tab_width.
tab_width ( number tab_width ) -> ( am.font )
Sets the tab width of the font.
Parameters:
number tab_width : The tab_width to set.
Returns:
am.font : This
measure_text ( string text , number contain_width , string/integer end_character = \0 ) -> ( number , number )
Measures the space in pixels that the given block of text would take up when contained to the given width. The end_character is the final character to measure up to. Defaults to the null character which indicates the end of the string. Can be changed to "\n"/13 (new line) or "."/46 (period) or even "A"/65 (A).
Parameters:
string text : The text to measure.
number contain_width : The width of the container.
string/integer end_character = \0 : The ending character.
Returns:
number : The width that would be taken up.
number : The height that would be taken up.
measure_line ( string text , number contain_width ) -> ( number , number )
Measures the space in pixels that the given line of text would take up when contained to the given width. Essentially calls measure text with the end character being a new line.
Parameters:
string text : The text to measure.
number contain_width : The width of the container.
Returns:
number : The width that would be taken up.
number : The height that would be taken up.
measure_word ( string word ) -> ( number , number )
Measures the space in pixels that the given word.
Parameters:
string word : The word to measure.
Returns:
number : The width that would be taken up.
number : The height that would be taken up.
process ( ) -> ( am.font )
Processes the font based on it's current values. This must be done after any changes are made to the font, including when the font is being created. This calculates all the character sizes and creates all the texture windows for each character.
Returns:
am.font : This