DOF/sqr/User/Asset/FontAsset.nut

53 lines
1.5 KiB
Plaintext

/*
文件名:FontAsset.nut
路径:User/Asset/FontAsset.nut
创建日期:2024-12-10 11:37
文件用途:
*/
class _FontAssetManager_ {
//初始化字体
function InitFont() {
//普通宋体小字
// Font.PreLoad("新宋体");
Font("新宋体", 11.5).Register(0);
Font("新宋体", 10).Register(1);
}
constructor() {
//初始化字体
InitFont();
getroottable().FontAssetManager <- this;
}
//生成普通宋体小字
function GenerateNormal(text, stroke, style = {}) {
//如果有设置换行宽度 则设置默认的自动换行模式
if (!(style.rawin("word_wrapping")) && style.rawin("wrap_width")) {
style.word_wrapping <- TextWordWrapping.WRAPPING_CHARACTER;
}
//登录按钮文本
local TextActor = TextActor(0, style);
TextActor.SetText(text);
if (stroke)
TextActor.SetOutline();
return TextActor;
}
//生成普通宋体小字
function GenerateMini(text, stroke, style = {}) {
//如果有设置换行宽度 则设置默认的自动换行模式
if (!(style.rawin("word_wrapping")) && style.rawin("wrap_width")) {
style.word_wrapping <- TextWordWrapping.WRAPPING_CHARACTER;
}
//登录按钮文本
local TextActor = TextActor(1, style);
TextActor.SetText(text);
if (stroke)
TextActor.SetOutline();
return TextActor;
}
}