1 /* 2 * FTGL - OpenGL font library 3 * 4 * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining 7 * a copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sublicense, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be 15 * included in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 26 #ifndef __FTLibrary__ 27 #define __FTLibrary__ 28 29 #include <ft2build.h> 30 #include FT_FREETYPE_H 31 //#include FT_CACHE_H 32 33 #include "FTGL/ftgl.h" 34 35 36 /** 37 * FTLibrary class is the global accessor for the Freetype library. 38 * 39 * This class encapsulates the Freetype Library. This is a singleton class 40 * and ensures that only one FT_Library is in existence at any one time. 41 * All constructors are private therefore clients cannot create or 42 * instantiate this class themselves and must access it's methods via the 43 * static <code>FTLibrary::Instance()</code> function. 44 * 45 * Just because this class returns a valid <code>FTLibrary</code> object 46 * doesn't mean that the Freetype Library has been successfully initialised. 47 * Clients should check for errors. You can initialse the library AND check 48 * for errors using the following code... 49 * <code>err = FTLibrary::Instance().Error();</code> 50 * 51 * @see "Freetype 2 Documentation" 52 * 53 */ 54 class FTLibrary 55 { 56 public: 57 /** 58 * Global acces point to the single FTLibrary object. 59 * 60 * @return The global <code>FTLibrary</code> object. 61 */ 62 static const FTLibrary& Instance(); 63 64 /** 65 * Gets a pointer to the native Freetype library. 66 * 67 * @return A handle to a FreeType library instance. 68 */ GetLibrary()69 const FT_Library* const GetLibrary() const { return library; } 70 71 /** 72 * Queries the library for errors. 73 * 74 * @return The current error code. 75 */ Error()76 FT_Error Error() const { return err; } 77 78 /** 79 * Destructor 80 * 81 * Disposes of the Freetype library 82 */ 83 ~FTLibrary(); 84 85 private: 86 /** 87 * Default constructors. 88 * 89 * Made private to stop clients creating there own FTLibrary 90 * objects. 91 */ 92 FTLibrary(); FTLibrary(const FT_Library &)93 FTLibrary(const FT_Library&){} 94 FTLibrary& operator=(const FT_Library&) { return *this; } 95 96 /** 97 * Initialises the Freetype library 98 * 99 * Even though this function indicates success via the return value, 100 * clients can't see this so must check the error codes. This function 101 * is only ever called by the default c_stor 102 * 103 * @return <code>true</code> if the Freetype library was 104 * successfully initialised, <code>false</code> 105 * otherwise. 106 */ 107 bool Initialise(); 108 109 /** 110 * Freetype library handle. 111 */ 112 FT_Library* library; 113 // FTC_Manager* manager; 114 115 /** 116 * Current error code. Zero means no error. 117 */ 118 FT_Error err; 119 120 }; 121 122 #endif // __FTLibrary__ 123