Index: /orxonox/trunk/src/lib/graphics/text_engine.cc
===================================================================
--- /orxonox/trunk/src/lib/graphics/text_engine.cc	(revision 3842)
+++ /orxonox/trunk/src/lib/graphics/text_engine.cc	(revision 3843)
@@ -57,4 +57,5 @@
   this->font = font;
   this->text = NULL;
+  this->alignment = TEXT_DEFAULT_ALIGNMENT;
   this->texture = 0;
   this->blending = 1.0f;
@@ -101,4 +102,23 @@
   this->text = new char[strlen(text)+1];
   strcpy(this->text, text);
+
+
+  // setting up the Text-Width if DYNAMIC
+  if (this->type == TEXT_DYNAMIC)
+    {
+      Glyph** glyphArray = this->font->getGlyphArray();
+
+      int width = 0;
+      char* tmpText = this->text;
+      while (*tmpText != '\0')
+	{
+	  if(glyphArray[*tmpText])
+	    {
+	      width += glyphArray[*tmpText]->width;
+	    }
+	  tmpText++;
+	}
+      this->posSize.w = width;
+    }
 }
 
@@ -112,4 +132,13 @@
   this->posSize.x = x;
   this->posSize.y = y;
+}
+
+/**
+   \brief sets the text-alignment
+   \param alignment the alignment to set
+*/
+void Text::setAlignment(TEXT_ALIGNMENT alignemnt)
+{
+  this->alignment = alignment;
 }
 
@@ -188,4 +217,11 @@
   glColor4f(1.0f,1.0f,1.0f, this->blending);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+
+  glPushMatrix();
+  // transform for alignment.
+  if (this->alignment == TEXT_ALIGN_RIGHT)
+    glTranslatef(-this->posSize.w, 0, 0);
+  else   if (this->alignment == TEXT_ALIGN_CENTER)
+    glTranslatef(-this->posSize.w/2, 0, 0);
 
   // drawing this Text.
@@ -229,4 +265,5 @@
 	}
     }
+  glPopMatrix();
   GraphicsEngine::leave2DMode();
 }
Index: /orxonox/trunk/src/lib/graphics/text_engine.h
===================================================================
--- /orxonox/trunk/src/lib/graphics/text_engine.h	(revision 3842)
+++ /orxonox/trunk/src/lib/graphics/text_engine.h	(revision 3843)
@@ -29,15 +29,18 @@
 template<class T> class tList;
 
+//! An enumerator for the text alignment.
+enum TEXT_ALIGNMENT {TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER};
 
 /* some default values */
 #define FONT_DEFAULT_SIZE       50                   //!< default size of the Text
-#define FONT_DEFAULT_TEXT	"orxonox 1234567890" //!< some default text to display
-#define FONT_DEFAULT_COLOR_R    255                  //!< the default red part (color) of the text
-#define FONT_DEFAULT_COLOR_G    255                  //!< the default red green (color) of the text
-#define FONT_DEFAULT_COLOR_B    255                  //!< the default red blue (color) of the text
-#define FONT_NUM_COLORS         256                  //!< The number of colors.
+#define FONT_DEFAULT_TEXT	"orxonox 1234567890" //!< default text to display
+#define FONT_DEFAULT_COLOR_R    255                  //!< default red part (color) of the text
+#define FONT_DEFAULT_COLOR_G    255                  //!< default red green (color) of the text
+#define FONT_DEFAULT_COLOR_B    255                  //!< default red blue (color) of the text
+#define FONT_NUM_COLORS         256                  //!< number of colors.
 
 #define FONT_HIGHEST_KNOWN_CHAR 128                  //!< The highest character known to the textEngine.
 
+#define TEXT_DEFAULT_ALIGNMENT  TEXT_ALIGN_CENTER    //!< default alignment
 #define TEXT_STATIC             0                    //!< Static Text
 #define TEXT_DYNAMIC            1                    //!< Dynamic Text
@@ -101,4 +104,5 @@
   void setText(const char* text);
   void setPosition(int x, int y);
+  void setAlignment(TEXT_ALIGNMENT alignemnt);
   /** \param blending the blending intensity to set (between 0.0 and 1.0) */
   inline void setBlending(float blending) {this->blending = blending;}
@@ -107,4 +111,5 @@
   void setColor(Uint8 r, Uint8 g, Uint8 b);
   void setStyle(char* renderStyle);
+
   void createTexture();
 
@@ -121,4 +126,5 @@
   char* text;                    //!< The text to display
   SDL_Color color;               //!< The color of the font.
+  TEXT_ALIGNMENT alignment;      //!< The aignment of the text.
   float blending;                //!< The blending intensity.
   // placement in openGL
