diff --git a/inc/hgl/graph/font/FontSource.h b/inc/hgl/graph/font/FontSource.h index 94568970..9a1c3911 100644 --- a/inc/hgl/graph/font/FontSource.h +++ b/inc/hgl/graph/font/FontSource.h @@ -13,13 +13,13 @@ namespace hgl { namespace graph { - struct FontAdvInfo + struct CharMetricsInfo { int x,y; //图像显示偏移 int w,h; //图像尺寸 int adv_x,adv_y;//字符尺寸 - };//struct FontAdvInfo + };//struct CharMetricsInfo /** * 字体位图数据 @@ -28,7 +28,7 @@ namespace hgl { int count; //使用次数 - FontAdvInfo adv_info; + CharMetricsInfo metrics_info; uint8 *data; };//struct FontBitmap @@ -47,7 +47,7 @@ namespace hgl virtual ~FontSource()=default; virtual FontBitmap *GetCharBitmap (const u32char &)=0; ///<取得字符位图数据 - virtual const bool GetCharAdvInfo (FontAdvInfo &,const u32char &); ///<取得字符绘制信息 + virtual const bool GetCharMetrics (CharMetricsInfo &,const u32char &); ///<取得字符绘制信息 virtual int GetCharHeight ()const=0; ///<取得字符高度 void RefAcquire(void *); ///<引用请求 @@ -76,7 +76,7 @@ namespace hgl virtual ~FontSourceSingle()=default; FontBitmap *GetCharBitmap (const u32char &ch) override; ///<取得字符位图数据 - const bool GetCharAdvInfo (FontAdvInfo &,const u32char &); ///<取得字符绘制信息 + const bool GetCharMetrics (CharMetricsInfo &,const u32char &); ///<取得字符绘制信息 virtual int GetCharHeight ()const override{return fnt.height;} ///<取得字符高度 };//class FontSourceSingle:public FontSource @@ -110,8 +110,10 @@ namespace hgl void Remove(UnicodeBlock); void Remove(FontSource *); + public: + FontBitmap *GetCharBitmap (const u32char &ch) override; - const bool GetCharAdvInfo (FontAdvInfo &,const u32char &); ///<取得字符绘制信息 + const bool GetCharMetrics (CharMetricsInfo &,const u32char &); ///<取得字符绘制信息 int GetCharHeight ()const override; ///<取得字符高度 };//class FontSourceMulti:public FontSource }//namespace graph diff --git a/inc/hgl/graph/font/TextLayout.h b/inc/hgl/graph/font/TextLayout.h index f4668ccd..0bd31288 100644 --- a/inc/hgl/graph/font/TextLayout.h +++ b/inc/hgl/graph/font/TextLayout.h @@ -8,6 +8,8 @@ namespace hgl { namespace graph { + class TileFont; + /** * 字符属性,可精确到字也可精确到段落或是全文 */ @@ -181,7 +183,7 @@ namespace hgl // virtual int Layout (const int max_chars,const BaseString &)=0; ///<排版 template - int PlaneLayout (const int max_chars,const BaseString &)=0; ///<简易排版 + int PlaneLayout (TileFont *,const int max_chars,const BaseString &)=0; ///<简易排版 };//class TextLayout }//namespace graph }//namespace hgl diff --git a/src/RenderDevice/Vulkan/VKRenderable.cpp b/src/RenderDevice/Vulkan/VKRenderable.cpp index 5a8177f4..28ff8a62 100644 --- a/src/RenderDevice/Vulkan/VKRenderable.cpp +++ b/src/RenderDevice/Vulkan/VKRenderable.cpp @@ -20,26 +20,26 @@ Renderable::~Renderable() delete[] buf_list; } -bool Renderable::Set(const int stage_input_binding,VertexAttribBuffer *vbo,VkDeviceSize offset) +bool Renderable::Set(const int stage_input_binding,VertexAttribBuffer *vab,VkDeviceSize offset) { - if(stage_input_binding<0||stage_input_binding>=buf_count||!vbo)return(false); + if(stage_input_binding<0||stage_input_binding>=buf_count||!vab)return(false); const VkVertexInputBindingDescription *desc=vertex_sm->GetDesc(stage_input_binding); const VkVertexInputAttributeDescription *attr=vertex_sm->GetAttr(stage_input_binding); - if(vbo->GetFormat()!=attr->format)return(false); - if(vbo->GetStride()!=desc->stride)return(false); + if(vab->GetFormat()!=attr->format)return(false); + if(vab->GetStride()!=desc->stride)return(false); //format信息来自于shader,实际中可以不一样。但那样需要为每一个格式产生一个同样shader的material instance,不同的格式又需要不同的pipeline,我们不支持这种行为 - buf_list[stage_input_binding]=vbo->GetBuffer(); + buf_list[stage_input_binding]=vab->GetBuffer(); buf_offset[stage_input_binding]=offset; return(true); } -bool Renderable::Set(const AnsiString &name,VertexAttribBuffer *vbo,VkDeviceSize offset) +bool Renderable::Set(const AnsiString &name,VertexAttribBuffer *vab,VkDeviceSize offset) { - return Set(vertex_sm->GetStageInputBinding(name),vbo,offset); + return Set(vertex_sm->GetStageInputBinding(name),vab,offset); } VK_NAMESPACE_END diff --git a/src/SceneGraph/font/FontSourceWin.cpp b/src/SceneGraph/font/FontSourceWin.cpp index a2445b83..e1b1267c 100644 --- a/src/SceneGraph/font/FontSourceWin.cpp +++ b/src/SceneGraph/font/FontSourceWin.cpp @@ -120,21 +120,21 @@ namespace hgl GetGlyphOutlineW(hdc,ch,ggo,&gm,buffer_size,buffer,&mat); - bmp->adv_info.w =gm.gmBlackBoxX; - bmp->adv_info.h =gm.gmBlackBoxY; + bmp->metrics_info.w =gm.gmBlackBoxX; + bmp->metrics_info.h =gm.gmBlackBoxY; - bmp->adv_info.x =gm.gmptGlyphOrigin.x; - bmp->adv_info.y =gm.gmptGlyphOrigin.y; + bmp->metrics_info.x =gm.gmptGlyphOrigin.x; + bmp->metrics_info.y =gm.gmptGlyphOrigin.y; - bmp->adv_info.adv_x =gm.gmCellIncX; - bmp->adv_info.adv_y =gm.gmCellIncY; + bmp->metrics_info.adv_x =gm.gmCellIncX; + bmp->metrics_info.adv_y =gm.gmCellIncY; - bmp->data=new uint8[bmp->adv_info.w*bmp->adv_info.h]; + bmp->data=new uint8[bmp->metrics_info.w*bmp->metrics_info.h]; if(ggo==GGO_GRAY8_BITMAP) - Convert8BitGrey(bmp->data,buffer,gm.gmBlackBoxX,gm.gmBlackBoxY,size/bmp->adv_info.h); + Convert8BitGrey(bmp->data,buffer,gm.gmBlackBoxX,gm.gmBlackBoxY,size/bmp->metrics_info.h); else - ConvertBitmap(bmp->data,buffer,gm.gmBlackBoxX,gm.gmBlackBoxY,size/bmp->adv_info.h); + ConvertBitmap(bmp->data,buffer,gm.gmBlackBoxX,gm.gmBlackBoxY,size/bmp->metrics_info.h); return(true); } diff --git a/src/SceneGraph/font/TextLayout.cpp b/src/SceneGraph/font/TextLayout.cpp index 531e0597..e3ff14e4 100644 --- a/src/SceneGraph/font/TextLayout.cpp +++ b/src/SceneGraph/font/TextLayout.cpp @@ -108,7 +108,7 @@ namespace hgl cla->is_punctuation =isPunctuation(*cp); - if(!tla->font_source->GetCharAdvInfo(cla->adv_info,*cp)) + if(!tla->font_source->GetCharMetrics(cla->adv_info,*cp)) hgl_zero(cla->adv_info); else if(cla->adv_info.w>0&&cla->adv_info.h>0) @@ -157,7 +157,7 @@ namespace hgl cla->vrotate =hgl::strchr(VRotateSymbols,*cp,VRotateSymbolsCount ); - if(!tla->font_source->GetCharAdvInfo(cla->adv_info,*cp)) + if(!tla->font_source->GetCharMetrics(cla->adv_info,*cp)) hgl_zero(cla->adv_info); else if(cla->adv_info.w>0&&cla->adv_info.h>0) @@ -253,7 +253,7 @@ namespace hgl * 不处理自动换行,仅支持\r\n换行。无任何特殊处理 */ template - int TextLayout::PlaneLayout(const int mc,const BaseString &str) + int TextLayout::PlaneLayout(TileFont *tf,const int mc,const BaseString &str) { if(mc<=0||str.IsEmpty() return(-1);