2 // C Implementation: text
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
19 void text_load(text_type* ptext, char* file)
25 for(y = 0; y < 3 ; ++y)
27 for(x = 0; x < 26 ; ++x)
29 texture_load_part(&ptext->chars[c],file,x*16,y*16,16,16, USE_ALPHA);
35 void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update)
39 text_draw(&black_text,text,x+shadowsize,y+shadowsize, 0, update);
41 int len = strlen(text);
43 for( i = 0; i < len; ++i)
45 if( text[i] >= 'A' && text[i] <= 'Z')
47 texture_draw(&ptext->chars[(int)(text[i] - 'A')],x+i*16,y,update);
49 else if( text[i] >= 'a' && text[i] <= 'z')
51 texture_draw(&ptext->chars[(int)(text[i] - 'a') + 26],x+i*16,y,update);
53 else if ( text[i] >= '!' && text[i] <= '9')
55 texture_draw(&ptext->chars[(int)(text[i] - '!') + 52],x+i*16,y,update);
57 else if ( text[i] == '?')
59 texture_draw(&ptext->chars[77],x+i*16,y,update);
61 else if ( text[i] == '\n')
68 void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update)
72 else if(halign == A_HMIDDLE)
73 x += screen->w/2 - ((strlen(text)*16)/2);
75 if(valign == A_BOTTOM)
77 else if(valign == A_VMIDDLE)
80 text_draw(ptext,text,x,y,shadowsize,update);
84 void text_free(text_type* ptext)
87 for( c = 0; c < 78; ++c)
88 texture_free(&ptext->chars[c]);