Index: trunk/src/lib/graphics/importer/material.cc
===================================================================
--- trunk/src/lib/graphics/importer/material.cc	(revision 8751)
+++ trunk/src/lib/graphics/importer/material.cc	(revision 8761)
@@ -317,4 +317,19 @@
 }
 
+/**
+ * @brief Sets the Diffuse map of this Texture by a Texture-pointer.
+ * @param textureDataPointer The Texture-Data-Pointer to load.
+ * @param textureNumber The Texture-Number from 0 to GL_MAX_TEXTURE_UNITS
+ */
+void Material::setDiffuseMap(const TextureDataPointer& textureDataPointer, unsigned int textureNumber)
+{
+  assert(textureNumber < Material::getMaxTextureUnits());
+
+  if (this->textures.size() <= textureNumber)
+    this->textures.resize(textureNumber+1, Texture());
+
+  this->textures[textureNumber] = textureDataPointer;
+}
+
 
 /**
@@ -436,4 +451,28 @@
 }
 
+
+
+void Material::debug() const
+{
+  PRINT(0)("Debug Material: %s\n", this->getName());
+  PRINT(0)("illumModel: %d ; ShiniNess %f\n", this->illumModel, shininess);
+  PRINT(0)("diffuseColor: "); diffuse.debug();
+  PRINT(0)("ambientColor: "); ambient.debug();
+  PRINT(0)("diffuseColor: "); specular.debug();
+  PRINT(0)("Blending Properties: Source: %s, Destination: %s\n", blendFuncToString(sFactor).c_str(), blendFuncToString(tFactor).c_str());
+
+  PRINT(0)("Textures: %d loaded", textures.size());
+  if (!this->textures.empty())
+  {
+    PRINT(0)(" - ID's: ");
+    for (unsigned int i = 0; i < textures.size(); ++i)
+    {
+      PRINT(0)("%d ", textures[i].getTexture());
+    }
+  }
+  PRINT(0)("\n");
+}
+
+
 const GLenum Material::glTextureArbs[] =
 {
Index: trunk/src/lib/graphics/importer/material.h
===================================================================
--- trunk/src/lib/graphics/importer/material.h	(revision 8751)
+++ trunk/src/lib/graphics/importer/material.h	(revision 8761)
@@ -53,4 +53,5 @@
   // MAPPING //
   void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
+  void setDiffuseMap(const TextureDataPointer& texturePointer, unsigned int textureNumber = 0);
   void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
   void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
@@ -67,7 +68,8 @@
   static void addTexturePath(const std::string& pathName);
 
-  const std::string& blendFuncToString(GLenum blendFunc);
-  GLenum stringToBlendFunc(const std::string& blendFuncString);
+  static const std::string& blendFuncToString(GLenum blendFunc);
+  static GLenum stringToBlendFunc(const std::string& blendFuncString);
 
+  void debug() const;
 
 public:
Index: trunk/src/lib/graphics/importer/texture.cc
===================================================================
--- trunk/src/lib/graphics/importer/texture.cc	(revision 8751)
+++ trunk/src/lib/graphics/importer/texture.cc	(revision 8761)
@@ -151,5 +151,5 @@
   this->setClassID(CL_TEXTURE, "Texture");
 
-  this->data = CountPointer<TextureData>(new TextureData());
+  this->data = TextureDataPointer(new TextureData());
 
   this->priority = 0.5;
@@ -173,4 +173,10 @@
   this->data = texture.data;
 
+  return *this;
+}
+
+Texture& Texture::operator=(const TextureDataPointer& textureDataPointer)
+{
+  this->data = textureDataPointer;
   return *this;
 }
Index: trunk/src/lib/graphics/importer/texture.h
===================================================================
--- trunk/src/lib/graphics/importer/texture.h	(revision 8751)
+++ trunk/src/lib/graphics/importer/texture.h	(revision 8761)
@@ -28,4 +28,5 @@
 
   Texture& operator=(const Texture& texture);
+  Texture& operator=(const TextureDataPointer& textureDataPointer);
 
   virtual ~Texture();
@@ -61,5 +62,5 @@
 
 private:
-  CountPointer<TextureData>     data;               //!< The TextureData
+  TextureDataPointer            data;               //!< The TextureData
   GLclampf                      priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
 
Index: trunk/src/lib/graphics/importer/texture_data.h
===================================================================
--- trunk/src/lib/graphics/importer/texture_data.h	(revision 8751)
+++ trunk/src/lib/graphics/importer/texture_data.h	(revision 8761)
@@ -43,3 +43,5 @@
 };
 
+typedef CountPointer<TextureData> TextureDataPointer;
+
 #endif /* _TEXTURE_DATA_H */
