diff --git a/CMCore b/CMCore index 3895fbbd..c826b3d8 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit 3895fbbd4dac907c12fecc88576ac8c55ad8f9fb +Subproject commit c826b3d8e5c0cb77f10729ce81bb388313094a5e diff --git a/CMSceneGraph b/CMSceneGraph index 02ede84e..780a97d2 160000 --- a/CMSceneGraph +++ b/CMSceneGraph @@ -1 +1 @@ -Subproject commit 02ede84ecd6e25cd705503018a53444bfda5af39 +Subproject commit 780a97d2435577b6fc6008bb656e623c5c058431 diff --git a/example/Vulkan/DrawText.cpp b/example/Vulkan/DrawText.cpp index a9b9b758..ee020293 100644 --- a/example/Vulkan/DrawText.cpp +++ b/example/Vulkan/DrawText.cpp @@ -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); diff --git a/inc/hgl/graph/vulkan/VKDevice.h b/inc/hgl/graph/vulkan/VKDevice.h index 733e3333..1fb86ebe 100644 --- a/inc/hgl/graph/vulkan/VKDevice.h +++ b/inc/hgl/graph/vulkan/VKDevice.h @@ -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); diff --git a/res b/res index f8af997d..89ec7b49 160000 --- a/res +++ b/res @@ -1 +1 @@ -Subproject commit f8af997de769b0d535dc933d2ee48984834b32d0 +Subproject commit 89ec7b496644d38d5baf52b9fe98f74cc79ffa01 diff --git a/src/RenderDevice/Vulkan/VKTileFont.cpp b/src/RenderDevice/Vulkan/VKTileFont.cpp index 9049ec3f..4f046308 100644 --- a/src/RenderDevice/Vulkan/VKTileFont.cpp +++ b/src/RenderDevice/Vulkan/VKTileFont.cpp @@ -1,23 +1,17 @@ #include #include -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);