add Font/FontBitmapCache
This commit is contained in:
35
inc/hgl/graph/font/Font.h
Normal file
35
inc/hgl/graph/font/Font.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef HGL_GRAPH_FONT_INCLUDE
|
||||
#define HGL_GRAPH_FONT_INCLUDE
|
||||
|
||||
#include<hgl/CompOperator.h>
|
||||
#include<string.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
/**
|
||||
* 字体信息
|
||||
*/
|
||||
struct Font
|
||||
{
|
||||
char name[128]; ///<字体名称(utf8)
|
||||
|
||||
int width; ///<宽度
|
||||
int height; ///<高度
|
||||
|
||||
bool bold; ///<加粗
|
||||
bool italic; ///<右斜
|
||||
|
||||
bool anti; ///<反矩齿
|
||||
|
||||
public:
|
||||
|
||||
Font();
|
||||
Font(const char *,int,int,bool,bool,bool=true);
|
||||
|
||||
CompOperatorMemcmp(const Font &); ///<比较操作符重载
|
||||
};//struct Font
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_FONT_INCLUDE
|
54
inc/hgl/graph/font/FontBitmapCache.h
Normal file
54
inc/hgl/graph/font/FontBitmapCache.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef HGL_GRAPH_FONT_BITMAP_CACHE_INCLUDE
|
||||
#define HGL_GRAPH_FONT_BITMAP_CACHE_INCLUDE
|
||||
|
||||
#include<hgl/type/StrChar.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/graph/font/Font.h>
|
||||
|
||||
using namespace hgl;
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
/**
|
||||
* 文本位图缓冲
|
||||
*/
|
||||
class FontBitmapCache
|
||||
{
|
||||
/**
|
||||
* 字体位图数据
|
||||
*/
|
||||
struct Bitmap
|
||||
{
|
||||
int count; //使用次数
|
||||
|
||||
int x,y; //图像显示偏移
|
||||
int w,h; //图像尺寸
|
||||
|
||||
int adv_x,adv_y;//字符尺寸
|
||||
|
||||
uint8 *data;
|
||||
};//struct Bitmap
|
||||
|
||||
protected:
|
||||
|
||||
Font fnt;
|
||||
|
||||
MapObject<u32char,FontBitmapCache::Bitmap> chars_bitmap; ///<字符位图
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool MakeCharBitmap(FontBitmapCache::Bitmap *,u32char)=0; ///<产生字体数据
|
||||
virtual int GetLineHeight()const=0; ///<取得行高
|
||||
|
||||
public:
|
||||
|
||||
FontBitmapCache(const Font &f){fnt=f;}
|
||||
virtual ~FontBitmapCache()=default;
|
||||
|
||||
FontBitmapCache::Bitmap *GetCharBitmap(const u32char &); ///<取得字符位图数据
|
||||
};//class FontBitmapCache
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_FONT_BITMAP_CACHE_INCLUDE
|
Reference in New Issue
Block a user