diff --git a/CMCore b/CMCore index 339ee9a5..2d6883be 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit 339ee9a5614211383999d725cd90e4278c9e1594 +Subproject commit 2d6883be633abae7f0f10810e2b61367175bcfc4 diff --git a/inc/hgl/graph/font/FontSource.h b/inc/hgl/graph/font/FontSource.h index 4731d73c..95ea0ff6 100644 --- a/inc/hgl/graph/font/FontSource.h +++ b/inc/hgl/graph/font/FontSource.h @@ -32,18 +32,13 @@ namespace hgl uint8 *data; };//struct FontBitmap - - /** - * 字符排版属性 - */ - struct CharLayoutAttributes + + struct CharAttributes { u32char ch; ///<字符 - bool visible; ///<是否可显示字符 + bool space; ///<是否属于空格 - int size; ///<字符排版尺寸(一般为宽) - bool is_cjk; ///<是否是中日韩文字 bool is_emoji; ///<是否是表情符号 @@ -51,9 +46,19 @@ namespace hgl bool begin_disable; ///<是否行首禁用符号 bool end_disable; ///<是否行尾禁用符号 - bool vrotate; ///<竖排时是否需要旋转 + bool vrotate; ///<竖排时是否需要旋转 + };// + + /** + * 字符排版属性 + */ + struct CharLayoutAttributes:public CharAttributes + { + CharAttributes *attr; ///<字符基本信息 - CharMetricsInfo adv_info; ///<字符绘制信息 + bool visible; ///<在当前字体下是否需要绘制 + + CharMetricsInfo metrics; ///<字符绘制信息 };//struct CharLayoutAttributes using CLA=CharLayoutAttributes; diff --git a/src/SceneGraph/font/FontSource.cpp b/src/SceneGraph/font/FontSource.cpp index 826b92c2..39af8332 100644 --- a/src/SceneGraph/font/FontSource.cpp +++ b/src/SceneGraph/font/FontSource.cpp @@ -31,6 +31,8 @@ namespace hgl constexpr int EndSymbolsCount =(sizeof(EndSymbols) /sizeof(u16char))-1; constexpr int CurrencySymbolsCount=(sizeof(CurrencySymbols)/sizeof(u16char))-1; constexpr int VRotateSymbolsCount =(sizeof(VRotateSymbols) /sizeof(u16char))-1; + + MapObject all_char_attrs; }//namespace const CLA *FontSource::GetCLA(const u32char &ch) @@ -40,37 +42,50 @@ namespace hgl if(cla_cache.Get(ch,cla)) return cla; - cla=new CLA; + CharAttributes *attr; - cla->ch=ch; + const int pos=all_char_attrs.GetValueAndSerial(ch,attr); - if(hgl::isspace(ch)) + if(pos<0) { - cla->visible=false; - } - else - { - cla->visible=true; + attr=new CharAttributes; + + attr->ch=ch; - cla->begin_disable =hgl::strchr(BeginSymbols, ch,BeginSymbolsCount ); - cla->end_disable =hgl::strchr(EndSymbols, ch,EndSymbolsCount ); + attr->space=hgl::isspace(ch); - if(!cla->end_disable) //货币符号同样行尾禁用 - cla->end_disable =hgl::strchr(CurrencySymbols, ch,CurrencySymbolsCount ); - - cla->vrotate =hgl::strchr(VRotateSymbols, ch,VRotateSymbolsCount ); - - cla->is_cjk =isCJK(ch); - cla->is_emoji =isEmoji(ch); - - cla->is_punctuation =isPunctuation(ch); - - if(!GetCharMetrics(cla->adv_info,ch)) - hgl_zero(cla->adv_info); - else - if(cla->adv_info.w>0&&cla->adv_info.h>0) + if(!attr->space) { - cla->size=ceil(cla->adv_info.adv_x); + attr->begin_disable =hgl::strchr(BeginSymbols, ch,BeginSymbolsCount ); + attr->end_disable =hgl::strchr(EndSymbols, ch,EndSymbolsCount ); + + if(!attr->end_disable) //货币符号同样行尾禁用 + attr->end_disable =hgl::strchr(CurrencySymbols, ch,CurrencySymbolsCount ); + + attr->vrotate =hgl::strchr(VRotateSymbols, ch,VRotateSymbolsCount ); + + attr->is_cjk =isCJK(ch); + attr->is_emoji =isEmoji(ch); + + attr->is_punctuation=isPunctuation(ch); + } + + all_char_attrs.Add(ch,attr); + } + + cla=new CLA; + cla->attr=attr; + + if(!attr->space) + { + if(!GetCharMetrics(cla->metrics,ch)) + { + cla->visible=false; + hgl_zero(cla->metrics); + } + else + { + cla->visible=(cla->metrics.w>0&&cla->metrics.h>0); } }