Index: trunk/src/lib/graphics/text_engine/font.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/font.cc	(revision 8751)
+++ trunk/src/lib/graphics/text_engine/font.cc	(revision 8761)
@@ -17,5 +17,4 @@
 
 #include "font.h"
-#include "text.h"
 
 #ifdef HAVE_SDL_IMAGE_H
@@ -24,10 +23,17 @@
 #include <SDL/SDL_image.h>
 #endif
+
 #include "default_font.xpm"
 
 #include "debug.h"
-#include "stdlibincl.h"
 #include "compiler.h"
-using namespace std;
+
+
+Font::Font()
+  : data(Font::defaultFontData)
+{
+  this->init();
+
+}
 
 /**
@@ -37,15 +43,12 @@
  */
 Font::Font(const std::string& fontFile, unsigned int renderSize)
-  : data(new FontData())
+  : data(Font::defaultFontData)
 {
   this->init();
 
-
-  this->data->renderSize = renderSize;
-  this->setStyle("c");
-
   if (!fontFile.empty())
-    this->loadFontFromTTF(fontFile);
-}
+    this->loadFontFromTTF(fontFile, renderSize);
+}
+
 
 /**
@@ -54,7 +57,8 @@
  */
 Font::Font(const std::string& imageFile)
-  : data(new FontData())
+  : data(Font::defaultFontData)
 {
   this->init();
+
   this->setName(imageFile);
   //  this->setSize(fontSize);
@@ -78,5 +82,5 @@
  */
 Font::Font(char** xpmArray)
-  : data(new FontData())
+  : data(Font::defaultFontData)
 {
   this->init();
@@ -92,5 +96,5 @@
   }
   else
-    PRINTF(1)("loading from surface failed: %s\n", IMG_GetError());
+    PRINTF(1)("Loading from XPM-array failed: %s\n", IMG_GetError());
 }
 
@@ -105,4 +109,13 @@
 { }
 
+Font& Font::operator=(const Font& font)
+{
+  Material::operator=(font);
+  this->data = font.data;
+
+  return *this;
+};
+
+
 /**
  * @brief initializes a Font (with default values)
@@ -110,7 +123,28 @@
 void Font::init()
 {
+  this->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
   this->setClassID(CL_FONT, "Font");
-}
-
+  if (Font::defaultFontData.get() == NULL)
+  {
+     Font::initDefaultFont();
+    this->data = Font::defaultFontData;
+  }
+}
+
+FontDataPointer Font::defaultFontData(NULL);
+
+/**
+ * @brief initializes the default font
+ */
+void Font::initDefaultFont()
+{
+  // temporarily create a Font.
+  Font::defaultFontData = FontDataPointer(new FontData);
+  // apply the Data.
+  printf("before: %p\n", defaultFontData.get());
+  Font::defaultFontData = Font(font_xpm).data;
+  printf("after: %p\n", defaultFontData.get());
+}
 
 /**
@@ -119,25 +153,27 @@
  * @returns true if loaded, false if something went wrong, or if a font was loaded before.
  */
