00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __FONT_H__
00012 #define __FONT_H__
00013
00014 #include "Render/RenderDll.h"
00015 #include "Common/Types.h"
00016 #include "Render/Shader.h"
00017
00018
00019 typedef enum _KFONTALIGN
00020 {
00021 KFA_LEFT = 0,
00022 KFA_RIGHT = 1,
00023 KFA_CENTER = 2
00024 } KFONTALIGN;
00025
00026 #define FONT_WIDTH 16
00027 #define FONT_HEIGHT 16
00028 #define FONT_NWIDTH (FONT_BITMAP_WIDTH/FONT_WIDTH)
00029 #define FONT_NHEIGHT (FONT_BITMAP_HEIGHT/FONT_HEIGHT)
00030 #define FONT_BITMAP_WIDTH 256
00031 #define FONT_BITMAP_HEIGHT 256
00032 #define FONT_SPACE_WIDTH 6
00033
00034
00035 class KRender;
00036
00037
00038 class RENDER_API KFont
00039 {
00040 protected:
00041 KRender* m_pRender;
00042 float m_RatioX;
00043 float m_SpaceX;
00044 KSHADER m_hShader;
00045 char* m_pShaderName;
00046 KRect m_CropTable[256];
00047
00048 bool CheckAlphaPixel( KTexture* pTexture, u32 x, u32 y, u8* pBits );
00049 void GenerateCropTable();
00050
00051 public:
00052 KFont( KRender* pRender, char* pFontName = NULL );
00053 ~KFont();
00054
00055 bool Init();
00056 void End();
00057
00058 KPt GetTextSize( char* pText,float FontSize = 1.0f );
00059 KPt GetCharSize( char Car, float FontSize = 1.0f );
00060 void Print( KPt& Pos, char* pText, float FontSize = 1.0f, KFONTALIGN FontAlign = KFA_LEFT, KCOLOR Color = KRGB_WHITE );
00061 };
00062
00063 #endif __FONT_H__