added not_bitmap_chars at TileFont

This commit is contained in:
2022-02-18 20:30:50 +08:00
parent 6a039b8a51
commit 14269369be
4 changed files with 22 additions and 21 deletions

2
CMCore

Submodule CMCore updated: 2ba3003685...676554bc86

View File

@@ -22,6 +22,8 @@ namespace hgl
TileResPool to_res;
SortedSets<u32char> not_bitmap_chars;
public:
FontSource *GetFontSource (){return source;}
@@ -33,7 +35,7 @@ namespace hgl
TileFont(TileData *td,FontSource *fs);
virtual ~TileFont();
bool Registry(TileUVFloatMap &,const u32char *ch_list,const int ch_count); ///<注册要使用的字符
bool Registry(TileUVFloatMap &,SortedSets<u32char> &chars_sets); ///<注册要使用的字符
void Unregistry(const List<u32char> &); ///<注销要使用的字符
};//class TileFont
}//namespace graph

View File

@@ -83,7 +83,7 @@ namespace hgl
}
//注册不重复字符给tile font系统获取所有字符的UV
if(!tile_font->Registry(chars_uv,chars_sets.GetData(),chars_sets.GetCount()))
if(!tile_font->Registry(chars_uv,chars_sets))
{
draw_chars_list.ClearData();
chars_sets.ClearData();
@@ -195,7 +195,7 @@ namespace hgl
if((*cda)->cla->attr->ch==' ')
left+=space_size;
else
if((*cda)->cla->attr->ch==HGL_FULL_SPACE)
if((*cda)->cla->attr->ch==U32_FULL_SPACE)
left+=full_space_size;
else
if((*cda)->cla->attr->ch=='\t')

View File

@@ -30,31 +30,31 @@ namespace hgl
* @param rs 每个字符在纹理中的UV坐标
* @param ch_list 要注册的字符列表
*/
bool TileFont::Registry(TileUVFloatMap &uv_map,const u32char *ch_list,const int ch_count)
bool TileFont::Registry(TileUVFloatMap &uv_map,SortedSets<u32char> &chars_sets)
{
const u32char *cp=ch_list;
TileObject *to;
ResPoolStats stats;
to_res.Stats(stats,ch_list,ch_count);
chars_sets.Clear(not_bitmap_chars); //清除所有没有位图的字符
to_res.Stats(stats,chars_sets.GetData(),chars_sets.GetCount());
if(stats.non_existent>stats.can_free+tile_data->GetFreeCount()) //不存在的字符数量总量>剩余可释放的闲置项+剩余可用的空余tile
return(false);
uv_map.ClearData();
TileObject *to;
FontBitmap *bmp;
cp=ch_list;
if(stats.non_existent>0)
{
tile_data->BeginCommit();
for(int i=0;i<ch_count;i++)
for(const u32char cp:chars_sets)
{
if(!to_res.Get(*cp,to))
if(!not_bitmap_chars.IsMember(cp))
if(!to_res.Get(cp,to))
{
bmp=source->GetCharBitmap(*cp);
bmp=source->GetCharBitmap(cp);
if(bmp)
{
@@ -62,27 +62,26 @@ namespace hgl
bmp->metrics_info.w*bmp->metrics_info.h,
bmp->metrics_info.w,bmp->metrics_info.h);
to_res.Add(*cp,to);
to_res.Add(cp,to);
}
else
{
not_bitmap_chars.Add(cp);
continue;
}
}
uv_map.Add(*cp,to->uv_float);
++cp;
uv_map.Add(cp,to->uv_float);
}
tile_data->EndCommit();
}
else
{
for(int i=0;i<ch_count;i++)
for(const u32char cp:chars_sets)
{
to_res.Get(*cp,to);
to_res.Get(cp,to);
uv_map.Add(*cp,to->uv_float);
++cp;
uv_map.Add(cp,to->uv_float);
}
}