-bool Font::loadFontFromTTF(const std::string& fontFile)
-{
-  // checking for existent Font.
-  if (this->data->fontTTF != NULL)
-  {
-    TTF_CloseFont(this->data->fontTTF);
-    this->data->fontTTF = NULL;
-  }
-
+bool Font::loadFontFromTTF(const std::string& fontFile, unsigned int renderSize)
+{
+  this->data = FontDataPointer (new FontData());
 
   this->setName(fontFile);
-  this->data->fontTTF = TTF_OpenFont(this->getName(), this->data->renderSize);
+  this->data->fontTTF = TTF_OpenFont(fontFile.c_str(), renderSize);
+  this->data->renderSize = renderSize;
 
   if(this->data->fontTTF != NULL)
   {
-    this->createFastTexture();
-    return (this->getTexture() != 0);
+    this->setStyle("c");
+    if (this->createFastTexture())
+      return true;
+    else
+    {
+      this->data = Font::defaultFontData;
+      return false;
+    }
   }
   else
   {
     PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError());
+    this->data = Font::defaultFontData;
     return false;
   }
@@ -151,20 +187,22 @@
 bool Font::loadFontFromSDL_Surface(SDL_Surface* surface)
 {
-  // loading to a texture.
   if(surface == NULL)
     return false;
 
-  if (this->data->fontTTF != NULL)
-  {
-    TTF_CloseFont(this->data->fontTTF);
-    this->data->fontTTF = NULL;
-  }
+  this->data = FontDataPointer (new FontData());
+  // loading to a texture.
+
   bool hasAlpha;
-  SDL_Surface* newSurf = this->prepareSurface(surface, hasAlpha);
+  SDL_Surface* newSurf = Texture::prepareSurface(surface, hasAlpha);
   if (newSurf != NULL)
   {
-    this->setSurface(newSurf);
-    this->setAlpha(hasAlpha);
+    this->data->texData->setSurface(newSurf);
+    this->data->texData->setAlpha(hasAlpha);
     this->setTexture(Texture::loadTexToGL(newSurf));
+  }
+  else
+  {
+    this->data = Font::defaultFontData;
+    return false;
   }
 
@@ -223,6 +261,4 @@
   //    PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n");
 }
-
-Font* Font::defaultFont = NULL;
 
 /**
@@ -283,23 +319,4 @@
   SDL_SaveBMP(tmpSurf, fileName.c_str());
   SDL_FreeSurface(tmpSurf);
-}
-
-/**
- * @brief initializes the default font
- */
-void Font::initDefaultFont()
-{
-  if (Font::defaultFont == NULL)
-    Font::defaultFont = new Font(font_xpm);
-}
-
-/**
- * @brief deletes the default font
- */
-void Font::removeDefaultFont()
-{
-  if (Font::defaultFont != NULL)
-    delete Font::defaultFont;
-  Font::defaultFont = NULL;
 }
 
@@ -473,9 +490,24 @@
 //       sprintf( outName, "%s-glyphs.bmp", this->getName());
 //       SDL_SaveBMP(tmpSurf, outName);
-  this->setAlpha(true);
-  if (this->setSurface(tmpSurf))
-    (this->setTexture(Texture::loadTexToGL(tmpSurf)));
+  this->data->texData->setAlpha(true);
+  if (this->data->texData->setSurface(tmpSurf))
+    this->setTexture(Texture::loadTexToGL(tmpSurf));
   return true;
 }
+
+/**
+ * @brief the Internal implementation of setting up the Texture.
+ * @param texture the Texture to load.
+ * @returns true on success, false otherwise.
+ */
+bool Font::setTexture(GLuint texture)
+{
+  bool retVal = this->data->texData->setTexture(texture);
+  this->setDiffuseMap(data->texData, 0);
+  printf("this->texture %d\n", texture);
+  //printf(this->getT)
+  this->debug();
+  return retVal;
+};
 
 /**
@@ -569,6 +601,9 @@
  * @brief a simple function to get some interesting information about this class
  */
