update TileFont
This commit is contained in:
parent
3355a75cdf
commit
324003ec6d
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit 3895fbbd4dac907c12fecc88576ac8c55ad8f9fb
|
Subproject commit c826b3d8e5c0cb77f10729ce81bb388313094a5e
|
@ -1 +1 @@
|
|||||||
Subproject commit 02ede84ecd6e25cd705503018a53444bfda5af39
|
Subproject commit 780a97d2435577b6fc6008bb656e623c5c058431
|
@ -16,10 +16,9 @@ using namespace hgl;
|
|||||||
using namespace hgl::graph;
|
using namespace hgl::graph;
|
||||||
|
|
||||||
constexpr uint32_t SCREEN_WIDTH =1280;
|
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_SIZE=14; //字符尺寸
|
||||||
constexpr uint CHAR_BITMAP_BORDER=1; //边界象素尺寸
|
|
||||||
|
|
||||||
class TestApp:public VulkanApplicationFramework
|
class TestApp:public VulkanApplicationFramework
|
||||||
{
|
{
|
||||||
@ -40,6 +39,8 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
FontSource * font_source =nullptr;
|
||||||
|
|
||||||
TileFont * tile_font;
|
TileFont * tile_font;
|
||||||
TextLayout tl_engine; ///<文本排版引擎
|
TextLayout tl_engine; ///<文本排版引擎
|
||||||
|
|
||||||
@ -57,9 +58,11 @@ private:
|
|||||||
|
|
||||||
bool InitTileFont()
|
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);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +134,7 @@ private:
|
|||||||
cla.BackgroundColor=Color4f(COLOR::Black);
|
cla.BackgroundColor=Color4f(COLOR::Black);
|
||||||
|
|
||||||
tla.char_layout_attr=&cla;
|
tla.char_layout_attr=&cla;
|
||||||
|
tla.line_gap=0.2f;
|
||||||
|
|
||||||
text_rc=new RenderableCreater(db,material);
|
text_rc=new RenderableCreater(db,material);
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
class TileData;
|
class TileData;
|
||||||
class TileFont;
|
class TileFont;
|
||||||
|
class FontSource;
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
|
||||||
@ -265,7 +266,7 @@ public:
|
|||||||
|
|
||||||
TileData *CreateTileData(const VkFormat video_format,const uint width,const uint height,const uint count); ///<创建一个Tile数据集
|
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
|
};//class Device
|
||||||
|
|
||||||
Device *CreateRenderDevice(Instance *inst,Window *win,const PhysicalDevice *physical_device=nullptr);
|
Device *CreateRenderDevice(Instance *inst,Window *win,const PhysicalDevice *physical_device=nullptr);
|
||||||
|
2
res
2
res
@ -1 +1 @@
|
|||||||
Subproject commit f8af997de769b0d535dc933d2ee48984834b32d0
|
Subproject commit 89ec7b496644d38d5baf52b9fe98f74cc79ffa01
|
@ -1,23 +1,17 @@
|
|||||||
#include<hgl/graph/font/TileFont.h>
|
#include<hgl/graph/font/TileFont.h>
|
||||||
#include<hgl/graph/vulkan/VKDevice.h>
|
#include<hgl/graph/vulkan/VKDevice.h>
|
||||||
|
|
||||||
namespace hgl
|
|
||||||
{
|
|
||||||
namespace graph
|
|
||||||
{
|
|
||||||
FontSource *AcquireFontSource(const Font &f);
|
|
||||||
}//namespace graph
|
|
||||||
}//namespace hgl
|
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
/**
|
/**
|
||||||
* 创建只使用一种字符的Tile字符管理对象
|
* 创建只使用一种字符的Tile字符管理对象
|
||||||
* @param f 字体需求信息
|
* @param f 字体需求信息
|
||||||
* @param limit_count 缓冲字符数量上限
|
* @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)
|
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); //按全屏幕放满不一样的字符为上限
|
limit_count=(ext.width/height)*(ext.height/height); //按全屏幕放满不一样的字符为上限
|
||||||
}
|
}
|
||||||
|
|
||||||
FontSource *fs=AcquireFontSource(f);
|
|
||||||
|
|
||||||
if(!fs)
|
if(!fs)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user