Class "Font"⚓︎
Constructors⚓︎
Font ()⚓︎
Font Font ( )⚓︎
"Font" 类的构造函数.
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 )⚓︎
将 UTF8 转换为 UTF16,然后在屏幕上绘制字符串.
BoxWidth 和 Center 变量可以用于对齐文本。需要注意以下几点:
- 如果
BoxWidth为零,文本将左对齐,Center参数会被忽略. - 如果
BoxWidth不为零,且Center参数为false,则文本会在BoxWidth范围内右对齐. - 如果
BoxWidth不为零,且Center参数为true,则文本会在BoxWidth范围内居中对齐.
Bug
如果调用此函数时 String 或 RenderColor 参数为 nil,游戏会崩溃.
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 )⚓︎
将 UTF8 转换为 UTF16,然后在屏幕上绘制缩放后的字符串.
Bug
如果调用此函数时 String 或 RenderColor 参数为 nil ,游戏会崩溃.
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 )⚓︎
在屏幕上绘制缩放后的 Unicode 文本字符串.
Bug
如果调用此函数时 String 或 RenderColor 参数为 nil ,游戏会崩溃.
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 )⚓︎
在屏幕上绘制一串 Unicode 文本.
BoxWidth 和 Center 参数可用于对齐文本,注意如下:
- 如果
BoxWidth为零,文本将左对齐,Center参数会被忽略. - 如果
BoxWidth不为零,且Center参数为false,则文本会在BoxWidth范围内右对齐. - 如果
BoxWidth不为零,且Center参数为true,则文本会在BoxWidth范围内居中对齐.
Bug
如果调用此函数时 String 或 RenderColor 参数为 nil,游戏会崩溃。
Example Code
Example usage.
1 2 3 | |
Get·Baseline·Height ()⚓︎
int GetBaselineHeight ( )⚓︎
返回从行的绝对顶部到字符基线的像素数(基准高度).
Get·Character·Width ()⚓︎
int GetCharacterWidth ( char Character )⚓︎
返回指定字符的像素宽度.
Get·Line·Height ()⚓︎
int GetLineHeight ( )⚓︎
返回每行文本之间的像素距离(行高度).
Get·String·Width ()⚓︎
int GetStringWidth ( string String )⚓︎
将字符串从 UTF8 转换为 UTF16,并返回该字符串的像素宽度.
Bug
如果调用此函数时参数为 nil,游戏会崩溃.
Get·String·Width·UTF8 ()⚓︎
int GetStringWidthUTF8 ( string String )⚓︎
返回 Unicode 文本的像素宽度.
Is·Loaded ()⚓︎
boolean IsLoaded ( )⚓︎
返回字体是否已被加载.
Load ()⚓︎
void Load ( string FilePath )⚓︎
加载字体。要检查字体是否实际加载成功,可随后调用 IsLoaded() 方法.
Bug
加载自定义字体时,传递给此函数的路径实际上是相对于游戏的 resources 文件夹,而不是你的 mod 的 resources 文件夹,这与 Sprite:Load() 等函数的行为不一致。你可以用如下代码加载自定义字体:
1 2 3 4 5 | |
Example Code
Example usage.
1 2 3 | |
Set·Missing·Character ()⚓︎
void SetMissingCharacter ( char MissingCharacter )⚓︎
设置当字体遇到缺失字符时所使用的字符.
Unload ()⚓︎
void Unload ( )⚓︎
从内存中卸载字体.