Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8765 in orxonox.OLD for trunk/src/lib/graphics/text_engine/font.cc


Ignore:
Timestamp:
Jun 24, 2006, 3:49:33 AM (19 years ago)
Author:
bensch
Message:

trunk: much better loading of the Font

File:
1 edited

Legend:

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

    r8764 r8765  
    192192void Font::setStyle(const std::string& renderStyle)
    193193{
    194   this->data->setStyle(renderStyle);
     194  /// FIXME
     195  //this->data->setStyle(renderStyle);
    195196}
    196197
     
    207208 * @param fileName the File to write the image into.
    208209 */
    209 void Font::createAsciiImage(const std::string& fileName, unsigned int size) const
    210 {
    211   if (this->data->fontTTF == NULL)
     210void Font::createAsciiImage(const std::string& ttfFile, const std::string& fileName, unsigned int size)
     211{
     212  TTF_Font* fontTTF = TTF_OpenFont(ttfFile.c_str(), size);
     213
     214  if (fontTTF == NULL)
    212215    return;
    213   int height = this->getMaxHeight();
     216  int height = TTF_FontHeight(fontTTF);
    214217
    215218  //
     
    241244    {
    242245      SDL_Surface* glyphSurf = NULL;
    243       if (likely(this->data->fontTTF != NULL))
    244       {
    245         SDL_Color white = {255, 255, 255};
    246         glyphSurf = TTF_RenderGlyph_Blended(this->data->fontTTF, posX+size*posY, white);
    247       }
     246      SDL_Color white = {255, 255, 255};
     247      glyphSurf = TTF_RenderGlyph_Blended(fontTTF, posX+size*posY, white);
     248
    248249      if( glyphSurf != NULL )
    249250      {
     
    259260  SDL_SaveBMP(tmpSurf, fileName.c_str());
    260261  SDL_FreeSurface(tmpSurf);
     262
     263  TTF_CloseFont(fontTTF);
    261264}
    262265
     
    273276  PRINT(0)("TEST %p and %p\n", this->data.get(), this->data->texData.get());
    274277  // print the loaded font's style
    275   int style = TTF_STYLE_NORMAL;
     278/*  int style = TTF_STYLE_NORMAL;
    276279  if (likely(this->data->fontTTF != NULL))
    277280    style = TTF_GetFontStyle(this->data->fontTTF);
     
    286289      PRINTF(0)(" italic");
    287290    if(style&TTF_STYLE_UNDERLINE)
    288       PRINTF(0)(" underline");
    289   }
     291      PRINTF(0)(" underline");*/
     292//  }
    290293  PRINTF(0)("\n");
    291294}
Note: See TracChangeset for help on using the changeset viewer.