-void Font::debug()
-{
+void Font::debug() const
+{
+  Material::debug();
+
+  PRINT(0)("TEST %p and %p\n", this->data.get(), this->data->texData.get());
   // print the loaded font's style
   int style = TTF_STYLE_NORMAL;
Index: trunk/src/lib/graphics/text_engine/font.h
===================================================================
--- trunk/src/lib/graphics/text_engine/font.h	(revision 8751)
+++ trunk/src/lib/graphics/text_engine/font.h	(revision 8761)
@@ -11,5 +11,5 @@
 #define _FONT_H
 
-#include "texture.h"
+#include "material.h"
 
 #include "font_data.h"
@@ -17,16 +17,21 @@
 
 //! A class to handle a Font of a certain ttf-File/image-file, Size.
-class Font : public Texture
+class Font : public Material /* TODO Material it should be */
 {
 
 public:
-  Font(const std::string& fontFile,
-       unsigned int renderSize);
+  Font();
+  Font(const std::string& fontFile, unsigned int renderSize);
   Font(const std::string& imageFile);
   Font(char** xpmArray);
   virtual ~Font();
 
-  //  font
-  bool loadFontFromTTF(const std::string& fontFile);
+  Font& operator=(const Font& font);
+  /** @brief compare two fonts @param font the comparator, @returns true if they match */
+  bool operator==(const Font& font) const { return this->data == font.data; };
+
+
+  /// LOADING new Fonts
+  bool loadFontFromTTF(const std::string& fontFile, unsigned int renderSize);
   bool loadFontFromSDL_Surface(SDL_Surface* surface);
 
@@ -42,27 +47,24 @@
   int getMaxDescent() const;
 
-  /** @returns the default Font */
-  inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; };
+  void createAsciiImage(const std::string& fileName, unsigned int size) const;
 
-  void createAsciiImage(const std::string& fileName, unsigned int size) const;
+  void debug() const;
+
+private:
+  void init();
+  void initGlyphs(Uint16 from, Uint16 count);
+  bool getGlyphMetrics(Glyph* glyph, Uint16 character);
   static void initDefaultFont();
-  static void removeDefaultFont();
+
+  int findOptimalFastTextureSize();
+  bool createFastTexture();
+
+  bool setTexture(GLuint texture);
 
 
 private:
-  void init();
-  bool getGlyphMetrics(Glyph* glyph, Uint16 character);
+  static FontDataPointer    defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
 
-  bool createFastTexture();
-
-  void initGlyphs(Uint16 from, Uint16 count);
-  int findOptimalFastTextureSize();
-
-  void debug();
-
-private:
-  static Font*  defaultFont;         //!< a default font, that is used, if other fonts were unable to be loaded.
-
-  fontDataPointer data;
+  FontDataPointer           data;                //!< A Data-Pointer to a Font.
 };
 
Index: trunk/src/lib/graphics/text_engine/font_data.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/font_data.cc	(revision 8751)
+++ trunk/src/lib/graphics/text_engine/font_data.cc	(revision 8761)
@@ -27,7 +27,11 @@
  */
 FontData::FontData()
+  : texData(new TextureData)
 {
+  printf("CREATE FONT_DATA\n");
   this->fontTTF = NULL;
   this->glyphArray = NULL;
+  this->renderStyle = TTF_STYLE_NORMAL;
+  this->renderSize = FONT_DEFAULT_RENDER_SIZE;
 }
 
Index: trunk/src/lib/graphics/text_engine/font_data.h
===================================================================
--- trunk/src/lib/graphics/text_engine/font_data.h	(revision 8751)
+++ trunk/src/lib/graphics/text_engine/font_data.h	(revision 8761)
@@ -48,9 +48,8 @@
 
 
-class FontData : public TextureData
+class FontData
 {
   friend class Font;
 public:
-  FontData();
   ~FontData();
 
@@ -65,4 +64,7 @@
 
 private:
+  FontData();
+
+private:
   TTF_Font*     fontTTF;             //!< The font we use for this.
   int           renderStyle;         //!< The Renderstyle
@@ -70,7 +72,9 @@
 
   Glyph**       glyphArray;          //!< An Array of all the Glyphs stored in the Array of Glyphs.
+
+  TextureDataPointer   texData;
 };
 
-typedef CountPointer<FontData> fontDataPointer;
+typedef CountPointer<FontData> FontDataPointer;
 
 #endif /* _FONT_DATA_H */
Index: trunk/src/lib/graphics/text_engine/limited_width_text.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/limited_width_text.cc	(revision 8751)
+++ trunk/src/lib/graphics/text_engine/limited_width_text.cc	(revision 8761)
@@ -76,10 +76,12 @@
   glActiveTexture(GL_TEXTURE0);
 
-  glEnable(GL_BLEND);
-  glEnable(GL_TEXTURE_2D);
-  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
+//   glEnable(GL_BLEND);
+//   glEnable(GL_TEXTURE_2D);
+//   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+//   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
+//
+//   glBindTexture(GL_TEXTURE_2D, this->font().getTexture());
+  this->font().select();
 
-  glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
   glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
@@ -90,5 +92,5 @@
   for (unsigned int i = 0; i < this->_dotedText.size(); i++)
   {
-    if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_dotedText[i]]) != NULL))
+    if(likely((tmpGlyph = this->font().getGlyphArray()[this->_dotedText[i]]) != NULL))
     {
       glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
@@ -118,5 +120,5 @@
 void LimitedWidthText::setupTextWidth()
 {
-  float dotsSize = this->font()->getGlyphArray()[46]->advance * 3.0;
+  float dotsSize = this->font().getGlyphArray()[46]->advance * 3.0;
 
   float width = 0.0f;
@@ -134,11 +136,11 @@
           this->_dotedText = this->text().substr(0, i) + "...";
           if (i > 0)
-            width -= this->font()->getGlyphArray()[this->text()[i-1]]->advance;
+            width -= this->font().getGlyphArray()[this->text()[i-1]]->advance;
           width += dotsSize;
           break;
         }
         // Advance the Text.
-        if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
-          width += this->font()->getGlyphArray()[this->text()[i]]->advance;
+        if(this->font().getGlyphArray()[this->text()[i]] != NULL)
+          width += this->font().getGlyphArray()[this->text()[i]]->advance;
       }
       break;
