Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2006, 5:28:10 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: compiles again, BUT well…. i do not expect it to run anymore

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/lib/graphics/text_engine/font.cc

    r6609 r7203  
    3737 * @param fontSize the Size of the Font in Pixels
    3838 */
    39 Font::Font(const char* fontFile, unsigned int renderSize)
     39Font::Font(const std::string& fontFile, unsigned int renderSize)
    4040{
    4141  this->init();
     
    4444  this->setStyle("c");
    4545
    46   if (fontFile != NULL)
     46  if (!fontFile.empty())
    4747    this->loadFontFromTTF(fontFile);
    4848}
     
    5252 * @param imageFile the ImageFile to load the Font From.
    5353 */
    54 Font::Font(const char* imageFile)
     54Font::Font(const std::string& imageFile)
    5555{
    5656  this->init();
     
    5858  //  this->setSize(fontSize);
    5959  SDL_Surface* image = NULL;
    60   if (imageFile != NULL)
    61     image = IMG_Load(imageFile);
     60  if (!imageFile.empty())
     61    image = IMG_Load(imageFile.c_str());
    6262  else
    6363    return;
     
    6868  }
    6969  else
    70     PRINTF(1)("loading from surface %s failed: %s\n", imageFile, IMG_GetError());
     70    PRINTF(1)("loading from surface %s failed: %s\n", imageFile.c_str(), IMG_GetError());
    7171}
    7272
     
    114114
    115115  //! @todo check if we really do not need to delete the fastTextureID here.
    116 //   if (this->fastTextureID != 0)
    117 //     if(glIsTexture(this->fastTextureID))
    118 //       glDeleteTextures(1, &this->fastTextureID);
     116  //   if (this->fastTextureID != 0)
     117  //     if(glIsTexture(this->fastTextureID))
     118  //       glDeleteTextures(1, &this->fastTextureID);
    119119
    120120  // erease this font out of the memory.
     
    140140 * @returns true if loaded, false if something went wrong, or if a font was loaded before.
    141141 */
    142 bool Font::loadFontFromTTF(const char* fontFile)
     142bool Font::loadFontFromTTF(const std::string& fontFile)
    143143{
    144144  // checking for existent Font.
     
    222222 *   i: italic, b: bold, u, underline
    223223 */
    224 void Font::setStyle(const char* renderStyle)
     224void Font::setStyle(const std::string& renderStyle)
    225225{
    226226  this->renderStyle = TTF_STYLE_NORMAL;
    227227
    228   for (int i = 0; i < strlen(renderStyle); i++)
    229     if (strncmp(renderStyle+i, "b", 1) == 0)
     228  for (int i = 0; i < renderStyle.size(); i++)
     229  {
     230    if (renderStyle[i] == 'b')
    230231      this->renderStyle |= TTF_STYLE_BOLD;
    231   else if (strncmp(renderStyle+i, "i", 1) == 0)
    232     this->renderStyle |= TTF_STYLE_ITALIC;
    233   else if (strncmp(renderStyle+i, "u", 1) == 0)
    234     this->renderStyle |= TTF_STYLE_UNDERLINE;
    235 
     232    else if (renderStyle[i] == 'i')
     233      this->renderStyle |= TTF_STYLE_ITALIC;
     234    else if (renderStyle[i] == 'u')
     235      this->renderStyle |= TTF_STYLE_UNDERLINE;
     236  }
    236237  if (likely(this->fontTTF != NULL))
    237238    TTF_SetFontStyle(this->fontTTF, this->renderStyle);
    238 //  else
    239 //    PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n");
     239  //  else
     240  //    PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n");
    240241}
    241242
     
    247248 * @param fileName the File to write the image into.
    248249 */
    249 void Font::createAsciiImage(const char* fileName, unsigned int size) const
     250void Font::createAsciiImage(const std::string& fileName, unsigned int size) const
    250251{
    251252  if (this->fontTTF == NULL)
     
    258259  SDL_Rect tmpRect; // this represents a Rectangle for blitting.
    259260  SDL_Surface* tmpSurf =  SDL_CreateRGBSurface(SDL_SWSURFACE,
    260                                                height*size, height*size,
    261                                                32,
     261                          height*size, height*size,
     262                          32,
    262263#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    263                                                0x000000FF,
    264                                                0x0000FF00,
    265                                                0x00FF0000,
    266                                                0xFF000000
     264                          0x000000FF,
     265                          0x0000FF00,
     266                          0x00FF0000,
     267                          0xFF000000
    267268#else
    268                                                0xFF000000,
    269                                                0x00FF0000,
    270                                                0x0000FF00,
    271                                                0x000000FF
     269                          0xFF000000,
     270                          0x00FF0000,
     271                          0x0000FF00,
     272                          0x000000FF
    272273#endif
    273274                                              );
     
    299300    }
    300301  }
    301   SDL_SaveBMP(tmpSurf, fileName);
     302  SDL_SaveBMP(tmpSurf, fileName.c_str());
    302303  SDL_FreeSurface(tmpSurf);
    303304}
     
    409410
    410411  this->initGlyphs(32, numberOfGlyphs);
    411 //  this->glyphArray[32]->width = .5f; //!< @todo find out the real size of a Space
     412  //  this->glyphArray[32]->width = .5f; //!< @todo find out the real size of a Space
    412413
    413414  int rectSize = this->findOptimalFastTextureSize();
     
    418419  SDL_Rect tmpRect; // this represents a Rectangle for blitting.
    419420  SDL_Surface* tmpSurf =  SDL_CreateRGBSurface(SDL_SWSURFACE,
    420                                                rectSize, rectSize,
    421                                                32,
     421                          rectSize, rectSize,
     422                          32,
    422423#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    423                                                0x000000FF,
    424                                                0x0000FF00,
    425                                                0x00FF0000,
    426                                                0xFF000000
     424                          0x000000FF,
     425                          0x0000FF00,
     426                          0x00FF0000,
     427                          0xFF000000
    427428#else
    428                                                0xFF000000,
    429                                                0x00FF0000,
    430                                                0x0000FF00,
    431                                                0x000000FF
     429                          0xFF000000,
     430                          0x00FF0000,
     431                          0x0000FF00,
     432                          0x000000FF
    432433#endif
    433434                                              );
     
    457458        break;
    458459      }
    459           // reading in the new Glyph
     460      // reading in the new Glyph
    460461      if (likely(this->fontTTF != NULL))
    461462      {
     
    521522  for (int i = from; i <= lastGlyph; i++)
    522523  {
    523       // setting up all the Glyphs we like.
     524    // setting up all the Glyphs we like.
    524525    glyphArray[i] = getGlyphMetrics(i);
    525526  }
     
    555556      if((tmpGlyph = this->glyphArray[i]) != NULL)
    556557      {
    557               // getting the height of the highest Glyph in the Line.
     558        // getting the height of the highest Glyph in the Line.
    558559        if (tmpGlyph->height*this->renderSize > maxLineHeight)
    559560          maxLineHeight = (int)(tmpGlyph->height*this->renderSize);
     
    563564          x = 0;
    564565          y = y + maxLineHeight;
    565                   //maxLineHeight = 0;
     566          //maxLineHeight = 0;
    566567        }
    567568        if (y + maxLineHeight + 1 > size)
     
    592593  if(style==TTF_STYLE_NORMAL)
    593594    PRINTF(0)(" normal");
    594   else {
     595  else
     596  {
    595597    if(style&TTF_STYLE_BOLD)
    596598      PRINTF(0)(" bold");
Note: See TracChangeset for help on using the changeset viewer.