Index: trunk/src/lib/graphics/text_engine.cc
===================================================================
--- trunk/src/lib/graphics/text_engine.cc	(revision 5335)
+++ trunk/src/lib/graphics/text_engine.cc	(revision 5336)
@@ -29,4 +29,12 @@
 #include <stdio.h>
 #include <string.h>
+
+#ifdef HAVE_SDL_IMAGE_H
+#include <SDL_image.h>
+#else
+#include <SDL/SDL_image.h>
+#endif
+#include "font.xpm"
+
 
 #include "graphics_engine.h"
@@ -333,5 +341,5 @@
   w = powerOfTwo(surface->w);
   h = powerOfTwo(surface->h);
-  if (texCoord)
+  if (texCoord != NULL)
     {
       texCoord->minU = 0.0f;
@@ -391,5 +399,5 @@
                GL_UNSIGNED_BYTE,
                image->pixels);
-  SDL_FreeSurface(image); /* No longer needed */
+  SDL_FreeSurface(image); /* No longer needed the data */
 
   return texture;
@@ -416,11 +424,8 @@
 ////////////
 /**
- *  constructs a Font
+ * constructs a Font
  * @param fontFile the File to load the font from
  * @param fontSize the Size of the Font in Pixels
- * @param r Red value of the Font.
- * @param g Green value of the Font.
- * @param b Blue value of the Font.
-*/
+ */
 Font::Font(const char* fontFile, unsigned int fontSize)
 {
@@ -433,5 +438,6 @@
   this->setSize(fontSize);
 
-  this->loadFont(fontFile);
+  if (fontFile != NULL)
+    this->loadFont(fontFile);
 
   this->setStyle("c");//TTF_STYLE_NORMAL);
@@ -439,18 +445,45 @@
   this->fastTextureID = this->createFastTexture();
 }
+
+/**
+ * constructs a Font
+ * @param fontFile the File to load the font from
+ * @param fontSize the Size of the Font in Pixels
+ */
+Font::Font(char** xpmArray)
+{
+  this->setClassID(CL_FONT, "Font");
+  // setting default values.
+  this->font = NULL;
+  this->glyphArray = NULL;
+  this->fastTextureID = 0;
+
+//  this->setSize(fontSize);
+
+  if (xpmArray != NULL)
+    this->loadFontFromXPMArray(xpmArray);
+}
+
 
 /**
  * destructs a font
  * this releases the memory a font uses to be opened.
-*/
+ * deletes the glLists, and the TTF-handler, if present.
+ */
 Font::~Font()
 {
-  // deleting the List of all Texts
+  // deleting the Lists of all Texts
 
   // deleting all Glyphs
-  if (this->glyphArray)
+  if (this->glyphArray != NULL)
     {
       for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
-        delete this->glyphArray[i];
+      {
+        if (this->glyphArray[i] != NULL)
+        {
+          glDeleteLists(this->glyphArray[i]->displayList, 1);
+          delete this->glyphArray[i];
+        }
+      }
       delete[] this->glyphArray;
     }
@@ -461,6 +494,7 @@
 }
 
