Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2006, 6:58:01 PM (18 years ago)
Author:
bensch
Message:

better, but still not running, yet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/fontdata/src/lib/graphics/text_engine/text.cc

    r8753 r8754  
    2828 */
    2929Text::Text(const std::string& fontFile, unsigned int textSize)
     30  : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
    3031{
    3132  this->setClassID(CL_TEXT, "Text");
     
    3839
    3940  this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
    40 
    41   this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
    4241}
    4342
    4443Text::Text(const Text& text)
     44  : _font()
    4545{
    4646  this->setClassID(CL_TEXT, "Text");
    47   this->_font = NULL;
    4847
    4948  *this = text;
     
    9392  this->_color = text._color;
    9493  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;
    9996
    10097  this->_text = text._text;
     
    192189
    193190  // unloading the Font if we alrady have one loaded.
    194   this->_font = newFont;
     191  this->_font = *newFont;
    195192//   if (oldFont != NULL && oldFont != Font::getDefaultFont())
    196193//     ResourceManager::getInstance()->unload(oldFont);
     
    238235  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    239236
    240   glBindTexture(GL_TEXTURE_2D, this->_font->getTexture());
     237  glBindTexture(GL_TEXTURE_2D, this->_font.getTexture());
    241238  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    242239  glRotatef(this->getAbsDir2D(), 0, 0, 1);
     
    247244  for (unsigned int i = 0; i < this->_text.size(); i++)
    248245  {
    249     if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_text[i]]) != NULL))
     246    if(likely((tmpGlyph = this->font().getGlyphArray()[this->_text[i]]) != NULL))
    250247    {
    251248      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
     
    277274  float width = 0;
    278275  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;
    281278  this->setSizeX2D(width * this->size());
    282279}
     
    288285void Text::debug() const
    289286{
    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());
    291288  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());
    292289}
Note: See TracChangeset for help on using the changeset viewer.