00001 #ifndef __FTLibrary__ 00002 #define __FTLibrary__ 00003 00004 #include <ft2build.h> 00005 #include FT_FREETYPE_H 00006 //#include FT_CACHE_H 00007 00008 #include "FTGL.h" 00009 00010 00011 /** 00012 * FTLibrary class is the global accessor for the Freetype library. 00013 * 00014 * This class encapsulates the Freetype Library. This is a singleton class 00015 * and ensures that only one FT_Library is in existence at any one time. 00016 * All constructors are private therefore clients cannot create or 00017 * instantiate this class themselves and must access it's methods via the 00018 * static <code>FTLibrary::Instance()</code> function. 00019 * 00020 * Just because this class returns a valid <code>FTLibrary</code> object 00021 * doesn't mean that the Freetype Library has been successfully initialised. 00022 * Clients should check for errors. You can initialse the library AND check 00023 * for errors using the following code... 00024 * <code>err = FTLibrary::Instance().Error();</code> 00025 * 00026 * @see "Freetype 2 Documentation" 00027 * 00028 */ 00029 class FTGL_EXPORT FTLibrary 00030 { 00031 public: 00032 /** 00033 * Global acces point to the single FTLibrary object. 00034 * 00035 * @return The global <code>FTLibrary</code> object. 00036 */ 00037 static const FTLibrary& Instance(); 00038 00039 /** 00040 * Gets a pointer to the native Freetype library. 00041 * 00042 * @return A handle to a FreeType library instance. 00043 */ 00044 const FT_Library* GetLibrary() const { return library;} 00045 00046 /** 00047 * Queries the library for errors. 00048 * 00049 * @return The current error code. 00050 */ 00051 FT_Error Error() const { return err;} 00052 00053 /** 00054 * Destructor 00055 * 00056 * Disposes of the Freetype library 00057 */ 00058 ~FTLibrary(); 00059 00060 private: 00061 /** 00062 * Default constructors. 00063 * 00064 * Made private to stop clients creating there own FTLibrary 00065 * objects. 00066 */ 00067 FTLibrary(); 00068 FTLibrary( const FT_Library&){} 00069 FTLibrary& operator=( const FT_Library&) { return *this; } 00070 00071 /** 00072 * Initialises the Freetype library 00073 * 00074 * Even though this function indicates success via the return value, 00075 * clients can't see this so must check the error codes. This function 00076 * is only ever called by the default c_stor 00077 * 00078 * @return <code>true</code> if the Freetype library was 00079 * successfully initialised, <code>false</code> 00080 * otherwise. 00081 */ 00082 bool Initialise(); 00083 00084 /** 00085 * Freetype library handle. 00086 */ 00087 FT_Library* library; 00088 // FTC_Manager* manager; 00089 00090 /** 00091 * Current error code. Zero means no error. 00092 */ 00093 FT_Error err; 00094 00095 }; 00096 00097 #endif // __FTLibrary__