From 14269369be3deab2416a7524df618aa396822793 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 18 Feb 2022 20:30:50 +0800 Subject: [PATCH] added not_bitmap_chars at TileFont --- CMCore | 2 +- inc/hgl/graph/font/TileFont.h | 4 +++- src/SceneGraph/font/TextLayout.cpp | 4 ++-- src/SceneGraph/font/TileFont.cpp | 33 +++++++++++++++--------------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/CMCore b/CMCore index 2ba30036..676554bc 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit 2ba3003685b788a5484fdf103249b81008384cb4 +Subproject commit 676554bc86ef3bfa70a798e0d52672ab2ae2f034 diff --git a/inc/hgl/graph/font/TileFont.h b/inc/hgl/graph/font/TileFont.h index 70524ca7..dae458ed 100644 --- a/inc/hgl/graph/font/TileFont.h +++ b/inc/hgl/graph/font/TileFont.h @@ -22,6 +22,8 @@ namespace hgl TileResPool to_res; + SortedSets 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 &chars_sets); ///<注册要使用的字符 void Unregistry(const List &); ///<注销要使用的字符 };//class TileFont }//namespace graph diff --git a/src/SceneGraph/font/TextLayout.cpp b/src/SceneGraph/font/TextLayout.cpp index 0591d666..fea7a218 100644 --- a/src/SceneGraph/font/TextLayout.cpp +++ b/src/SceneGraph/font/TextLayout.cpp @@ -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') diff --git a/src/SceneGraph/font/TileFont.cpp b/src/SceneGraph/font/TileFont.cpp index 4094a0d8..0322035e 100644 --- a/src/SceneGraph/font/TileFont.cpp +++ b/src/SceneGraph/font/TileFont.cpp @@ -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 &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;iGetCharBitmap(*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;iuv_float); - ++cp; + uv_map.Add(cp,to->uv_float); } }