delete line_height in FontSource, append char_height attribute.
This commit is contained in:
parent
94cfcd322c
commit
a273605b42
@ -43,6 +43,7 @@ namespace hgl
|
|||||||
|
|
||||||
virtual FontBitmap *GetCharBitmap(const u32char &)=0; ///<取得字符位图数据
|
virtual FontBitmap *GetCharBitmap(const u32char &)=0; ///<取得字符位图数据
|
||||||
virtual int GetCharAdvWidth(const u32char &)=0; ///<取得字符绘制宽度
|
virtual int GetCharAdvWidth(const u32char &)=0; ///<取得字符绘制宽度
|
||||||
|
virtual int GetCharHeight()const=0; ///<取得字符高度
|
||||||
|
|
||||||
void RefAcquire(void *); ///<引用请求
|
void RefAcquire(void *); ///<引用请求
|
||||||
void RefRelease(void *); ///<引用释放
|
void RefRelease(void *); ///<引用释放
|
||||||
@ -69,9 +70,9 @@ namespace hgl
|
|||||||
FontSourceSingle(const Font &f){fnt=f;}
|
FontSourceSingle(const Font &f){fnt=f;}
|
||||||
virtual ~FontSourceSingle()=default;
|
virtual ~FontSourceSingle()=default;
|
||||||
|
|
||||||
FontBitmap * GetCharBitmap(const u32char &ch) override; ///<取得字符位图数据
|
FontBitmap *GetCharBitmap(const u32char &ch) override; ///<取得字符位图数据
|
||||||
virtual int GetCharAdvWidth(const u32char &)=0; ///<取得字符绘制宽度
|
virtual int GetCharAdvWidth(const u32char &)=0; ///<取得字符绘制宽度
|
||||||
virtual int GetLineHeight()const=0; ///<取得行高
|
virtual int GetCharHeight()const override{return fnt.height;} ///<取得字符高度
|
||||||
};//class FontSourceSingle:public FontSource
|
};//class FontSourceSingle:public FontSource
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,6 +85,10 @@ namespace hgl
|
|||||||
FontSource *default_source;
|
FontSource *default_source;
|
||||||
Map<UnicodeBlock,FontSourcePointer> source_map;
|
Map<UnicodeBlock,FontSourcePointer> source_map;
|
||||||
|
|
||||||
|
int max_char_height;
|
||||||
|
|
||||||
|
void RefreshMaxCharHeight();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
FontSource *GetFontSource(const u32char &ch);
|
FontSource *GetFontSource(const u32char &ch);
|
||||||
@ -102,6 +107,7 @@ namespace hgl
|
|||||||
|
|
||||||
FontBitmap *GetCharBitmap(const u32char &ch) override;
|
FontBitmap *GetCharBitmap(const u32char &ch) override;
|
||||||
int GetCharAdvWidth(const u32char &) override;
|
int GetCharAdvWidth(const u32char &) override;
|
||||||
|
int GetCharHeight()const override; ///<取得字符高度
|
||||||
};//class FontSourceMulti:public FontSource
|
};//class FontSourceMulti:public FontSource
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -10,6 +10,8 @@ namespace hgl
|
|||||||
|
|
||||||
if(fs)
|
if(fs)
|
||||||
fs->RefAcquire(this);
|
fs->RefAcquire(this);
|
||||||
|
|
||||||
|
max_char_height=fs->GetCharHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
FontSourceMulti::~FontSourceMulti()
|
FontSourceMulti::~FontSourceMulti()
|
||||||
@ -25,8 +27,28 @@ namespace hgl
|
|||||||
||!fs
|
||!fs
|
||||||
||fs==default_source)return;
|
||fs==default_source)return;
|
||||||
|
|
||||||
|
if(fs->GetCharHeight()>max_char_height)
|
||||||
|
max_char_height=fs->GetCharHeight();
|
||||||
|
|
||||||
source_map.Update(ub,fs);
|
source_map.Update(ub,fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FontSourceMulti::RefreshMaxCharHeight()
|
||||||
|
{
|
||||||
|
max_char_height=0;
|
||||||
|
|
||||||
|
const int count=source_map.GetCount();
|
||||||
|
|
||||||
|
const auto **fsp=source_map.GetDataList();
|
||||||
|
|
||||||
|
for(int i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
if((*fsp)->right->GetCharHeight()>max_char_height)
|
||||||
|
max_char_height=(*fsp)->right->GetCharHeight();
|
||||||
|
|
||||||
|
++fsp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FontSourceMulti::Remove(UnicodeBlock ub)
|
void FontSourceMulti::Remove(UnicodeBlock ub)
|
||||||
{
|
{
|
||||||
@ -34,8 +56,13 @@ namespace hgl
|
|||||||
|
|
||||||
if(source_map.Get(ub,fsp))
|
if(source_map.Get(ub,fsp))
|
||||||
{
|
{
|
||||||
|
const bool refresh=(fsp->GetCharHeight()==max_char_height);
|
||||||
|
|
||||||
fsp->RefRelease(this);
|
fsp->RefRelease(this);
|
||||||
source_map.DeleteByKey(ub);
|
source_map.DeleteByKey(ub);
|
||||||
|
|
||||||
|
if(refresh)
|
||||||
|
RefreshMaxCharHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,8 +73,13 @@ namespace hgl
|
|||||||
|
|
||||||
if(source_map.ValueExist(fs))
|
if(source_map.ValueExist(fs))
|
||||||
{
|
{
|
||||||
|
const bool refresh=(fs->GetCharHeight()==max_char_height);
|
||||||
|
|
||||||
fs->RefRelease(this);
|
fs->RefRelease(this);
|
||||||
source_map.DeleteByValue(fs);
|
source_map.DeleteByValue(fs);
|
||||||
|
|
||||||
|
if(refresh)
|
||||||
|
RefreshMaxCharHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +61,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
hdc=CreateCompatibleDC(0);
|
hdc=CreateCompatibleDC(0);
|
||||||
|
|
||||||
LineHeight=(fnt.height*GetDeviceCaps(hdc,LOGPIXELSY))/72;
|
CharHeight=fnt.height;
|
||||||
LineDistance=(LineHeight-fnt.height)/2;
|
|
||||||
|
|
||||||
hfont=CreateFont( -fnt.height,
|
hfont=CreateFont( -fnt.height,
|
||||||
fnt.width,
|
fnt.width,
|
||||||
|
@ -21,18 +21,12 @@ namespace hgl
|
|||||||
uint8 *buffer;
|
uint8 *buffer;
|
||||||
int buffer_size;
|
int buffer_size;
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
int LineHeight;
|
|
||||||
int LineDistance;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WinBitmapFont(const Font &);
|
WinBitmapFont(const Font &);
|
||||||
~WinBitmapFont();
|
~WinBitmapFont();
|
||||||
|
|
||||||
bool MakeCharBitmap(FontBitmap *,u32char) override; ///<产生字体数据
|
bool MakeCharBitmap(FontBitmap *,u32char) override; ///<产生字体数据
|
||||||
int GetLineHeight()const override{return LineHeight;} ///<取得行高
|
|
||||||
int GetCharAdvWidth(const u32char &) override;
|
int GetCharAdvWidth(const u32char &) override;
|
||||||
};//class WinBitmapFont
|
};//class WinBitmapFont
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
|
Loading…
x
Reference in New Issue
Block a user