add FontSourceSingle/Multi.cpp
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/Set.h>
|
||||
#include<hgl/graph/font/Font.h>
|
||||
#include<hgl/type/UnicodeBlocks.h>
|
||||
|
||||
using namespace hgl;
|
||||
|
||||
@@ -32,14 +33,32 @@ namespace hgl
|
||||
*/
|
||||
class FontSource
|
||||
{
|
||||
protected:
|
||||
|
||||
Set<void *> ref_object;
|
||||
|
||||
public:
|
||||
|
||||
virtual ~FontSource()=default;
|
||||
|
||||
virtual FontBitmap *GetCharBitmap(const u32char &)=0; ///<取得字符位图数据
|
||||
|
||||
void RefAcquire(void *); ///<引用请求
|
||||
void RefRelease(void *); ///<引用释放
|
||||
int RefCount()const{return ref_object.GetCount();} ///<获取引用对象数量
|
||||
};//class FontSource
|
||||
|
||||
/**
|
||||
* 文字位图单一数据源
|
||||
*/
|
||||
class FontSourceSingle:public FontSource
|
||||
{
|
||||
protected:
|
||||
|
||||
Font fnt;
|
||||
|
||||
MapObject<u32char,FontBitmap> chars_bitmap; ///<字符位图
|
||||
|
||||
Set<void *> ref_object;
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool MakeCharBitmap(FontBitmap *,u32char)=0; ///<产生字体数据
|
||||
@@ -47,15 +66,36 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
FontSource(const Font &f){fnt=f;}
|
||||
virtual ~FontSource()=default;
|
||||
FontSourceSingle(const Font &f){fnt=f;}
|
||||
virtual ~FontSourceSingle()=default;
|
||||
|
||||
FontBitmap *GetCharBitmap(const u32char &); ///<取得字符位图数据
|
||||
FontBitmap *GetCharBitmap(const u32char &ch) override;
|
||||
};//class FontSourceSingle:public FontSource
|
||||
|
||||
void RefAcquire(void *); ///<引用请求
|
||||
void RefRelease(void *); ///<引用释放
|
||||
int RefCount()const{return ref_object.GetCount();} ///<获取引用对象数量
|
||||
};//class FontSource
|
||||
/**
|
||||
* 文字位图多重数据源
|
||||
*/
|
||||
class FontSourceMulti:public FontSource
|
||||
{
|
||||
using FontSourcePointer=FontSource *;
|
||||
|
||||
FontSource *default_source;
|
||||
Map<UnicodeBlock,FontSourcePointer> source_map;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @param dfs 缺省字符数据源
|
||||
*/
|
||||
FontSourceMulti(FontSource *dfs);
|
||||
virtual ~FontSourceMulti();
|
||||
|
||||
void Add(UnicodeBlock,FontSource *);
|
||||
void Remove(UnicodeBlock);
|
||||
void Remove(FontSource *);
|
||||
|
||||
FontBitmap *GetCharBitmap(const u32char &ch) override;
|
||||
};//class FontSourceMulti:public FontSource
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_FONT_SOURCE_INCLUDE
|
||||
#endif//HGL_GRAPH_FONT_SOURCE_INCLUDE
|
||||
|
Reference in New Issue
Block a user