00001
00026 #ifndef FREETYPE_H_
00027 #define FREETYPE_H_
00028
00029 #include <malloc.h>
00030 #include <map>
00031 #include <ft2build.h>
00032 #include FT_FREETYPE_H
00033
00034
00035 extern char fontface[];
00036 extern int fontsize;
00038
00039 typedef struct fontCharData_ {
00040 u16 glyphAdvanceX;
00042 u16 textureWidth;
00043 u16 textureHeight;
00045 u16 renderOffsetY;
00047 u32* glyphDataTexture;
00048 } fontCharData;
00049
00051 class FontSystem {
00052
00053 private:
00054 FT_Library ftLibrary;
00055 FT_Face ftFace;
00056 FT_GlyphSlot ftSlot;
00058 u8 textureFormat;
00059 std::map<char, fontCharData> fontData;
00061 void cacheFontData();
00062 void loadFontData(FT_Bitmap *bmp, fontCharData *charData);
00063 void converBufferToRGBA8(u32* glyphData, fontCharData *charData);
00064 void copyTextureToFramebuffer(GXTexObj *texObj, u16 texWidth, u16 texHeight, u16 screenX, u16 screenY);
00065 void drawCharacter(u16 x, u16 y, fontCharData *charData, u32* videoBuffer, u16 videoBufferWidth);
00066
00067 public:
00068 FontSystem(FT_UInt pointSize, u8 textureFormat = GX_TF_RGBA8);
00069 ~FontSystem();
00070 u16 drawText(u16 x, u16 y, char *text);
00071 u16 drawText(u16 x, u16 y, char const *text);
00072 u16 drawText(u16 x, u16 y, char *text, u32* videoBuffer, u16 videoBufferWidth);
00073 u16 drawText(u16 x, u16 y, char const *text, u32* videoBuffer, u16 videoBufferWidth);
00074 };
00075
00076 #endif