@@ -152,11 +154,11 @@
           this->_dotedText = std::string("...") + this->text().substr(i);
           if (i + 1 < (int)text().size() )
-            width -= this->font()->getGlyphArray()[this->text()[i+1]]->advance;
+            width -= this->font().getGlyphArray()[this->text()[i+1]]->advance;
           width += dotsSize;
           break;
         }
         // Advance the Text.
-        if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
-          width += this->font()->getGlyphArray()[this->text()[i]]->advance;
+        if(this->font().getGlyphArray()[this->text()[i]] != NULL)
+          width += this->font().getGlyphArray()[this->text()[i]]->advance;
       }
       break;
Index: trunk/src/lib/graphics/text_engine/multi_line_text.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/multi_line_text.cc	(revision 8751)
+++ trunk/src/lib/graphics/text_engine/multi_line_text.cc	(revision 8761)
@@ -76,5 +76,5 @@
   glActiveTexture(GL_TEXTURE0);
 
-  glColor4fv(&this->color()[0]);
+/*  glColor4fv(&this->color()[0]);
   glEnable(GL_BLEND);
   glEnable(GL_TEXTURE_2D);
@@ -82,5 +82,6 @@
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
 
-  glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
+  glBindTexture(GL_TEXTURE_2D, this->font().getTexture());*/
+  this->font().select();
   glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
@@ -99,8 +100,8 @@
       ++lineNumber;
       posX = 0.0f;
-      posY += this->lineSpacing + this->size(); //this->font()->getMaxHeight();
+      posY += this->lineSpacing + this->size(); //this->font().getMaxHeight();
     }
 
-    if(likely((tmpGlyph = this->font()->getGlyphArray()[this->text()[i]]) != NULL))
+    if(likely((tmpGlyph = this->font().getGlyphArray()[this->text()[i]]) != NULL))
     {
       glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
@@ -141,5 +142,5 @@
       {
         this->lineEnds.push_back( i -1 );
-        width = this->font()->getGlyphArray()[this->text()[i-1]]->advance;
+        width = this->font().getGlyphArray()[this->text()[i-1]]->advance;
       }
       else
@@ -148,9 +149,9 @@
 
     // Advance the Text.
-    if(this->font()->getGlyphArray()[this->text()[i]] != NULL)
-      width += this->font()->getGlyphArray()[this->text()[i]]->advance;
+    if(this->font().getGlyphArray()[this->text()[i]] != NULL)
+      width += this->font().getGlyphArray()[this->text()[i]]->advance;
   }
   this->lineCount = lineEnds.size() + 1;
