00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __FONTTEXTURE_H__
00020 #define __FONTTEXTURE_H__
00021
00022 #include <string>
00023
00024 #include <vrs/sharedobj.h>
00025 #include <vrs/image/memoryimage.h>
00026 #include <vrs/opengl/texturegl.h>
00027
00028 #include <vrs/text/vrs_textprerequisites.h>
00029
00030 struct FT_Bitmap_;
00031 typedef struct FT_Bitmap_ FT_Bitmap;
00032
00034 namespace VRS
00035 {
00036 namespace TEXT
00037 {
00038 class VRS_CORE_API FontDefinition;
00039
00040
00044 class VRS_CORE_API FontTexture : public SharedObj
00045 {
00046 public:
00052 FontTexture( unsigned int textureSize,
00053 SO<FontDefinition> fontDefinition,
00054 bool colored = false );
00056 virtual ~FontTexture();
00057
00059 inline unsigned int getTextureSize() const { return m_TextureSize; };
00061 inline SO<FontDefinition> getFontDefinition() const
00062 { return m_FontDefinition; };
00063
00065 TextureGL* getTexture();
00066
00068 inline MemoryImage* getImage() const
00069 { return m_AlphaImage; }
00070
00072 bool hasEnoughFreeSpace( SO<Image> img ) const;
00074 bool hasEnoughFreeSpace( const FT_Bitmap& bitmap ) const;
00076 bool hasEnoughFreeSpace( int width, int height ) const;
00077
00082 void addGlyphToTexture( const FT_Bitmap& bitmap, unsigned int* uv = NULL );
00087 void addImageToTexture( SO<Image> img, unsigned int* uv = NULL );
00088
00090 void writeToPng(const std::string& filename);
00091
00092 VRS_TYPEINFO(FontTexture, SharedObj);
00093 private:
00095 unsigned int m_TextureSize;
00096
00098 unsigned int m_GlyphSpacing;
00099
00101 SO<MemoryImage> m_AlphaImage;
00103 SO<TextureGL> m_Texture;
00104
00106 unsigned int m_CurrentXOffset;
00108 unsigned int m_CurrentYOffset;
00110 unsigned int m_CurrentRowHeight;
00112 SO<FontDefinition> m_FontDefinition;
00113 };
00114 }
00115 }
00116
00117 #endif