Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7426 in orxonox.OLD for trunk/src/lib/graphics/text_engine


Ignore:
Timestamp:
Apr 28, 2006, 10:27:28 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: ShellFont can be changed in threads :)

File:
1 edited

Legend:

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

    r7355 r7426  
    6565void Text::setFont(const std::string& fontFile, unsigned int fontSize)
    6666{
    67   Font* tmpFont;
    68   Text* newText;
    69   Vector tmpVec;
    70 
    71   // unloading the Font if we alrady have one loaded.
    72   if (this->font != NULL && this->font != Font::getDefaultFont())
    73     ResourceManager::getInstance()->unload(this->font);
    74   this->font = NULL;
     67  Font* newFont;
     68  Font* oldFont = this->font;
    7569
    7670  // load a new Font
    7771  if (!fontFile.empty())
    7872  {
    79     tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, (int)fontSize);
    80     if (tmpFont != NULL)
    81       this->font = tmpFont;
    82     else
     73    newFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, (int)fontSize);
     74    if (newFont == NULL)
     75    {
     76      newFont = Font::getDefaultFont();
    8377      PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str());
    84   }
     78    }
     79  }
     80  else
     81    newFont = Font::getDefaultFont();
     82
     83  // unloading the Font if we alrady have one loaded.
     84  this->font = newFont;
     85  if (oldFont != NULL && oldFont != Font::getDefaultFont())
     86    ResourceManager::getInstance()->unload(oldFont);
    8587}
    8688
Note: See TracChangeset for help on using the changeset viewer.