Changeset 5179 in orxonox.OLD for trunk/src/lib/graphics
- Timestamp:
- Sep 13, 2005, 11:23:34 PM (19 years ago)
- Location:
- trunk/src/lib/graphics
- Files:
-
- 2 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(); -
trunk/src/lib/graphics/text_engine.h
r5124 r5179 106 106 { 107 107 public: 108 Text(Font* font , TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC);108 Text(Font* font = NULL, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC); 109 109 ~Text(); 110 110 111 void setFont(Font* font); 112 void setFont(const char* fontFile, unsigned int fontSize); 111 113 void setType(TEXT_RENDER_TYPE type); 112 114 void setText(const char* text, bool isExtern = false);
Note: See TracChangeset
for help on using the changeset viewer.