ULRE/src/RenderDevice/Vulkan/VKTileFont.cpp

45 lines
1020 B
C++
Raw Normal View History

2020-07-31 18:01:28 +08:00
#include<hgl/graph/font/TileFont.h>
#include<hgl/graph/vulkan/VKDevice.h>
namespace hgl
{
namespace graph
{
FontSource *AcquireFontSource(const Font &f);
}//namespace graph
}//namespace hgl
VK_NAMESPACE_BEGIN
/**
* 使Tile字符管理对象
* @param f
* @param limit_count
*/
TileFont *Device::CreateTileFont(const Font &f,int limit_count)
{
int height=(f.height+3)>>2;
height<<=2; //保证可以被4整除
height+=2; //上下左右各空一个象素
if(limit_count<=0)
{
const VkExtent2D &ext=GetSwapchainSize();
limit_count=(ext.width/height)*(ext.height/height); //按全屏幕放满不一样的字符为上限
}
FontSource *fs=AcquireFontSource(f);
if(!fs)
return(nullptr);
TileData *td=CreateTileData(UFMT_R8,height,height,limit_count);
if(!td)
return nullptr;
return(new TileFont(td,fs));
}
VK_NAMESPACE_END