00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KEOS_FONTMANAGER_H
00022 #define KEOS_FONTMANAGER_H
00023
00024 #include "KeosPrerequisites.h"
00025 #include "KeosSingleton.h"
00026 #include "KeosDeclaration.h"
00027 #include "KeosTexture.h"
00028 #include "KeosBuffer.h"
00029
00030 namespace Keos
00031 {
00032
00035 class KEOS_EXPORT CFontManager : public CSingleton<CFontManager>
00036 {
00037 friend class CSingleton<CFontManager>;
00038
00039 public :
00040
00046 void LoadFont(const String& strFontFile, const String& strFontName, int nQuality = 16);
00047
00050 void UnloadFonts();
00051
00055 void DrawString(const CGraphicString& String);
00056
00061 TVector2I GetStringPixelSize(const CGraphicString& String);
00062
00065 size_t GetFontHeight(const String& strFontName);
00066
00067 private :
00068
00071 CFontManager();
00072
00075 ~CFontManager();
00076
00079 void Initialize();
00080
00082 struct TVertex
00083 {
00084 TVector3F Position;
00085 ulong Diffuse;
00086 TVector2F TexCoords;
00087 };
00088
00090 typedef ushort TIndex;
00091
00093 struct Glyph
00094 {
00095 float Tex_x1, Tex_y1, Tex_x2;
00096 size_t Advance;
00097 };
00098
00100 struct TFont
00101 {
00103 CTexture Texture;
00105 Glyph* Glyphs;
00107 Glyph* GlyphsTable[256];
00109 size_t LineHeight;
00111 float TextureLineHeight;
00112 };
00113
00114 typedef std::map<String, TFont> TFontsMap;
00115
00116 static const unsigned int NbCharMax = 512;
00117
00118 TFontsMap m_Fonts;
00119 CBuffer<TVertex> m_VertexBuffer;
00120 CBuffer<TIndex> m_IndexBuffer;
00121 CDeclarationPtr m_Declaration;
00122 };
00123
00124 }
00125
00126 #endif // KEOS_FONTMANAGER_H