-  this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font()->getMaxHeight()));
+  this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font().getMaxHeight()));
 }
 
Index: trunk/src/lib/graphics/text_engine/text.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/text.cc	(revision 8751)
+++ trunk/src/lib/graphics/text_engine/text.cc	(revision 8761)
@@ -28,22 +28,20 @@
  */
 Text::Text(const std::string& fontFile, unsigned int textSize)
+    : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
 {
   this->setClassID(CL_TEXT, "Text");
 
   // initialize this Text
-  this->_font = NULL;
   this->_size = textSize;
   this->setSizeY2D(textSize);
-  this->_color = TEXT_DEFAULT_COLOR;
+  this->setColor(TEXT_DEFAULT_COLOR);
 
   this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
-
-  this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
 }
 
 Text::Text(const Text& text)
+    : _font()
 {
   this->setClassID(CL_TEXT, "Text");
-  this->_font = NULL;
 
   *this = text;
@@ -56,6 +54,6 @@
 Text::~Text()
 {
-  if (this->_font != NULL && this->_font != Font::getDefaultFont())
-    ResourceManager::getInstance()->unload(this->_font);
+  /*  if (this->_font != NULL && this->_font != Font::getDefaultFont())
+      ResourceManager::getInstance()->unload(this->_font);*/
 }
 
@@ -69,6 +67,5 @@
   return (this->_text == text._text &&
           this->_size == text._size &&
-          this->_font == text._font &&
-          this->_color == text._color);
+          this->_font == text._font );
 }
 
@@ -91,10 +88,7 @@
 {
   this->_size = text._size;
-  this->_color = text._color;
   this->setAlignment(text.getAlignment());
-  if (this->_font != NULL)
-    ResourceManager::getInstance()->unload(this->_font);
-
-  this->_font = (Font*)ResourceManager::getInstance()->copy( text._font ); //!< HACK
+
+  this->_font = text._font;
 
   this->_text = text._text;
@@ -175,5 +169,5 @@
 {
   Font* newFont = NULL;
-  Font* oldFont = this->_font;
+  //  Font* oldFont = this->_font;
 
   // load a new Font
@@ -183,17 +177,16 @@
     if (newFont == NULL)
     {
-      newFont = Font::getDefaultFont();
+      //      newFont = &Font::();
       PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str());
     }
   }
+
   if (newFont == NULL)
-    newFont = Font::getDefaultFont();
-  assert(newFont != NULL);
-
-  // unloading the Font if we alrady have one loaded.
-  this->_font = newFont;
-  if (oldFont != NULL && oldFont != Font::getDefaultFont())
-    ResourceManager::getInstance()->unload(oldFont);
-
+    this->_font = Font();
+  else
+    this->_font = *newFont;
+
+  printf("Font Texture is\n" );
+  _font.debug();
   this->setupTextWidth();
 }
@@ -226,17 +219,5 @@
     glTranslatef(-this->getSizeX2D()/2, 0, 0);
 
-  // drawing this Text.
-  // setting the Blending effects
-  glColor4fv(&this->_color[0]);
-
-
-  glActiveTexture(GL_TEXTURE0);
-
-  glEnable(GL_BLEND);
-  glEnable(GL_TEXTURE_2D);
-  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
-
-  glBindTexture(GL_TEXTURE_2D, this->_font->getTexture());
+  this->font().select();
   glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
@@ -247,5 +228,5 @@
   for (unsigned int i = 0; i < this->_text.size(); i++)
   {
-    if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_text[i]]) != NULL))
+    if(likely((tmpGlyph = this->font().getGlyphArray()[this->_text[i]]) != NULL))
     {
       glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
@@ -277,6 +258,6 @@
   float width = 0;
   for (unsigned int i = 0; i < this->_text.size(); i++)
-    if(this->_font->getGlyphArray()[this->_text[i]] != NULL)
-      width += this->_font->getGlyphArray()[this->_text[i]]->advance;
+    if(this->_font.getGlyphArray()[this->_text[i]] != NULL)
+      width += this->_font.getGlyphArray()[this->_text[i]]->advance;
   this->setSizeX2D(width * this->size());
 }
