update TileFont

This commit is contained in:
hyzboy 2020-08-04 18:28:34 +08:00
parent 3355a75cdf
commit 324003ec6d
6 changed files with 18 additions and 21 deletions

2
CMCore

@ -1 +1 @@
Subproject commit 3895fbbd4dac907c12fecc88576ac8c55ad8f9fb
Subproject commit c826b3d8e5c0cb77f10729ce81bb388313094a5e

@ -1 +1 @@
Subproject commit 02ede84ecd6e25cd705503018a53444bfda5af39
Subproject commit 780a97d2435577b6fc6008bb656e623c5c058431

View File

@ -16,10 +16,9 @@ using namespace hgl;
using namespace hgl::graph;
constexpr uint32_t SCREEN_WIDTH =1280;
constexpr uint32_t SCREEN_HEIGHT=960;
constexpr uint32_t SCREEN_HEIGHT=SCREEN_WIDTH/16*9;
constexpr uint CHAR_BITMAP_SIZE=16; //字符尺寸
constexpr uint CHAR_BITMAP_BORDER=1; //边界象素尺寸
constexpr uint CHAR_BITMAP_SIZE=14; //字符尺寸
class TestApp:public VulkanApplicationFramework
{
@ -40,6 +39,8 @@ private:
private:
FontSource * font_source =nullptr;
TileFont * tile_font;
TextLayout tl_engine; ///<文本排版引擎
@ -57,9 +58,11 @@ private:
bool InitTileFont()
{
Font fnt(OS_TEXT("微软雅黑"),0,CHAR_BITMAP_SIZE);
Font chs_fnt(OS_TEXT("微软雅黑"),0,CHAR_BITMAP_SIZE);
tile_font=device->CreateTileFont(fnt);
font_source=AcquireFontSource(chs_fnt);
tile_font=device->CreateTileFont(font_source);
return(true);
}
@ -131,6 +134,7 @@ private:
cla.BackgroundColor=Color4f(COLOR::Black);
tla.char_layout_attr=&cla;
tla.line_gap=0.2f;
text_rc=new RenderableCreater(db,material);

View File

@ -20,6 +20,7 @@ namespace hgl
{
class TileData;
class TileFont;
class FontSource;
}//namespace graph
}//namespace hgl
@ -265,7 +266,7 @@ public:
TileData *CreateTileData(const VkFormat video_format,const uint width,const uint height,const uint count); ///<创建一个Tile数据集
TileFont *CreateTileFont(const Font &f,int limit_count=-1); ///<创建一个Tile字体
TileFont *CreateTileFont(FontSource *fs,int limit_count=-1); ///<创建一个Tile字体
};//class Device
Device *CreateRenderDevice(Instance *inst,Window *win,const PhysicalDevice *physical_device=nullptr);

2
res

@ -1 +1 @@
Subproject commit f8af997de769b0d535dc933d2ee48984834b32d0
Subproject commit 89ec7b496644d38d5baf52b9fe98f74cc79ffa01

View File

@ -1,23 +1,17 @@
#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)
TileFont *Device::CreateTileFont(FontSource *fs,int limit_count)
{
int height=((f.height+2+3)>>2)<<2; //上下左右各空一个象素并保证可以被4整除
if(!fs)return(nullptr);
int height=((fs->GetCharHeight()+2+3)>>2)<<2; //上下左右各空一个象素并保证可以被4整除
if(limit_count<=0)
{
@ -26,8 +20,6 @@ TileFont *Device::CreateTileFont(const Font &f,int limit_count)
limit_count=(ext.width/height)*(ext.height/height); //按全屏幕放满不一样的字符为上限
}
FontSource *fs=AcquireFontSource(f);
if(!fs)
return(nullptr);