Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 24, 2006, 2:14:37 AM (18 years ago)
Author:
bensch
Message:

orxonox/font: nicer implementation

File:
1 edited

Legend:

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

    r8759 r8760  
    2828 */
    2929Text::Text(const std::string& fontFile, unsigned int textSize)
    30   : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
     30    : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
    3131{
    3232  this->setClassID(CL_TEXT, "Text");
     
    3535  this->_size = textSize;
    3636  this->setSizeY2D(textSize);
    37   this->_color = TEXT_DEFAULT_COLOR;
     37  this->setColor(TEXT_DEFAULT_COLOR);
    3838
    3939  this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
     
    4141
    4242Text::Text(const Text& text)
    43   : _font()
     43    : _font()
    4444{
    4545  this->setClassID(CL_TEXT, "Text");
     
    5454Text::~Text()
    5555{
    56 /*  if (this->_font != NULL && this->_font != Font::getDefaultFont())
    57     ResourceManager::getInstance()->unload(this->_font);*/
     56  /*  if (this->_font != NULL && this->_font != Font::getDefaultFont())
     57      ResourceManager::getInstance()->unload(this->_font);*/
    5858}
    5959
     
    6767  return (this->_text == text._text &&
    6868          this->_size == text._size &&
    69           this->_font == text._font &&
    70           this->_color == text._color);
     69          this->_font == text._font );
    7170}
    7271
     
    8988{
    9089  this->_size = text._size;
    91   this->_color = text._color;
    9290  this->setAlignment(text.getAlignment());
    9391
     
    171169{
    172170  Font* newFont = NULL;
    173 //  Font* oldFont = this->_font;
     171  //  Font* oldFont = this->_font;
    174172
    175173  // load a new Font
     
    179177    if (newFont == NULL)
    180178    {
    181 //      newFont = &Font::();
     179      //      newFont = &Font::();
    182180      PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str());
    183181    }
    184182  }
    185 //  if (newFont == NULL)
    186 //    newFont = Font::getDefaultFont();
    187   assert(newFont != NULL);
    188 
    189   // unloading the Font if we alrady have one loaded.
    190 
    191   this->_font = *newFont;
    192 //   if (oldFont != NULL && oldFont != Font::getDefaultFont())
    193 //     ResourceManager::getInstance()->unload(oldFont);
    194 
     183
     184  if (newFont == NULL)
     185    this->_font = Font();
     186  else
     187    this->_font = *newFont;
     188
     189  printf("Font Texture is\n" );
     190  _font.debug();
    195191  this->setupTextWidth();
    196192}
     
    223219    glTranslatef(-this->getSizeX2D()/2, 0, 0);
    224220
    225   // drawing this Text.
    226   // setting the Blending effects
    227   glColor4fv(&this->_color[0]);
    228 
    229221  this->font().select();
    230222  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
     
    278270{
    279271  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font.getName(), this->_text.c_str());
    280   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());
    281 }
    282 
     272  //  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());
     273}
     274
Note: See TracChangeset for help on using the changeset viewer.