- Timestamp:
- Jun 23, 2006, 6:38:05 PM (18 years ago)
- Location:
- branches/fontdata/src/lib/graphics/text_engine
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/fontdata/src/lib/graphics/text_engine/font.cc
r8751 r8753 27 27 28 28 #include "debug.h" 29 #include "stdlibincl.h"30 29 #include "compiler.h" 31 using namespace std; 30 32 31 33 32 /** … … 37 36 */ 38 37 Font::Font(const std::string& fontFile, unsigned int renderSize) 39 : data( new FontData())38 : data(Font::defaultFontData) 40 39 { 41 40 this->init(); … … 54 53 */ 55 54 Font::Font(const std::string& imageFile) 56 : data( new FontData())55 : data(Font::defaultFontData) 57 56 { 58 57 this->init(); 58 59 59 this->setName(imageFile); 60 60 // this->setSize(fontSize); … … 78 78 */ 79 79 Font::Font(char** xpmArray) 80 : data( new FontData())80 : data(Font::defaultFontData) 81 81 { 82 82 this->init(); … … 111 111 { 112 112 this->setClassID(CL_FONT, "Font"); 113 } 113 if (Font::defaultFontData.get() == NULL) 114 Font::defaultFontData = initDefaultFont(); 115 } 116 117 FontDataPointer Font::defaultFontData = FontDataPointer(NULL); //initDefaultFont(); 114 118 115 119 … … 121 125 bool Font::loadFontFromTTF(const std::string& fontFile) 122 126 { 123 // checking for existent Font. 124 if (this->data->fontTTF != NULL) 125 { 126 TTF_CloseFont(this->data->fontTTF); 127 this->data->fontTTF = NULL; 128 } 129 127 this->data = FontDataPointer (new FontData()); 130 128 131 129 this->setName(fontFile); … … 223 221 // PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n"); 224 222 } 225 226 Font* Font::defaultFont = NULL;227 223 228 224 /** … … 288 284 * @brief initializes the default font 289 285 */ 290 void Font::initDefaultFont() 291 { 292 if (Font::defaultFont == NULL) 293 Font::defaultFont = new Font(font_xpm); 294 } 295 296 /** 297 * @brief deletes the default font 298 */ 299 void Font::removeDefaultFont() 300 { 301 if (Font::defaultFont != NULL) 302 delete Font::defaultFont; 303 Font::defaultFont = NULL; 304 } 305 286 FontDataPointer Font::initDefaultFont() 287 { 288 return Font(font_xpm).data; 289 } 306 290 307 291 /** … … 569 553 * @brief a simple function to get some interesting information about this class 570 554 */ 571 void Font::debug() 555 void Font::debug() const 572 556 { 573 557 // print the loaded font's style -
branches/fontdata/src/lib/graphics/text_engine/font.h
r8751 r8753 43 43 44 44 /** @returns the default Font */ 45 inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; }; 45 //inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; }; 46 47 46 48 47 49 void createAsciiImage(const std::string& fileName, unsigned int size) const; 48 static void initDefaultFont();49 static void removeDefaultFont();50 50 51 51 void debug() const ; 52 52 private: 53 53 void init(); … … 56 56 bool createFastTexture(); 57 57 58 58 59 void initGlyphs(Uint16 from, Uint16 count); 59 60 int findOptimalFastTextureSize(); 60 61 61 void debug(); 62 63 static FontDataPointer initDefaultFont(); 62 64 63 65 private: 64 static Font * defaultFont;//!< a default font, that is used, if other fonts were unable to be loaded.66 static FontDataPointer defaultFontData; //!< a default font, that is used, if other fonts were unable to be loaded. 65 67 66 fontDataPointer data;68 FontDataPointer data; //!< A Data-Pointer to a Font. 67 69 }; 68 70 -
branches/fontdata/src/lib/graphics/text_engine/font_data.h
r8751 r8753 72 72 }; 73 73 74 typedef CountPointer<FontData> fontDataPointer;74 typedef CountPointer<FontData> FontDataPointer; 75 75 76 76 #endif /* _FONT_DATA_H */ -
branches/fontdata/src/lib/graphics/text_engine/text.cc
r8619 r8753 56 56 Text::~Text() 57 57 { 58 if (this->_font != NULL && this->_font != Font::getDefaultFont())59 ResourceManager::getInstance()->unload(this->_font); 58 /* if (this->_font != NULL && this->_font != Font::getDefaultFont()) 59 ResourceManager::getInstance()->unload(this->_font);*/ 60 60 } 61 61 … … 175 175 { 176 176 Font* newFont = NULL; 177 Font* oldFont = this->_font;177 // Font* oldFont = this->_font; 178 178 179 179 // load a new Font … … 183 183 if (newFont == NULL) 184 184 { 185 newFont = Font::getDefaultFont();185 // newFont = Font::getDefaultFont(); 186 186 PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str()); 187 187 } 188 188 } 189 if (newFont == NULL)190 newFont = Font::getDefaultFont();189 // if (newFont == NULL) 190 // newFont = Font::getDefaultFont(); 191 191 assert(newFont != NULL); 192 192 193 193 // unloading the Font if we alrady have one loaded. 194 194 this->_font = newFont; 195 if (oldFont != NULL && oldFont != Font::getDefaultFont())196 ResourceManager::getInstance()->unload(oldFont);195 // if (oldFont != NULL && oldFont != Font::getDefaultFont()) 196 // ResourceManager::getInstance()->unload(oldFont); 197 197 198 198 this->setupTextWidth(); -
branches/fontdata/src/lib/graphics/text_engine/text_engine.cc
r7428 r8753 76 76 { 77 77 Font* font = dynamic_cast<Font*>(fontList->back()); 78 if (likely(font != Font::getDefaultFont()))79 ResourceManager::getInstance()->unload(font, RP_GAME);78 //if (likely(font != Font::getDefaultFont())) 79 // ResourceManager::getInstance()->unload(font, RP_GAME); 80 80 } 81 81 } … … 108 108 if (TTF_WasInit()) 109 109 { 110 Font::removeDefaultFont();110 // Font::removeDefaultFont(); 111 111 TTF_Quit(); 112 112 }
Note: See TracChangeset
for help on using the changeset viewer.