Changeset 8754 in orxonox.OLD for branches/fontdata/src/lib/graphics/text_engine/text.cc
- Timestamp:
- Jun 23, 2006, 6:58:01 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/fontdata/src/lib/graphics/text_engine/text.cc
r8753 r8754 28 28 */ 29 29 Text::Text(const std::string& fontFile, unsigned int textSize) 30 : _font(fontFile, FONT_DEFAULT_RENDER_SIZE) 30 31 { 31 32 this->setClassID(CL_TEXT, "Text"); … … 38 39 39 40 this->setAlignment(TEXT_DEFAULT_ALIGNMENT); 40 41 this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);42 41 } 43 42 44 43 Text::Text(const Text& text) 44 : _font() 45 45 { 46 46 this->setClassID(CL_TEXT, "Text"); 47 this->_font = NULL;48 47 49 48 *this = text; … … 93 92 this->_color = text._color; 94 93 this->setAlignment(text.getAlignment()); 95 if (this->_font != NULL) 96 ResourceManager::getInstance()->unload(this->_font); 97 98 this->_font = (Font*)ResourceManager::getInstance()->copy( text._font ); //!< HACK 94 95 this->_font = text._font; 99 96 100 97 this->_text = text._text; … … 192 189 193 190 // unloading the Font if we alrady have one loaded. 194 this->_font = newFont;191 this->_font = *newFont; 195 192 // if (oldFont != NULL && oldFont != Font::getDefaultFont()) 196 193 // ResourceManager::getInstance()->unload(oldFont); … … 238 235 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 239 236 240 glBindTexture(GL_TEXTURE_2D, this->_font ->getTexture());237 glBindTexture(GL_TEXTURE_2D, this->_font.getTexture()); 241 238 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); 242 239 glRotatef(this->getAbsDir2D(), 0, 0, 1); … … 247 244 for (unsigned int i = 0; i < this->_text.size(); i++) 248 245 { 249 if(likely((tmpGlyph = this->font() ->getGlyphArray()[this->_text[i]]) != NULL))246 if(likely((tmpGlyph = this->font().getGlyphArray()[this->_text[i]]) != NULL)) 250 247 { 251 248 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); … … 277 274 float width = 0; 278 275 for (unsigned int i = 0; i < this->_text.size(); i++) 279 if(this->_font ->getGlyphArray()[this->_text[i]] != NULL)280 width += this->_font ->getGlyphArray()[this->_text[i]]->advance;276 if(this->_font.getGlyphArray()[this->_text[i]] != NULL) 277 width += this->_font.getGlyphArray()[this->_text[i]]->advance; 281 278 this->setSizeX2D(width * this->size()); 282 279 } … … 288 285 void Text::debug() const 289 286 { 290 PRINT(0)("=== TEXT: %s (with Font:'%s') displaying %s ===\n", this->getName(), this->_font ->getName(), this->_text.c_str());287 PRINT(0)("=== TEXT: %s (with Font:'%s') displaying %s ===\n", this->getName(), this->_font.getName(), this->_text.c_str()); 291 288 PRINT(0)("Color: r=%0.2f g=%0.2f b=%0.2f a=%0.2f\n", this->_color.r(), this->_color.g(), this->_color.b(), this->_color.a()); 292 289 }
Note: See TracChangeset
for help on using the changeset viewer.