Changeset 5179 in orxonox.OLD for trunk/src/lib/graphics/text_engine.cc
- Timestamp:
- Sep 13, 2005, 11:23:34 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine.cc
r5125 r5179 82 82 83 83 /** 84 * sets the Font of this Text to font 85 * @param font the Font (normaly from the ResourceManager) to allocate to this Text 86 */ 87 void Text::setFont(Font* font) 88 { 89 if (this->font != NULL) 90 ResourceManager::getInstance()->unload(this->font); 91 this->font = font; 92 } 93 94 /** 95 * sets the Font of this Text to font from fontFile 96 * @param fontFile the File to load the Font from. 97 * @param fontSize the Size of the Font 98 */ 99 void Text::setFont(const char* fontFile, unsigned int fontSize) 100 { 101 Font* tmpFont; 102 Text* newText; 103 Vector tmpVec; 104 105 tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, &fontSize); 106 if (!tmpFont) 107 { 108 PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile); 109 this->setFont(NULL); 110 } 111 else 112 this->setFont(tmpFont); 113 } 114 115 /** 84 116 * sets the Type of this Text 85 117 * @param type the type to set. … … 87 119 void Text::setType(TEXT_RENDER_TYPE type) 88 120 { 89 if (this->font ->font)121 if (this->font != NULL && this->font->font) 90 122 this->type = type; 91 123 else … … 124 156 125 157 // setting up the Text-Width if DYNAMIC 126 if (this->type & TEXT_RENDER_DYNAMIC && this->getAlignment() != TEXT_ALIGN_LEFT )158 if (this->type & TEXT_RENDER_DYNAMIC && this->getAlignment() != TEXT_ALIGN_LEFT && this->font != NULL) 127 159 { 128 160 Glyph** glyphArray = this->font->getGlyphArray(); … … 194 226 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 195 227 196 if(likely(type & TEXT_RENDER_DYNAMIC ))228 if(likely(type & TEXT_RENDER_DYNAMIC && this->font != NULL)) 197 229 { 198 230 Glyph** glyphArray = this->font->getGlyphArray();
Note: See TracChangeset
for help on using the changeset viewer.