00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __FONTMANAGER_H__
00021 #define __FONTMANAGER_H__
00022
00023 #include <vrs/text/vrs_textprerequisites.h>
00024 #include <vrs/text/fontdefinition.h>
00025
00026 #include <map>
00027 #include <string>
00028
00029 struct FT_LibraryRec_;
00030 typedef struct FT_LibraryRec_ *FT_Library;
00031
00033 namespace VRS
00034 {
00035 namespace TEXT
00036 {
00037 typedef std::map<const std::string, SO<FontDefinition> > FontDefinitionMap;
00038
00044 class VRS_CORE_API FontManager : public VRS::SharedObj
00045 {
00046 public:
00048 virtual ~FontManager();
00049
00051 static SO<FontManager> getSingleton();
00052
00069 SO<FontDefinition> createFontDefinitionByFilename( const std::string& name,
00070 const std::string& absolutefilename, const std::string& style, SO<FontSize> size,
00071 unsigned int typeFlags = GTI_ALL, bool searchFont = true, bool usefallback = false );
00086 SO<FontDefinition> createFontDefinitionByFontname( const std::string& name,
00087 const std::string& fontname, const std::string& cstyle, SO<FontSize> size,
00088 unsigned int typeFlags = GTI_ALL, bool usefallback = true );
00092 void destroyFontDefinition( const SO<FontDefinition> fd );
00095 void destroyFontDefinitions( void );
00096
00108 std::string findFontpathPerFilename( const std::string& searchfilename, bool matchSubstring = true,
00109 bool searchDirectories = false, bool compareLowercase = true );
00120 std::string findFontpathPerFontname( const std::string& searchfontname, bool matchSubstring = true,
00121 bool searchDirectories = false, bool compareLowercase = true );
00122
00124 void addFontDirectory( std::string dir );
00126 void removeFontDirectory( std::string dir );
00127
00134 void prefetchFontDirectories( bool clearFontDirectories = true );
00135
00139 SO<FontDefinition> getFontDefinition( const std::string& name ) const;
00140
00142 inline FT_Library _getLibrary() const { return m_Library; };
00143
00147 void setTextureSize(unsigned int dim);
00150 inline unsigned int getTextureSize() const { return m_TextureSize; };
00151
00156 void setResolution(unsigned int horiresolution, unsigned int vertresolution );
00159 inline unsigned int getHoriResolution() const { return m_HoriResolution; };
00162 inline unsigned int getVertResolution() const { return m_VertResolution; };
00163
00165 inline GlyphCharcode getNewLineChar() const
00166 { return m_NewLineChar; };
00168 void setNewLineChar(GlyphCharcode gc);
00169
00171 void setFallBackName( const std::string& name );
00173 std::string getFallBackName( ) const;
00174
00176 bool isCheckFontFileExtensions() const;
00178 void setCheckFontFileExtensions( bool check );
00179
00180 friend void FontDefinition::serialize(SerializationManager& doc) ;
00181 private:
00183 FontManager();
00184
00185 static SO<FontManager> s_Instance;
00186
00188 void injectFontDefinition( SO<FontDefinition> fd );
00189
00191 void configureFontpath();
00192
00194 GlyphCharcode m_NewLineChar;
00195
00197 FontDefinitionMap m_FontDefinitionMap;
00198
00200 FT_Library m_Library;
00201
00203 unsigned int m_TextureSize;
00204
00206 unsigned int m_HoriResolution;
00208 unsigned int m_VertResolution;
00209
00211 std::set< std::string > m_FontDirectories;
00213 std::map< std::string, std::string > m_PrefetchedFonts;
00214
00216 std::string m_FallBackName;
00217
00219 bool m_CheckFontFileExtensions;
00220 };
00221
00222 }
00223 }
00224
00225 #endif