diff --git a/CMCore b/CMCore index c2c7c42c..3895fbbd 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit c2c7c42cd43759a9a613b6ad2c890a2e1d948b37 +Subproject commit 3895fbbd4dac907c12fecc88576ac8c55ad8f9fb diff --git a/example/Vulkan/DrawText.cpp b/example/Vulkan/DrawText.cpp index ded16948..a9b9b758 100644 --- a/example/Vulkan/DrawText.cpp +++ b/example/Vulkan/DrawText.cpp @@ -57,7 +57,7 @@ private: bool InitTileFont() { - Font fnt(OS_TEXT("Consolas"),0,CHAR_BITMAP_SIZE); + Font fnt(OS_TEXT("微软雅黑"),0,CHAR_BITMAP_SIZE); tile_font=device->CreateTileFont(fnt); return(true); @@ -145,7 +145,8 @@ private: if(!tl_engine.Init()) return(false); - UTF16String str=U16_TEXT("道可道,非常道。名可名,非常名。无名天地之始。有名万物之母。故常无欲以观其妙。常有欲以观其徼。此两者同出而异名,同谓之玄。玄之又玄,众妙之门。"); + UTF16String str; + LoadStringFromTextFile(str,OS_TEXT("res/text/DaoDeBible.txt")); if(tl_engine.SimpleLayout(tile_font,str)>0) { diff --git a/inc/hgl/graph/font/FontSource.h b/inc/hgl/graph/font/FontSource.h index 47851f03..53d7dd3b 100644 --- a/inc/hgl/graph/font/FontSource.h +++ b/inc/hgl/graph/font/FontSource.h @@ -52,7 +52,7 @@ namespace hgl /** * 字符排版属性 */ - struct CharLayoutAttributes:public CharAttributes + struct CharLayoutAttributes { CharAttributes *attr; ///<字符基本信息 diff --git a/inc/hgl/graph/font/TextLayout.h b/inc/hgl/graph/font/TextLayout.h index 59ae5739..05eee4e0 100644 --- a/inc/hgl/graph/font/TextLayout.h +++ b/inc/hgl/graph/font/TextLayout.h @@ -121,8 +121,9 @@ namespace hgl int sl_v_r2l(); int sl_v_l2r(); - template - int SimpleLayout (TileFont *,const BaseString &); ///<简易排版 + template int SimpleLayout(TileFont *,const BaseString &); ///<简易排版 + +// template int SimpleLayout(TileFont *,const StringList> &); ///<简易排版 protected: @@ -168,6 +169,9 @@ namespace hgl int SimpleLayout (TileFont *,const UTF16String &); ///<简易排版 int SimpleLayout (TileFont *,const UTF32String &); ///<简易排版 + +// int SimpleLayout (TileFont *,const UTF16StringList &); ///<简易排版 +// int SimpleLayout (TileFont *,const UTF32StringList &); ///<简易排版 };//class TextLayout }//namespace graph }//namespace hgl diff --git a/res b/res index 8e31af94..f8af997d 160000 --- a/res +++ b/res @@ -1 +1 @@ -Subproject commit 8e31af94c83e4114673e19db2ea7593522bae16e +Subproject commit f8af997de769b0d535dc933d2ee48984834b32d0 diff --git a/src/RenderDevice/Vulkan/VKTileFont.cpp b/src/RenderDevice/Vulkan/VKTileFont.cpp index 025cb5f4..9049ec3f 100644 --- a/src/RenderDevice/Vulkan/VKTileFont.cpp +++ b/src/RenderDevice/Vulkan/VKTileFont.cpp @@ -17,10 +17,7 @@ VK_NAMESPACE_BEGIN */ TileFont *Device::CreateTileFont(const Font &f,int limit_count) { - int height=(f.height+3)>>2; - - height<<=2; //保证可以被4整除 - height+=2; //上下左右各空一个象素 + int height=((f.height+2+3)>>2)<<2; //上下左右各空一个象素,并保证可以被4整除 if(limit_count<=0) { diff --git a/src/SceneGraph/font/FontSource.cpp b/src/SceneGraph/font/FontSource.cpp index 93a5aae8..1959090c 100644 --- a/src/SceneGraph/font/FontSource.cpp +++ b/src/SceneGraph/font/FontSource.cpp @@ -88,6 +88,10 @@ namespace hgl cla->visible=(cla->metrics.w>0&&cla->metrics.h>0); } } + else + { + cla->visible=false; + } cla_cache.Add(ch,cla); return cla; diff --git a/src/SceneGraph/font/FontSourceWin.cpp b/src/SceneGraph/font/FontSourceWin.cpp index 8a7b3498..2741a96c 100644 --- a/src/SceneGraph/font/FontSourceWin.cpp +++ b/src/SceneGraph/font/FontSourceWin.cpp @@ -136,6 +136,7 @@ namespace hgl bmp->metrics_info.adv_y =gm.gmCellIncY; bmp->data=new uint8[bmp->metrics_info.w*bmp->metrics_info.h]; + memset(bmp->data,0,bmp->metrics_info.w*bmp->metrics_info.h); if(ggo==GGO_GRAY8_BITMAP) Convert8BitGrey(bmp->data,bmp->metrics_info.w,buffer,gm.gmBlackBoxX,gm.gmBlackBoxY,size/gm.gmBlackBoxY); diff --git a/src/SceneGraph/font/TextLayout.cpp b/src/SceneGraph/font/TextLayout.cpp index 7f6ec3cc..ec4f18a5 100644 --- a/src/SceneGraph/font/TextLayout.cpp +++ b/src/SceneGraph/font/TextLayout.cpp @@ -97,7 +97,7 @@ namespace hgl for(int i=0;icla->ch,(*cda)->uv); + alone_chars_uv.Get((*cda)->cla->attr->ch,(*cda)->uv); ++cda; } @@ -181,19 +181,37 @@ namespace hgl if((*cda)->cla->visible) { tp=WriteRect( tp, - left, - top, + left+(*cda)->cla->metrics.x, + top -(*cda)->cla->metrics.y+font_source->GetCharHeight(), (*cda)->cla->metrics.w, (*cda)->cla->metrics.h); tcp=WriteRect(tcp,(*cda)->uv); + + left+=(*cda)->cla->metrics.adv_x; } else - { + { + if((*cda)->cla->attr->ch==' ') + left+=tla.space_size; + else + if((*cda)->cla->attr->ch==HGL_FULL_SPACE) + left+=tla.full_space_size; + else + if((*cda)->cla->attr->ch=='\t') + left+=tla.tab_size; + else + if((*cda)->cla->attr->ch=='\n') + { + left=0; + top+=font_source->GetCharHeight()+tla.line_gap; + } + else + { + left+=(*cda)->cla->metrics.adv_x; + } } - left+=(*cda)->cla->metrics.adv_x; - ++cda; } @@ -251,5 +269,13 @@ namespace hgl int TextLayout::SimpleLayout(TileFont *tf,const UTF16String &str){return this->SimpleLayout(tf,str);} int TextLayout::SimpleLayout(TileFont *tf,const UTF32String &str){return this->SimpleLayout(tf,str);} + + //template + //int TextLayout::SimpleLayout(TileFont *tf,const StringList> &sl) + //{ + //} + + //int TextLayout::SimpleLayout(TileFont *tf,const UTF16StringList &sl){return this->SimpleLayout(tf,sl);} + //int TextLayout::SimpleLayout(TileFont *tf,const UTF32StringList &sl){return this->SimpleLayout(tf,sl);} }//namespace graph }//namespace hgl diff --git a/src/SceneGraph/font/TileFont.cpp b/src/SceneGraph/font/TileFont.cpp index 7a1bd112..d1eb95e6 100644 --- a/src/SceneGraph/font/TileFont.cpp +++ b/src/SceneGraph/font/TileFont.cpp @@ -58,11 +58,19 @@ namespace hgl if(!to_res.Get(*cp,to)) { bmp=source->GetCharBitmap(*cp); - to=tile_data->Commit( bmp->data, - bmp->metrics_info.w*bmp->metrics_info.h, - bmp->metrics_info.w,bmp->metrics_info.h); - to_res.Add(*cp,to); + if(bmp) + { + to=tile_data->Commit( bmp->data, + bmp->metrics_info.w*bmp->metrics_info.h, + bmp->metrics_info.w,bmp->metrics_info.h); + + to_res.Add(*cp,to); + } + else + { + + } } uv_map.Add(*cp,to->uv_float);