Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7455 in orxonox.OLD for trunk/src/lib/graphics


Ignore:
Timestamp:
Apr 29, 2006, 10:38:12 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: fixed a SegFault (that this worked before is some wonder :)

Location:
trunk/src/lib/graphics/text_engine
Files:
2 edited

Legend:

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

    r7454 r7455  
    9191  for (unsigned int i = 0; i < this->getText().size(); ++i)
    9292  {
    93     if (unlikely(this->getText()[i] == '\n' || i == this->lineEnds[lineNumber]))
     93    if (unlikely(!this->lineEnds.empty() && i == this->lineEnds[lineNumber]))
    9494    {
    9595      // go to the next Line.
     
    140140      width += this->getFont()->getGlyphArray()[this->getText()[i]]->advance;
    141141  }
    142   this->setSizeY2D(this->lineEnds.size() * (this->lineSpacing+this->getFont()->getMaxHeight()));
     142  this->setSizeY2D(this->lineEnds.size() * (this->lineSpacing + this->getFont()->getMaxHeight()));
    143143}
  • trunk/src/lib/graphics/text_engine/text.cc

    r7453 r7455  
    3535  // initialize this Text
    3636  this->font = NULL;
    37   this->text = "";
    38   this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
     37
     38  this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
     39
    3940  this->blending = TEXT_DEFAULT_BLENDING;
    4041  this->color = TEXT_DEFAULT_COLOR;
    41 
    42   if (!fontFile.empty())
    43     this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
    44 
     42  this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
    4543  this->setSize(TEXT_DEFAULT_SIZE);
    4644}
     
    6361void Text::setFont(const std::string& fontFile, unsigned int fontSize)
    6462{
    65   Font* newFont;
     63  Font* newFont = NULL;
    6664  Font* oldFont = this->font;
    6765
     
    7674    }
    7775  }
    78   else
     76  if (newFont == NULL)
    7977    newFont = Font::getDefaultFont();
     78  assert(newFont != NULL);
    8079
    8180  // unloading the Font if we alrady have one loaded.
Note: See TracChangeset for help on using the changeset viewer.