use CharMetricsInfo instead FontAdvInfo
This commit is contained in:
parent
b60182754e
commit
42de618db7
@ -13,13 +13,13 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
namespace graph
|
namespace graph
|
||||||
{
|
{
|
||||||
struct FontAdvInfo
|
struct CharMetricsInfo
|
||||||
{
|
{
|
||||||
int x,y; //图像显示偏移
|
int x,y; //图像显示偏移
|
||||||
int w,h; //图像尺寸
|
int w,h; //图像尺寸
|
||||||
|
|
||||||
int adv_x,adv_y;//字符尺寸
|
int adv_x,adv_y;//字符尺寸
|
||||||
};//struct FontAdvInfo
|
};//struct CharMetricsInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字体位图数据
|
* 字体位图数据
|
||||||
@ -28,7 +28,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
int count; //使用次数
|
int count; //使用次数
|
||||||
|
|
||||||
FontAdvInfo adv_info;
|
CharMetricsInfo metrics_info;
|
||||||
|
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
};//struct FontBitmap
|
};//struct FontBitmap
|
||||||
@ -47,7 +47,7 @@ namespace hgl
|
|||||||
virtual ~FontSource()=default;
|
virtual ~FontSource()=default;
|
||||||
|
|
||||||
virtual FontBitmap *GetCharBitmap (const u32char &)=0; ///<取得字符位图数据
|
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; ///<取得字符高度
|
virtual int GetCharHeight ()const=0; ///<取得字符高度
|
||||||
|
|
||||||
void RefAcquire(void *); ///<引用请求
|
void RefAcquire(void *); ///<引用请求
|
||||||
@ -76,7 +76,7 @@ namespace hgl
|
|||||||
virtual ~FontSourceSingle()=default;
|
virtual ~FontSourceSingle()=default;
|
||||||
|
|
||||||
FontBitmap *GetCharBitmap (const u32char &ch) override; ///<取得字符位图数据
|
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;} ///<取得字符高度
|
virtual int GetCharHeight ()const override{return fnt.height;} ///<取得字符高度
|
||||||
};//class FontSourceSingle:public FontSource
|
};//class FontSourceSingle:public FontSource
|
||||||
|
|
||||||
@ -110,8 +110,10 @@ namespace hgl
|
|||||||
void Remove(UnicodeBlock);
|
void Remove(UnicodeBlock);
|
||||||
void Remove(FontSource *);
|
void Remove(FontSource *);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
FontBitmap *GetCharBitmap (const u32char &ch) override;
|
FontBitmap *GetCharBitmap (const u32char &ch) override;
|
||||||
const bool GetCharAdvInfo (FontAdvInfo &,const u32char &); ///<取得字符绘制信息
|
const bool GetCharMetrics (CharMetricsInfo &,const u32char &); ///<取得字符绘制信息
|
||||||
int GetCharHeight ()const override; ///<取得字符高度
|
int GetCharHeight ()const override; ///<取得字符高度
|
||||||
};//class FontSourceMulti:public FontSource
|
};//class FontSourceMulti:public FontSource
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
|
@ -8,6 +8,8 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
namespace graph
|
namespace graph
|
||||||
{
|
{
|
||||||
|
class TileFont;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符属性,可精确到字也可精确到段落或是全文
|
* 字符属性,可精确到字也可精确到段落或是全文
|
||||||
*/
|
*/
|
||||||
@ -181,7 +183,7 @@ namespace hgl
|
|||||||
// virtual int Layout (const int max_chars,const BaseString<T> &)=0; ///<排版
|
// virtual int Layout (const int max_chars,const BaseString<T> &)=0; ///<排版
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int PlaneLayout (const int max_chars,const BaseString<T> &)=0; ///<简易排版
|
int PlaneLayout (TileFont *,const int max_chars,const BaseString<T> &)=0; ///<简易排版
|
||||||
};//class TextLayout
|
};//class TextLayout
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -20,26 +20,26 @@ Renderable::~Renderable()
|
|||||||
delete[] buf_list;
|
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 VkVertexInputBindingDescription *desc=vertex_sm->GetDesc(stage_input_binding);
|
||||||
const VkVertexInputAttributeDescription *attr=vertex_sm->GetAttr(stage_input_binding);
|
const VkVertexInputAttributeDescription *attr=vertex_sm->GetAttr(stage_input_binding);
|
||||||
|
|
||||||
if(vbo->GetFormat()!=attr->format)return(false);
|
if(vab->GetFormat()!=attr->format)return(false);
|
||||||
if(vbo->GetStride()!=desc->stride)return(false);
|
if(vab->GetStride()!=desc->stride)return(false);
|
||||||
|
|
||||||
//format信息来自于shader,实际中可以不一样。但那样需要为每一个格式产生一个同样shader的material instance,不同的格式又需要不同的pipeline,我们不支持这种行为
|
//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;
|
buf_offset[stage_input_binding]=offset;
|
||||||
|
|
||||||
return(true);
|
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
|
VK_NAMESPACE_END
|
||||||
|
@ -120,21 +120,21 @@ namespace hgl
|
|||||||
|
|
||||||
GetGlyphOutlineW(hdc,ch,ggo,&gm,buffer_size,buffer,&mat);
|
GetGlyphOutlineW(hdc,ch,ggo,&gm,buffer_size,buffer,&mat);
|
||||||
|
|
||||||
bmp->adv_info.w =gm.gmBlackBoxX;
|
bmp->metrics_info.w =gm.gmBlackBoxX;
|
||||||
bmp->adv_info.h =gm.gmBlackBoxY;
|
bmp->metrics_info.h =gm.gmBlackBoxY;
|
||||||
|
|
||||||
bmp->adv_info.x =gm.gmptGlyphOrigin.x;
|
bmp->metrics_info.x =gm.gmptGlyphOrigin.x;
|
||||||
bmp->adv_info.y =gm.gmptGlyphOrigin.y;
|
bmp->metrics_info.y =gm.gmptGlyphOrigin.y;
|
||||||
|
|
||||||
bmp->adv_info.adv_x =gm.gmCellIncX;
|
bmp->metrics_info.adv_x =gm.gmCellIncX;
|
||||||
bmp->adv_info.adv_y =gm.gmCellIncY;
|
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)
|
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
|
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);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ namespace hgl
|
|||||||
|
|
||||||
cla->is_punctuation =isPunctuation(*cp);
|
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);
|
hgl_zero(cla->adv_info);
|
||||||
else
|
else
|
||||||
if(cla->adv_info.w>0&&cla->adv_info.h>0)
|
if(cla->adv_info.w>0&&cla->adv_info.h>0)
|
||||||
@ -157,7 +157,7 @@ namespace hgl
|
|||||||
|
|
||||||
cla->vrotate =hgl::strchr(VRotateSymbols,*cp,VRotateSymbolsCount );
|
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);
|
hgl_zero(cla->adv_info);
|
||||||
else
|
else
|
||||||
if(cla->adv_info.w>0&&cla->adv_info.h>0)
|
if(cla->adv_info.w>0&&cla->adv_info.h>0)
|
||||||
@ -253,7 +253,7 @@ namespace hgl
|
|||||||
* 不处理自动换行,仅支持\r\n换行。无任何特殊处理
|
* 不处理自动换行,仅支持\r\n换行。无任何特殊处理
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int TextLayout::PlaneLayout(const int mc,const BaseString<T> &str)
|
int TextLayout::PlaneLayout(TileFont *tf,const int mc,const BaseString<T> &str)
|
||||||
{
|
{
|
||||||
if(mc<=0||str.IsEmpty()
|
if(mc<=0||str.IsEmpty()
|
||||||
return(-1);
|
return(-1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user