--- /dev/null
+//
+// C Implementation: text
+//
+// Description:
+//
+//
+// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include <string.h>
+#include "globals.h"
+#include "defines.h"
+#include "screen.h"
+#include "text.h"
+
+void text_load(text_type* ptext, char* file)
+{
+ int x, y, c;
+
+ c = 0;
+
+ for(y = 0; y < 3 ; ++y)
+ {
+ for(x = 0; x < 26 ; ++x)
+ {
+ texture_load_part(&ptext->chars[c],file,x*16,y*16,16,16, USE_ALPHA);
+ ++c;
+ }
+ }
+}
+
+void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update)
+{
+
+if(shadowsize != 0)
+text_draw(&black_text,text,x+shadowsize,y+shadowsize, 0, update);
+
+ int len = strlen(text);
+ int i;
+ for( i = 0; i < len; ++i)
+ {
+ if( text[i] >= 'A' && text[i] <= 'Z')
+ {
+ texture_draw(&ptext->chars[(int)(text[i] - 'A')],x+i*16,y,update);
+ }
+ else if( text[i] >= 'a' && text[i] <= 'z')
+ {
+ texture_draw(&ptext->chars[(int)(text[i] - 'a') + 26],x+i*16,y,update);
+ }
+ else if ( text[i] >= '!' && text[i] <= '9')
+ {
+ texture_draw(&ptext->chars[(int)(text[i] - '!') + 52],x+i*16,y,update);
+ }
+ else if ( text[i] == '?')
+ {
+ texture_draw(&ptext->chars[77],x+i*16,y,update);
+ }
+ else if ( text[i] == '\n')
+ {
+ y += 18;
+ }
+ }
+}
+
+void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update)
+{
+if(halign == A_RIGHT)
+x += screen->w;
+else if(halign == A_HMIDDLE)
+x += screen->w/2 - ((strlen(text)*16)/2);
+
+if(valign == A_BOTTOM)
+y += screen->h - 16;
+else if(valign == A_VMIDDLE)
+y += screen->h/2;
+
+text_draw(ptext,text,x,y,shadowsize,update);
+
+}
+
+void text_free(text_type* ptext)
+{
+ int c;
+ for( c = 0; c < 78; ++c)
+ texture_free(&ptext->chars[c]);
+}
--- /dev/null
+//
+// C Interface: text
+//
+// Description:
+//
+//
+// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef SUPERTUX_TEXT_H
+#define SUPERTUX_TEXT_H
+
+#include "texture.h"
+
+/* Text type */
+typedef struct text_type
+ {
+ texture_type chars[78];
+ }
+text_type;
+
+enum {
+ A_LEFT,
+ A_HMIDDLE,
+ A_RIGHT,
+ A_TOP,
+ A_VMIDDLE,
+ A_BOTTOM,
+ A_NONE
+};
+
+void text_load(text_type* ptext, char* file);
+void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update);
+void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update);
+void text_free(text_type* ptext);
+
+#endif /*SUPERTUX_TEXT_H*/
+