@@ -288,6 +269,6 @@
 void Text::debug() const
 {
-  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font->getName(), this->_text.c_str());
-  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());
-}
-
+  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->_font.getName(), this->_text.c_str());
+  //  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());
+}
+
Index: trunk/src/lib/graphics/text_engine/text.h
===================================================================
--- trunk/src/lib/graphics/text_engine/text.h	(revision 8751)
+++ trunk/src/lib/graphics/text_engine/text.h	(revision 8761)
@@ -9,4 +9,5 @@
 #include "element_2d.h"
 #include "color.h"
+#include "font.h"
 
 #define  TEXT_ALIGN_LEFT             E2D_ALIGN_LEFT
@@ -20,5 +21,4 @@
 
 // FORWARD DECLARATION
-class Font;
 struct SDL_Surface;
 
@@ -45,9 +45,9 @@
     void setFont(const std::string& fontFile, unsigned int renderSize);
     /** @param blending the blending intensity to set (between 0.0 and 1.0) */
-    inline void setBlending(float blending) { this->_color.a() = blending; };
+    inline void setBlending(float blending) { this->_font.setTransparency(blending); };
     /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */
-    void setColor(float r, float g, float b) { this->_color = Color(r, g, b, this->_color.a()); };
-    void setColor(float r, float g, float b, float a) { this->_color = Color(r, g, b, a); };
-    void setColor(const Color& color) { this->_color = color; };
+    void setColor(float r, float g, float b) { this->_font.setDiffuseColor(Color(r, g, b, this->blending())); };
+    void setColor(float r, float g, float b, float a) { this->_font.setDiffuseColor(Color(r, g, b, a)); };
+    void setColor(const Color& color) { this->_font.setDiffuseColor(color); };
     void setSize(float size);
 
@@ -58,9 +58,9 @@
 
     /** @returns the pointer to the stored Font (not changeable) */
-    inline const Font* const font() const { return this->_font; };
+    inline const Font& font() const { return this->_font; };
     /** @returns the Blending Value [0 invisible 1.0 full visible */
-    inline float blending() const { return this->_color.a(); };
+    inline float blending() const { return this->_font.diffuseColor().a(); };
     /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */
-    inline const Color& color() const { return this->_color; };
+    inline const Color& color() const { return this->_font.diffuseColor(); };
     /** @returns the Size of the Text */
     inline float size() const { return this->_size; };
@@ -76,8 +76,7 @@
 
   private:
-    Font*             _font;           //!< Font of this text
+    Font              _font;           //!< Font of this text
 
     std::string       _text;           //!< The text to display
-    Color             _color;          //!< The color of the font.
     float             _size;           //!< The size of the Text.
 };
Index: trunk/src/lib/graphics/text_engine/text_engine.cc
===================================================================
--- trunk/src/lib/graphics/text_engine/text_engine.cc	(revision 8751)
+++ trunk/src/lib/graphics/text_engine/text_engine.cc	(revision 8761)
@@ -75,7 +75,7 @@
 //    while (fontList->size() > 0)
     {
-      Font* font = dynamic_cast<Font*>(fontList->back());
-      if (likely(font != Font::getDefaultFont()))
-        ResourceManager::getInstance()->unload(font, RP_GAME);
+//      Font* font = dynamic_cast<Font*>(fontList->back());
+      //if (likely(font != Font::getDefaultFont()))
+      //        ResourceManager::getInstance()->unload(font, RP_GAME);
     }
   }
@@ -108,5 +108,5 @@
   if (TTF_WasInit())
     {
-      Font::removeDefaultFont();
+//      Font::removeDefaultFont();
       TTF_Quit();
     }
Index: trunk/src/lib/util/count_pointer.h
===================================================================
--- trunk/src/lib/util/count_pointer.h	(revision 8751)
+++ trunk/src/lib/util/count_pointer.h	(revision 8761)
@@ -21,4 +21,5 @@
         return *this;
     }
+    bool operator==(const CountPointer& r) const { return this->itsCounter->ptr == r.itsCounter->ptr; };
     X& operator*()  const { return *itsCounter->ptr; }
     X* operator->() const { return itsCounter->ptr; }
