#include "goom_config.h" #include "gfontrle.c" #include #include static int ***font_chars; static int *font_width; static int *font_height; static int ***small_font_chars; static int *small_font_width; static int *small_font_height; void gfont_load (void) { unsigned char *gfont; unsigned int i = 0, j = 0; unsigned int nba = 0; unsigned int current = 32; int *font_pos; // decompress le rle gfont = malloc (the_font.width*the_font.height*the_font.bytes_per_pixel); while (i>2)<<(ROUGE*8))| (((g1 + g2 + g3 + g4)>>2)<<(VERT*8))| (((b1 + b2 + b3 + b4)>>2)<<(BLEU*8))| (((a1 + a2 + a3 + a4)>>2)<<(ALPHA*8)); } } } // definir les lettres restantes for (i=0;i<256;i++) { if (font_chars[i]==0) { font_chars[i]=font_chars[42]; small_font_chars[i]=small_font_chars[42]; font_width[i]=font_width[42]; font_pos[i]=font_pos[42]; font_height[i]=font_height[42]; small_font_width[i]=small_font_width[42]; small_font_height[i]=small_font_height[42]; } } font_width [32] = (the_font.height / 2) - 1; small_font_width [32] = font_width [32]/2; font_chars [32] = 0; small_font_chars [32] = 0; } void goom_draw_text (guint32 * buf,int resolx,int resoly, int x, int y, const char *str, float charspace, int center) { float fx = (float) x; int fin = 0; int ***cur_font_chars; int *cur_font_width; int *cur_font_height; if (resolx>320) { //printf("use big\n"); cur_font_chars = font_chars; cur_font_width = font_width; cur_font_height = font_height; } else { //printf ("use small\n"); cur_font_chars = small_font_chars; cur_font_width = small_font_width; cur_font_height = small_font_height; } if (cur_font_chars == NULL) return ; if (center) { unsigned char *tmp = (unsigned char*)str; float lg = -charspace; while (*tmp != '\0') lg += cur_font_width[*(tmp++)] + charspace; fx -= lg / 2; } while (!fin) { unsigned char c = *str; x = (int) fx; if (c == '\0') fin = 1; else if (cur_font_chars[c]==0) { fx += cur_font_width[c] + charspace; } else { int xx, yy; int xmin = x; int xmax = x + cur_font_width[c]; int ymin = y - cur_font_height[c]; int ymax = y; yy = ymin; if (xmin < 0) xmin = 0; if (xmin >= resolx - 1) return; if (xmax >= (int) resolx) xmax = resolx - 1; if (yy < 0) yy = 0; if (yy <= (int) resoly - 1) { if (ymax >= (int) resoly - 1) ymax = resoly - 1; for (; yy < ymax; yy++) for (xx = xmin; xx < xmax; xx++) { unsigned int color = cur_font_chars[c][yy - ymin][xx - x]; unsigned int transparency = color & 0xff000000; if (transparency) { if (transparency==0xff000000) buf[yy * resolx + xx] = color; else { unsigned int back = buf[yy * resolx + xx]; unsigned int a1 = (color & 0xff000000) >> 24; unsigned int a2 = 255 - a1; buf[yy * resolx + xx] = (((((color & 0x00ff0000) * a1) + ((back & 0x00ff0000) * a2)) & 0xff000000) >> 8) | (((((color & 0x0000ff00) * a1) + ((back & 0x0000ff00) * a2)) & 0x00ff0000) >> 8) | ((((color & 0x000000ff) * a1) + ((back & 0x000000ff) * a2)) >> 8); } } } } fx += cur_font_width[c] + charspace; } str++; } }