Class "Font"⚓︎
Info
This class can be accessed by using its constructor or this function:
Example Code
1 | |
Constructors⚓︎
Font ()⚓︎
Font Font ( )⚓︎
Constructor for the "Font" class.
Example Code
Example usage.
1 2 3 | |
Functions⚓︎
Draw·String ()⚓︎
void DrawString ( string String, float PositionX, float PositionY, KColor RenderColor, int BoxWidth = 0, boolean Center = false )⚓︎
void DrawString ( string String, float PositionX, float PositionY, float sizeX, float sizeY, KColor RenderColor, FontRenderSettings settings )⚓︎
Converts UTF8 to UTF16, then draws the string on screen.
The BoxWidth and Center parameters can be used for aligning the text. Some things to note about this:
- If
BoxWidthis zero, the text will be left-aligned and theCenterparameter will be ignored. - If
BoxWidthis NOT zero, and theCenterparameter isfalse, then the text will be right-aligned inside theBoxWidthsize. - If
BoxWidthis NOT zero, and theCenterparameter istrue, then the text will be centered inside theBoxWidthsize.
Bug
Calling this function with nil as either the String or RenderColor parameters will crash the game.
Example Code
Example usage.
1 2 3 4 5 6 | |
Draw·String·Scaled ()⚓︎
void DrawStringScaled ( string String, float PositionX, float PositionY, float ScaleX, float ScaleY, KColor RenderColor, int BoxWidth = 0, boolean Center = false )⚓︎
Converts UTF8 to UTF16, then draws the scaled string on the screen.
Bug
Calling this function with nil as either the String or RenderColor parameters will crash the game.
Example Code
Example usage.
1 2 3 | |
Draw·String·Scaled·UTF8 ()⚓︎
void DrawStringScaledUTF8 ( string String, float PositionX, float PositionY, float ScaleX, float ScaleY, KColor RenderColor, int BoxWidth = 0, boolean Center = false )⚓︎
Draws a scaled string of Unicode text on the screen.
Bug
Calling this function with nil as either the String or RenderColor parameters will crash the game.
Example Code
Example usage.
1 2 3 | |
Draw·String·UTF8 ()⚓︎
void DrawStringUTF8 ( string String, float PositionX, float PositionY, KColor RenderColor, int BoxWidth = 0, boolean Center = false )⚓︎
Draws a string of Unicode text on the screen.
The BoxWidth and Center parameters can be used for aligning the text. Some things to note about this:
- If
BoxWidthis zero, the text will be left-aligned and theCenterparameter will be ignored. - If
BoxWidthis NOT zero, and theCenterparameter isfalse, then the text will be right-aligned inside theBoxWidthsize. - If
BoxWidthis NOT zero, and theCenterparameter istrue, then the text will be centered inside theBoxWidthsize.
Bug
Calling this function with nil as either the String or RenderColor parameters will crash the game.
Example Code
Example usage.
1 2 3 | |
Get·Baseline·Height ()⚓︎
int GetBaselineHeight ( )⚓︎
Returns the number of pixels from the absolute top of the line to the base of the characters.
Get·Character·Width ()⚓︎
int GetCharacterWidth ( char Character )⚓︎
Returns the width of a specific character in pixels.
Get·Line·Height ()⚓︎
int GetLineHeight ( )⚓︎
Returns the distance in pixels between each line of text.
Get·String·Width ()⚓︎
int GetStringWidth ( string String )⚓︎
Converts a string from UTF8 to UTF16, and returns the string's width in pixels.
Bug
Calling this function with nil as the parameter will crash the game.
Get·String·Width·UTF8 ()⚓︎
int GetStringWidthUTF8 ( string String )⚓︎
Returns the string width of a Unicode text in pixels.
Is·Loaded ()⚓︎
boolean IsLoaded ( )⚓︎
Returns whether a font is loaded or not.
Load ()⚓︎
void Load ( string FilePath )⚓︎
Loads a font. To check that the font actually got loaded, call the IsLoaded() method afterwards.
Bug
When loading a custom font, the path provided to this function is actually relative to the game's resources folder instead of your mod's resources folder, which is inconsistent with things such as Sprite:Load(). You can load a custom font with the following code:
1 2 3 4 5 | |
Example Code
Example usage.
1 2 3 | |
Set·Missing·Character ()⚓︎
void SetMissingCharacter ( char MissingCharacter )⚓︎
Sets the character that will be used when a missing character is encountered by the font.
Unload ()⚓︎
void Unload ( )⚓︎
Unloads the font from memory.