-/**
- *  sets The Font.
+
+/**
+ * sets The Font.
  * @param fontFile The file containing the font.
  * @returns true if loaded, false if something went wrong, or if a font was loaded before.
@@ -489,4 +523,56 @@
 
 /**
+ * loads a font From an XPM-array.
+ * @param xpmArray the array of the XPM to load the font from.
+ */
+bool Font::loadFontFromXPMArray(char** xpmArray)
+{
+  if (xpmArray == NULL)
+    return false;
+
+  // loading to a texture.
+  SDL_Surface* image = IMG_ReadXPMFromArray(xpmArray);
+  if(image == NULL)
+  {
+    PRINTF(1)("loading from XPM-array failed: %s\n", IMG_GetError());
+    return false;
+  }
+  TexCoord texCoord;
+  this->fastTextureID = Text::loadTexture(image, &texCoord);
+
+  // initializing the Glyphs.
+  if (!this->glyphArray)
+  {
+    float cx,cy;
+    this->glyphArray = new Glyph*[FONT_HIGHEST_KNOWN_CHAR];
+    for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
+    {
+      this->glyphArray[i] = new Glyph;
+      this->glyphArray[i]->displayList = glGenLists(1);
+      cx=(float)(i%16)/16.0f;                  // X Position Of Current Character
+      cy=(float)(i/16)/16.0f;                  // Y Position Of Current Character
+      glNewList(this->glyphArray[i]->displayList, GL_COMPILE); // Start Building A List
+       glBegin(GL_QUADS);                           // Use A Quad For Each Character
+        glTexCoord2f(cx,1.0f-cy-0.0625f);            // Texture Coord (Bottom Left)
+        glVertex2d(0,16);                            // Vertex Coord (Bottom Left)
+        glTexCoord2f(cx+0.0625f,1.0f-cy-0.0625f);    // Texture Coord (Bottom Right)
+        glVertex2i(16,16);                           // Vertex Coord (Bottom Right)
+        glTexCoord2f(cx+0.0625f,1.0f-cy-0.001f);     // Texture Coord (Top Right)
+        glVertex2i(16,0);                            // Vertex Coord (Top Right)
+        glTexCoord2f(cx,1.0f-cy-0.001f);             // Texture Coord (Top Left)
+        glVertex2i(0,0);                             // Vertex Coord (Top Left)
+       glEnd();                                     // Done Building Our Quad (Character)
+//       glTranslated(12,0,0);                        // Move To The Right Of The Character
+      glEndList();                                 // Done Building The Display List
+
+      this->glyphArray[i]->width = 12;
+    }
+  }
+  SDL_FreeSurface(image);
+  return true;
+}
+
+
+/**
  *  sets a specific renderStyle
  * @param renderStyle the Style to render: a char-array containing:
@@ -519,4 +605,25 @@
   this->fontSize = fontSize;
 }
+
+Font* Font::defaultFont = NULL;
+/**
+ * initializes the default font
+ */
+void Font::initDefaultFont()
+{
+  if (Font::defaultFont == NULL)
+    Font::defaultFont = new Font(font_xpm);
+}
+
+/**
+ * deletes the default font
+ */
+void Font::removeDefaultFont()
+{
+  if (Font::defaultFont != NULL)
+    delete Font::defaultFont;
+  Font::defaultFont = NULL;
+}
+
 
 /**
@@ -582,4 +689,7 @@
 }
 
+/**
+ * creates a Fast-Texture of this Font
+ */
 GLuint Font::createFastTexture()
 {
@@ -878,4 +988,5 @@
 
       TextEngine::checkVersion();
+      Font::initDefaultFont();
     }
   else
@@ -890,4 +1001,5 @@
   if (TTF_WasInit())
     {
+      Font::removeDefaultFont();
       TTF_Quit();
     }
Index: trunk/src/lib/graphics/text_engine.h
===================================================================
--- trunk/src/lib/graphics/text_engine.h	(revision 5335)
+++ trunk/src/lib/graphics/text_engine.h	(revision 5336)
@@ -21,7 +21,7 @@
 
 #ifdef HAVE_SDL_TTF_H
-#include "SDL_ttf.h"
+#include <SDL_ttf.h>
 #else
-#include "SDL/SDL_ttf.h"
+#include <SDL/SDL_ttf.h>
 #endif
 
@@ -46,5 +46,5 @@
 #define FONT_NUM_COLORS              256                        //!< number of colors.
 
-#define FONT_HIGHEST_KNOWN_CHAR      128                        //!< The highest character known to the textEngine.
+#define FONT_HIGHEST_KNOWN_CHAR      256                        //!< The highest character known to the textEngine.
 
 #define TEXT_DEFAULT_ALIGNMENT       TEXT_ALIGN_CENTER          //!< default alignment
@@ -129,10 +129,12 @@
   void debug() const;
 
+  // helpers.
+  static GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord);
+  static int powerOfTwo(int input);
+
  private:
    Text(Font* font = NULL, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC);
    void setFont(Font* font);
 
-   static GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord);
-   static int powerOfTwo(int input);
 
  private:
@@ -163,4 +165,5 @@
   Font(const char* fontFile,
        unsigned int fontSize = FONT_DEFAULT_SIZE);
+  Font(char** xpmArray);
 
   virtual ~Font();
@@ -168,4 +171,6 @@
   // font
   bool loadFont(const char* fontFile);
+  bool loadFontFromXPMArray(char** xpmArray);
+
   void setSize(unsigned int fontSize);
   void setStyle(const char* renderStyle);
@@ -175,4 +180,9 @@
   /** @returns the texture to the fast-texture */
   inline GLuint getFastTextureID() const { return fastTextureID; };
+  /** @returns the default Font */
+  inline static Font* getDefaultFont() { return Font::defaultFont; };
+
+  static void initDefaultFont();
+  static void removeDefaultFont();
 
  private:
@@ -190,7 +200,5 @@
 
  private:
-  // general purpose
-  GLdouble      projMat[16];         //!< The Projection Matrix
-
+  static Font*  defaultFont;         //!< a default font, that is used, if other fonts were unable to be loaded.
   // information about the Font
   TTF_Font*     font;                //!< The font we use for this.
