palpic2png.c: improve, make usable with ppic binary files
[rofl0r-openDOW.git] / font.c
blob99adf8f5a5b94afecfe79a3d424ea51d03d32a98
1 #include "palpic.h"
2 #include "sprites/font.c"
3 #include "SDL/SDL.h"
4 #include <stddef.h>
6 #define STRSWITCH_LETTERS_UC 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': \
7 case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': \
8 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z'
10 #define STRSWITCH_LETTERS_LC 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': \
11 case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': \
12 case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z'
14 #define STRSWITCH_LETTERS STRSWITCH_LETTERS_UC: case STRSWITCH_LETTERS_LC
16 #define STRSWITCH_NUMBERS '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9'
19 extern SDL_Surface *surface;
20 extern struct vo_desc video;
22 static int chartofontindex(int c) {
23 switch(c) {
24 case STRSWITCH_NUMBERS:
25 return c - '0' + 16;
26 case STRSWITCH_LETTERS_UC:
27 return c - 'A' + 33;
28 case STRSWITCH_LETTERS_LC:
29 return c - 'a' + 33;
30 case '!' : return 1;
31 case '$' : return 4;
32 case '\'': return 7;
33 case ',' : return 12;
34 case '.' : return 14;
35 case '\?': return 31;
36 default:
37 return 0;
41 void font_print(int x, int y, const char *str, size_t len, unsigned scale, prgb color) {
42 size_t i;
43 prgb col[2] = {PRGB(0,0,0), color };
44 for(i = 0; i < len; i++, x+=8*scale)
45 blit_sprite(x,y, &video, scale, &font.header, chartofontindex(str[i]), col);