2020-08-04 01:27:35 +08:00
|
|
|
|
#include<hgl/graph/font/TileFont.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKDevice.h>
|
2020-07-31 18:01:28 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
|
|
|
|
/**
|
|
|
|
|
* 创建只使用一种字符的Tile字符管理对象
|
|
|
|
|
* @param f 字体需求信息
|
|
|
|
|
* @param limit_count 缓冲字符数量上限
|
|
|
|
|
*/
|
2020-10-21 12:39:22 +08:00
|
|
|
|
TileFont *GPUDevice::CreateTileFont(FontSource *fs,int limit_count)
|
2020-07-31 18:01:28 +08:00
|
|
|
|
{
|
2020-08-04 18:28:34 +08:00
|
|
|
|
if(!fs)return(nullptr);
|
|
|
|
|
|
2022-02-18 12:01:42 +08:00
|
|
|
|
const uint32_t height=hgl_align2(fs->GetCharHeight()+2,4); //上下左右各空一个象素,并保证可以被4整除
|
2020-07-31 18:01:28 +08:00
|
|
|
|
|
|
|
|
|
if(limit_count<=0)
|
|
|
|
|
{
|
|
|
|
|
const VkExtent2D &ext=GetSwapchainSize();
|
|
|
|
|
|
2022-02-18 19:04:48 +08:00
|
|
|
|
limit_count=(ext.width/height)*(ext.height/height); //按全屏幕放满不一样的字符为上限
|
2020-07-31 18:01:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!fs)
|
|
|
|
|
return(nullptr);
|
|
|
|
|
|
2021-06-24 19:25:43 +08:00
|
|
|
|
TileData *td=CreateTileData(UPF_R8,height,height,limit_count);
|
2020-07-31 18:01:28 +08:00
|
|
|
|
|
|
|
|
|
if(!td)
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
return(new TileFont(td,fs));
|
|
|
|
|
}
|
|
|
|
|
VK_NAMESPACE_END
|