Index: /branches/fontdata/src/lib/graphics/text_engine/font.cc
===================================================================
--- /branches/fontdata/src/lib/graphics/text_engine/font.cc	(revision 8753)
+++ /branches/fontdata/src/lib/graphics/text_engine/font.cc	(revision 8754)
@@ -29,4 +29,11 @@
 #include "compiler.h"
 
+
+Font::Font()
+  : data(Font::defaultFontData)
+{
+  this->init();
+
+}
 
 /**
@@ -149,4 +156,5 @@
 bool Font::loadFontFromSDL_Surface(SDL_Surface* surface)
 {
+  this->data = FontDataPointer (new FontData());
   // loading to a texture.
   if(surface == NULL)
@@ -286,4 +294,5 @@
 FontDataPointer Font::initDefaultFont()
 {
+  Font::defaultFontData = FontDataPointer(new FontData);
   return Font(font_xpm).data;
 }
Index: /branches/fontdata/src/lib/graphics/text_engine/font.h
===================================================================
--- /branches/fontdata/src/lib/graphics/text_engine/font.h	(revision 8753)
+++ /branches/fontdata/src/lib/graphics/text_engine/font.h	(revision 8754)
@@ -21,4 +21,5 @@
 
 public:
+  Font();
   Font(const std::string& fontFile,
        unsigned int renderSize);
@@ -26,4 +27,7 @@
   Font(char** xpmArray);
   virtual ~Font();
+
+  Font& operator=(const Font& font) { this->data = font.data; return *this; };
+  bool operator==(const Font& font) const { return this->data == font.data; };
 
   //  font
Index: /branches/fontdata/src/lib/graphics/text_engine/limited_width_text.cc
===================================================================
--- /branches/fontdata/src/lib/graphics/text_engine/limited_width_text.cc	(revision 8753)
+++ /branches/fontdata/src/lib/graphics/text_engine/limited_width_text.cc	(revision 8754)
@@ -81,5 +81,5 @@
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
 
-  glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
+  glBindTexture(GL_TEXTURE_2D, this->font().getTexture());
   glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
@@ -90,5 +90,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 +118,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 +134,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 +152,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: /branches/fontdata/src/lib/graphics/text_engine/multi_line_text.cc
===================================================================
--- /branches/fontdata/src/lib/graphics/text_engine/multi_line_text.cc	(revision 8753)
+++ /branches/fontdata/src/lib/graphics/text_engine/multi_line_text.cc	(revision 8754)
@@ -82,5 +82,5 @@
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
 
-  glBindTexture(GL_TEXTURE_2D, this->font()->getTexture());
+  glBindTexture(GL_TEXTURE_2D, this->font().getTexture());
   glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
@@ -99,8 +99,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 +141,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 +148,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: /branches/fontdata/src/lib/graphics/text_engine/text.cc
===================================================================
--- /branches/fontdata/src/lib/graphics/text_engine/text.cc	(revision 8753)
+++ /branches/fontdata/src/lib/graphics/text_engine/text.cc	(revision 8754)
@@ -28,4 +28,5 @@
  */
 Text::Text(const std::string& fontFile, unsigned int textSize)
+  : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
 {
   this->setClassID(CL_TEXT, "Text");
@@ -38,12 +39,10 @@
 
   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;
@@ -93,8 +92,6 @@
   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;
@@ -192,5 +189,5 @@
 
   // unloading the Font if we alrady have one loaded.
-  this->_font = newFont;
+  this->_font = *newFont;
 //   if (oldFont != NULL && oldFont != Font::getDefaultFont())
 //     ResourceManager::getInstance()->unload(oldFont);
@@ -238,5 +235,5 @@
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
 
-  glBindTexture(GL_TEXTURE_2D, this->_font->getTexture());
+  glBindTexture(GL_TEXTURE_2D, this->_font.getTexture());
   glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
   glRotatef(this->getAbsDir2D(), 0, 0, 1);
@@ -247,5 +244,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 +274,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,5 +285,5 @@
 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)("=== 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: /branches/fontdata/src/lib/graphics/text_engine/text.h
===================================================================
--- /branches/fontdata/src/lib/graphics/text_engine/text.h	(revision 8753)
+++ /branches/fontdata/src/lib/graphics/text_engine/text.h	(revision 8754)
@@ -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;
 
@@ -58,5 +58,5 @@
 
     /** @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(); };
@@ -76,5 +76,5 @@
 
   private:
-    Font*             _font;           //!< Font of this text
+    Font              _font;           //!< Font of this text
 
     std::string       _text;           //!< The text to display
Index: /branches/fontdata/src/lib/graphics/text_engine/text_engine.cc
===================================================================
--- /branches/fontdata/src/lib/graphics/text_engine/text_engine.cc	(revision 8753)
+++ /branches/fontdata/src/lib/graphics/text_engine/text_engine.cc	(revision 8754)
@@ -75,5 +75,5 @@
 //    while (fontList->size() > 0)
     {
-      Font* font = dynamic_cast<Font*>(fontList->back());
+//      Font* font = dynamic_cast<Font*>(fontList->back());
       //if (likely(font != Font::getDefaultFont()))
       //        ResourceManager::getInstance()->unload(font, RP_GAME);
Index: /branches/fontdata/src/lib/util/count_pointer.h
===================================================================
--- /branches/fontdata/src/lib/util/count_pointer.h	(revision 8753)
+++ /branches/fontdata/src/lib/util/count_pointer.h	(revision 8754)
@@ -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; }
