Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 24, 2006, 2:16:12 AM (19 years ago)
Author:
bensch
Message:

merged the new Font-Implementation back here
merged with svn merge https://svn.orxonox.net/orxonox/branches/fontdata . -r8752:HEAD
no conflicts, naturally

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

Legend:

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

    r8751 r8761  
    1717
    1818#include "font.h"
    19 #include "text.h"
    2019
    2120#ifdef HAVE_SDL_IMAGE_H
     
    2423#include <SDL/SDL_image.h>
    2524#endif
     25
    2626#include "default_font.xpm"
    2727
    2828#include "debug.h"
    29 #include "stdlibincl.h"
    3029#include "compiler.h"
    31 using namespace std;
     30
     31
     32Font::Font()
     33  : data(Font::defaultFontData)
     34{
     35  this->init();
     36
     37}
    3238
    3339/**
     
    3743 */
    3844Font::Font(const std::string& fontFile, unsigned int renderSize)
    39   : data(new FontData())
     45  : data(Font::defaultFontData)
    4046{
    4147  this->init();
    4248
    43 
    44   this->data->renderSize = renderSize;
    45   this->setStyle("c");
    46 
    4749  if (!fontFile.empty())
    48     this->loadFontFromTTF(fontFile);
    49 }
     50    this->loadFontFromTTF(fontFile, renderSize);
     51}
     52
    5053
    5154/**
     
    5457 */
    5558Font::Font(const std::string& imageFile)
    56   : data(new FontData())
     59  : data(Font::defaultFontData)
    5760{
    5861  this->init();
     62
    5963  this->setName(imageFile);
    6064  //  this->setSize(fontSize);
     
    7882 */
    7983Font::Font(char** xpmArray)
    80   : data(new FontData())
     84  : data(Font::defaultFontData)
    8185{
    8286  this->init();
     
    9296  }
    9397  else
    94     PRINTF(1)("loading from surface failed: %s\n", IMG_GetError());
     98    PRINTF(1)("Loading from XPM-array failed: %s\n", IMG_GetError());
    9599}
    96100
     
    105109{ }
    106110
     111Font& Font::operator=(const Font& font)
     112{
     113  Material::operator=(font);
     114  this->data = font.data;
     115
     116  return *this;
     117};
     118
     119
    107120/**
    108121 * @brief initializes a Font (with default values)
     
    110123void Font::init()
    111124{
     125  this->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     126
    112127  this->setClassID(CL_FONT, "Font");
    113 }
    114 
     128  if (Font::defaultFontData.get() == NULL)
     129  {
     130     Font::initDefaultFont();
     131    this->data = Font::defaultFontData;
     132  }
     133}
     134
     135FontDataPointer Font::defaultFontData(NULL);
     136
     137/**
     138 * @brief initializes the default font
     139 */
     140void Font::initDefaultFont()
     141{
     142  // temporarily create a Font.
     143  Font::defaultFontData = FontDataPointer(new FontData);
     144  // apply the Data.
     145  printf("before: %p\n", defaultFontData.get());
     146  Font::defaultFontData = Font(font_xpm).data;
     147  printf("after: %p\n", defaultFontData.get());
     148}
    115149
    116150/**
     
    119153 * @returns true if loaded, false if something went wrong, or if a font was loaded before.
    120154 */
    121 bool Font::loadFontFromTTF(const std::string& fontFile)
    122 {
    123   // checking for existent Font.
    124   if (this->data->fontTTF != NULL)
    125   {
    126     TTF_CloseFont(this->data->fontTTF);
    127     this->data->fontTTF = NULL;
    128   }
    129 
     155bool Font::loadFontFromTTF(const std::string& fontFile, unsigned int renderSize)
     156{
     157  this->data = FontDataPointer (new FontData());
    130158
    131159  this->setName(fontFile);
    132   this->data->fontTTF = TTF_OpenFont(this->getName(), this->data->renderSize);
     160  this->data->fontTTF = TTF_OpenFont(fontFile.c_str(), renderSize);
     161  this->data->renderSize = renderSize;
    133162
    134163  if(this->data->fontTTF != NULL)
    135164  {
    136     this->createFastTexture();
    137     return (this->getTexture() != 0);
     165    this->setStyle("c");
     166    if (this->createFastTexture())
     167      return true;
     168    else
     169    {
     170      this->data = Font::defaultFontData;
     171      return false;
     172    }
    138173  }
    139174  else
    140175  {
    141176    PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError());
     177    this->data = Font::defaultFontData;
    142178    return false;
    143179  }
     
    151187bool Font::loadFontFromSDL_Surface(SDL_Surface* surface)
    152188{
    153   // loading to a texture.
    154189  if(surface == NULL)
    155190    return false;
    156191
    157   if (this->data->fontTTF != NULL)
    158   {
    159     TTF_CloseFont(this->data->fontTTF);
    160     this->data->fontTTF = NULL;
    161   }
     192  this->data = FontDataPointer (new FontData());
     193  // loading to a texture.
     194
    162195  bool hasAlpha;
    163   SDL_Surface* newSurf = this->prepareSurface(surface, hasAlpha);
     196  SDL_Surface* newSurf = Texture::prepareSurface(surface, hasAlpha);
    164197  if (newSurf != NULL)
    165198  {
    166     this->setSurface(newSurf);
    167     this->setAlpha(hasAlpha);
     199    this->data->texData->setSurface(newSurf);
     200    this->data->texData->setAlpha(hasAlpha);
    168201    this->setTexture(Texture::loadTexToGL(newSurf));
     202  }
     203  else
     204  {
     205    this->data = Font::defaultFontData;
     206    return false;
    169207  }
    170208
     
    223261  //    PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n");
    224262}
    225 
    226 Font* Font::defaultFont = NULL;
    227263
    228264/**
     
    283319  SDL_SaveBMP(tmpSurf, fileName.c_str());
    284320  SDL_FreeSurface(tmpSurf);
    285 }
    286 
    287 /**
    288  * @brief initializes the default font
    289  */
    290 void Font::initDefaultFont()
    291 {
    292   if (Font::defaultFont == NULL)
    293     Font::defaultFont = new Font(font_xpm);
    294 }
    295 
    296 /**
    297  * @brief deletes the default font
    298  */
    299 void Font::removeDefaultFont()
    300 {
    301   if (Font::defaultFont != NULL)
    302     delete Font::defaultFont;
    303   Font::defaultFont = NULL;
    304321}
    305322
     
    473490//       sprintf( outName, "%s-glyphs.bmp", this->getName());
    474491//       SDL_SaveBMP(tmpSurf, outName);
    475   this->setAlpha(true);
    476   if (this->setSurface(tmpSurf))
    477     (this->setTexture(Texture::loadTexToGL(tmpSurf)));
     492  this->data->texData->setAlpha(true);
     493  if (this->data->texData->setSurface(tmpSurf))
     494    this->setTexture(Texture::loadTexToGL(tmpSurf));
    478495  return true;
    479496}
     497
     498/**
     499 * @brief the Internal implementation of setting up the Texture.
     500 * @param texture the Texture to load.
     501 * @returns true on success, false otherwise.
     502 */
     503bool Font::setTexture(GLuint texture)
     504{
     505  bool retVal = this->data->texData->setTexture(texture);
     506  this->setDiffuseMap(data->texData, 0);
     507  printf("this->texture %d\n", texture);
     508  //printf(this->getT)
     509  this->debug();
     510  return retVal;
     511};
    480512
    481513/**
     
    569601 * @brief a simple function to get some interesting information about this class
    570602 */
    571 void Font::debug()
    572 {
     603void Font::debug() const
     604{
     605  Material::debug();
     606
     607  PRINT(0)("TEST %p and %p\n", this->data.get(), this->data->texData.get());
    573608  // print the loaded font's style
    574609  int style = TTF_STYLE_NORMAL;
  • trunk/src/lib/graphics/text_engine/font.h

    r8751 r8761  
    1111#define _FONT_H
    1212
    13 #include "texture.h"
     13#include "material.h"
    1414
    1515#include "font_data.h"
     
    1717
    1818//! A class to handle a Font of a certain ttf-File/image-file, Size.
    19 class Font : public Texture
     19class Font : public Material /* TODO Material it should be */
    2020{
    2121
    2222public:
    23   Font(const std::string& fontFile,
    24       unsigned int renderSize);
     23  Font();
     24  Font(const std::string& fontFile, unsigned int renderSize);
    2525  Font(const std::string& imageFile);
    2626  Font(char** xpmArray);
    2727  virtual ~Font();
    2828
    29   //  font
    30   bool loadFontFromTTF(const std::string& fontFile);
     29  Font& operator=(const Font& font);
     30  /** @brief compare two fonts @param font the comparator, @returns true if they match */
     31  bool operator==(const Font& font) const { return this->data == font.data; };
     32
     33
     34  /// LOADING new Fonts
     35  bool loadFontFromTTF(const std::string& fontFile, unsigned int renderSize);
    3136  bool loadFontFromSDL_Surface(SDL_Surface* surface);
    3237
     
    4247  int getMaxDescent() const;
    4348
    44   /** @returns the default Font */
    45   inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; };
     49  void createAsciiImage(const std::string& fileName, unsigned int size) const;
    4650
    47   void createAsciiImage(const std::string& fileName, unsigned int size) const;
     51  void debug() const;
     52
     53private:
     54  void init();
     55  void initGlyphs(Uint16 from, Uint16 count);
     56  bool getGlyphMetrics(Glyph* glyph, Uint16 character);
    4857  static void initDefaultFont();
    49   static void removeDefaultFont();
     58
     59  int findOptimalFastTextureSize();
     60  bool createFastTexture();
     61
     62  bool setTexture(GLuint texture);
    5063
    5164
    5265private:
    53   void init();
    54   bool getGlyphMetrics(Glyph* glyph, Uint16 character);
     66  static FontDataPointer    defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
    5567
    56   bool createFastTexture();
    57 
    58   void initGlyphs(Uint16 from, Uint16 count);
    59   int findOptimalFastTextureSize();
    60 
    61   void debug();
    62 
    63 private:
    64   static Font*  defaultFont;         //!< a default font, that is used, if other fonts were unable to be loaded.
    65 
    66   fontDataPointer data;
     68  FontDataPointer           data;                //!< A Data-Pointer to a Font.
    6769};
    6870
  • trunk/src/lib/graphics/text_engine/font_data.cc

    r8751 r8761  
    2727 */
    2828FontData::FontData()
     29  : texData(new TextureData)
    2930{
     31  printf("CREATE FONT_DATA\n");
    3032  this->fontTTF = NULL;
    3133  this->glyphArray = NULL;
     34  this->renderStyle = TTF_STYLE_NORMAL;
     35  this->renderSize = FONT_DEFAULT_RENDER_SIZE;
    3236}
    3337
  • trunk/src/lib/graphics/text_engine/font_data.h

    r8751 r8761  
    4848
    4949
    50 class FontData : public TextureData
     50class FontData
    5151{
    5252  friend class Font;
    5353public:
    54   FontData();
    5554  ~FontData();
    5655
     
    6564
    6665private:
     66  FontData();
     67
     68private:
    6769  TTF_Font*     fontTTF;             //!< The font we use for this.
    6870  int           renderStyle;         //!< The Renderstyle
     
    7072
    7173  Glyph**       glyphArray;          //!< An Array of all the Glyphs stored in the Array of Glyphs.
     74
     75  TextureDataPointer   texData;
    7276};
    7377
    74 typedef CountPointer<FontData> fontDataPointer;
     78typedef CountPointer<FontData> FontDataPointer;
    7579
    7680#endif /* _FONT_DATA_H */
  • trunk/src/lib/graphics/text_engine/limited_width_text.cc

    r8619 r8761  
    7676  glActiveTexture(GL_TEXTURE0);
    7777
    78   glEnable(GL_BLEND);
    79   glEnable(GL_TEXTURE_2D);
    80   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    81   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
     78//   glEnable(GL_BLEND);
     79//   glEnable(GL_TEXTURE_2D);
     80//   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     81//   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
     82//
     83//   glBindTexture(GL_TEXTURE_2D, this->font().getTexture());
     84  this->font().select();
    8285
    83   glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
    8486  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    8587  glRotatef(this->getAbsDir2D(), 0, 0, 1);
     
    9092  for (unsigned int i = 0; i < this->_dotedText.size(); i++)
    9193  {
    92     if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_dotedText[i]]) != NULL))
     94    if(likely((tmpGlyph = this->font().getGlyphArray()[this->_dotedText[i]]) != NULL))
    9395    {
    9496      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
     
    118120void LimitedWidthText::setupTextWidth()
    119121{
    120   float dotsSize = this->font()->getGlyphArray()[46]->advance * 3.0;
     122  float dotsSize = this->font().getGlyphArray()[46]->advance * 3.0;
    121123
    122124  float width = 0.0f;
     
    134136          this->_dotedText = this->text().substr(0, i) + "...";
    135137          if (i > 0)
    136             width -= this->font()->getGlyphArray()[this->text()[i-1]]->advance;
     138            width -= this->font().getGlyphArray()[this->text()[i-1]]->advance;
    137139          width += dotsSize;
    138140          break;
    139141        }
    140142        // Advance the Text.
    141         if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
    142           width += this->font()->getGlyphArray()[this->text()[i]]->advance;
     143        if(this->font().getGlyphArray()[this->text()[i]] != NULL)
     144          width += this->font().getGlyphArray()[this->text()[i]]->advance;
    143145      }
    144146      break;
     
    152154          this->_dotedText = std::string("...") + this->text().substr(i);
    153155          if (i + 1 < (int)text().size() )
    154             width -= this->font()->getGlyphArray()[this->text()[i+1]]->advance;
     156            width -= this->font().getGlyphArray()[this->text()[i+1]]->advance;
    155157          width += dotsSize;
    156158          break;
    157159        }
    158160        // Advance the Text.
    159         if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
    160           width += this->font()->getGlyphArray()[this->text()[i]]->advance;
     161        if(this->font().getGlyphArray()[this->text()[i]] != NULL)
     162          width += this->font().getGlyphArray()[this->text()[i]]->advance;
    161163      }
    162164      break;
  • trunk/src/lib/graphics/text_engine/multi_line_text.cc

    r8619 r8761  
    7676  glActiveTexture(GL_TEXTURE0);
    7777
    78   glColor4fv(&this->color()[0]);
     78/*  glColor4fv(&this->color()[0]);
    7979  glEnable(GL_BLEND);
    8080  glEnable(GL_TEXTURE_2D);
     
    8282  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    8383
    84   glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
     84  glBindTexture(GL_TEXTURE_2D, this->font().getTexture());*/
     85  this->font().select();
    8586  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
    8687  glRotatef(this->getAbsDir2D(), 0, 0, 1);
     
    99100      ++lineNumber;
    100101      posX = 0.0f;
    101       posY += this->lineSpacing + this->size(); //this->font()->getMaxHeight();
     102      posY += this->lineSpacing + this->size(); //this->font().getMaxHeight();
    102103    }
    103104
    104     if(likely((tmpGlyph = this->font()->getGlyphArray()[this->text()[i]]) != NULL))
     105    if(likely((tmpGlyph = this->font().getGlyphArray()[this->text()[i]]) != NULL))
    105106    {
    106107      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
     
    141142      {
    142143        this->lineEnds.push_back( i -1 );
    143         width = this->font()->getGlyphArray()[this->text()[i-1]]->advance;
     144        width = this->font().getGlyphArray()[this->text()[i-1]]->advance;
    144145      }
    145146      else
     
    148149
    149150    // Advance the Text.
    150     if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
    151       width += this->font()->getGlyphArray()[this->text()[i]]->advance;
     151    if(this->font().getGlyphArray()[this->text()[i]] != NULL)
     152      width += this->font().getGlyphArray()[this->text()[i]]->advance;
    152153  }
    153154  this->lineCount = lineEnds.size() + 1;
    154   this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font()->getMaxHeight()));
     155  this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font().getMaxHeight()));
    155156}
    156157
  • trunk/src/lib/graphics/text_engine/text.cc

    r8619 r8761  
    2828 */
    2929Text::Text(const std::string& fontFile, unsigned int textSize)
     30    : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
    3031{
    3132  this->setClassID(CL_TEXT, "Text");
    3233
    3334  // initialize this Text
    34   this->_font = NULL;
    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);
    40 
    41   this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
    4240}
    4341
    4442Text::Text(const Text& text)
     43    : _font()
    4544{
    4645  this->setClassID(CL_TEXT, "Text");
    47   this->_font = NULL;
    4846
    4947  *this = text;
     
    5654Text::~Text()
    5755{
    58   if (this->_font != NULL && this->_font != Font::getDefaultFont())
    59     ResourceManager::getInstance()->unload(this->_font);
     56  /*  if (this->_font != NULL && this->_font != Font::getDefaultFont())
     57      ResourceManager::getInstance()->unload(this->_font);*/
    6058}
    6159
     
    6967  return (this->_text == text._text &&
    7068          this->_size == text._size &&
    71           this->_font == text._font &&
    72           this->_color == text._color);
     69          this->_font == text._font );
    7370}
    7471
     
    9188{
    9289  this->_size = text._size;
    93   this->_color = text._color;
    9490  this->setAlignment(text.getAlignment());
    95   if (this->_font != NULL)
    96     ResourceManager::getInstance()->unload(this->_font);
    97 
    98   this->_font = (Font*)ResourceManager::getInstance()->copy( text._font ); //!< HACK
     91
     92  this->_font = text._font;
    9993
    10094  this->_text = text._text;
     
    175169{
    176170  Font* newFont = NULL;
    177   Font* oldFont = this->_font;
     171  //  Font* oldFont = this->_font;
    178172
    179173  // load a new Font
     
    183177    if (newFont == NULL)
    184178    {
    185       newFont = Font::getDefaultFont();
     179      //      newFont = &Font::();
    186180      PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str());
    187181    }
    188182  }
     183
    189184  if (newFont == NULL)
    190     newFont = Font::getDefaultFont();
    191   assert(newFont != NULL);
    192 
    193   // unloading the Font if we alrady have one loaded.
    194   this->_font = newFont;
    195   if (oldFont != NULL && oldFont != Font::getDefaultFont())
    196     ResourceManager::getInstance()->unload(oldFont);
    197 
     185    this->_font = Font();
     186  else
     187    this->_font = *newFont;
     188
     189  printf("Font Texture is\n" );
     190  _font.debug();
    198191  this->setupTextWidth();
    199192}
     
    226219    glTranslatef(-this->getSizeX2D()/2, 0, 0);
    227220
    228   // drawing this Text.
    229   // setting the Blending effects
    230   glColor4fv(&this->_color[0]);
    231 
    232 
    233   glActiveTexture(GL_TEXTURE0);
    234 
    235   glEnable(GL_BLEND);
    236   glEnable(GL_TEXTURE_2D);
    237   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    238   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    239 
    240   glBindTexture(GL_TEXTURE_2D, this->_font->getTexture());
     221  this->font().select();
    241222  glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    242223  glRotatef(this->getAbsDir2D(), 0, 0, 1);
     
    247228  for (unsigned int i = 0; i < this->_text.size(); i++)
    248229  {
    249     if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_text[i]]) != NULL))
     230    if(likely((tmpGlyph = this->font().getGlyphArray()[this->_text[i]]) != NULL))
    250231    {
    251232      glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
     
    277258  float width = 0;
    278259  for (unsigned int i = 0; i < this->_text.size(); i++)
    279     if(this->_font->getGlyphArray()[this->_text[i]] != NULL)
    280       width += this->_font->getGlyphArray()[this->_text[i]]->advance;
     260    if(this->_font.getGlyphArray()[this->_text[i]] != NULL)
     261      width += this->_font.getGlyphArray()[this->_text[i]]->advance;
    281262  this->setSizeX2D(width * this->size());
    282263}
     
    288269void Text::debug() const
    289270{
    290   PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font->getName(), this->_text.c_str());
    291   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());
    292 }
    293 
     271  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font.getName(), this->_text.c_str());
     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
  • trunk/src/lib/graphics/text_engine/text.h

    r8619 r8761  
    99#include "element_2d.h"
    1010#include "color.h"
     11#include "font.h"
    1112
    1213#define  TEXT_ALIGN_LEFT             E2D_ALIGN_LEFT
     
    2021
    2122// FORWARD DECLARATION
    22 class Font;
    2323struct SDL_Surface;
    2424
     
    4545    void setFont(const std::string& fontFile, unsigned int renderSize);
    4646    /** @param blending the blending intensity to set (between 0.0 and 1.0) */
    47     inline void setBlending(float blending) { this->_color.a() = blending; };
     47    inline void setBlending(float blending) { this->_font.setTransparency(blending); };
    4848    /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */
    49     void setColor(float r, float g, float b) { this->_color = Color(r, g, b, this->_color.a()); };
    50     void setColor(float r, float g, float b, float a) { this->_color = Color(r, g, b, a); };
    51     void setColor(const Color& color) { this->_color = color; };
     49    void setColor(float r, float g, float b) { this->_font.setDiffuseColor(Color(r, g, b, this->blending())); };
     50    void setColor(float r, float g, float b, float a) { this->_font.setDiffuseColor(Color(r, g, b, a)); };
     51    void setColor(const Color& color) { this->_font.setDiffuseColor(color); };
    5252    void setSize(float size);
    5353
     
    5858
    5959    /** @returns the pointer to the stored Font (not changeable) */
    60     inline const Font* const font() const { return this->_font; };
     60    inline const Font& font() const { return this->_font; };
    6161    /** @returns the Blending Value [0 invisible 1.0 full visible */
    62     inline float blending() const { return this->_color.a(); };
     62    inline float blending() const { return this->_font.diffuseColor().a(); };
    6363    /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */
    64     inline const Color& color() const { return this->_color; };
     64    inline const Color& color() const { return this->_font.diffuseColor(); };
    6565    /** @returns the Size of the Text */
    6666    inline float size() const { return this->_size; };
     
    7676
    7777  private:
    78     Font*             _font;           //!< Font of this text
     78    Font              _font;           //!< Font of this text
    7979
    8080    std::string       _text;           //!< The text to display
    81     Color             _color;          //!< The color of the font.
    8281    float             _size;           //!< The size of the Text.
    8382};
  • trunk/src/lib/graphics/text_engine/text_engine.cc

    r7428 r8761  
    7575//    while (fontList->size() > 0)
    7676    {
    77       Font* font = dynamic_cast<Font*>(fontList->back());
    78       if (likely(font != Font::getDefaultFont()))
    79         ResourceManager::getInstance()->unload(font, RP_GAME);
     77//      Font* font = dynamic_cast<Font*>(fontList->back());
     78      //if (likely(font != Font::getDefaultFont()))
     79      //        ResourceManager::getInstance()->unload(font, RP_GAME);
    8080    }
    8181  }
     
    108108  if (TTF_WasInit())
    109109    {
    110       Font::removeDefaultFont();
     110//      Font::removeDefaultFont();
    111111      TTF_Quit();
    112112    }
Note: See TracChangeset for help on using the changeset viewer.