author | ecalot
<ecalot> 2005-01-27 03:30:53 UTC |
committer | ecalot
<ecalot> 2005-01-27 03:30:53 UTC |
parent | 6fdedce8c7873c91a42bde53089c25da2b331f0a |
FP/src/conf/alphabet.conf | +3 | -0 |
FP/src/conf/awk/text_conf.awk | +7 | -1 |
FP/src/out/output.c | +5 | -11 |
diff --git a/FP/src/conf/alphabet.conf b/FP/src/conf/alphabet.conf index 667fc68..76301f2 100644 --- a/FP/src/conf/alphabet.conf +++ b/FP/src/conf/alphabet.conf @@ -1,3 +1,6 @@ +Space 3 +Kerning 1 + Character 'A': /------\ | OOOO | diff --git a/FP/src/conf/awk/text_conf.awk b/FP/src/conf/awk/text_conf.awk index 896bc7f..a2d439c 100644 --- a/FP/src/conf/awk/text_conf.awk +++ b/FP/src/conf/awk/text_conf.awk @@ -45,6 +45,7 @@ BEGIN { #default space=3 + kerning=2 } @@ -53,10 +54,14 @@ BEGIN { # Parse file into memory # ########################## -/^Space [0-9]+$/ { #space is treates specially +/^Space [0-9]+$/ { #space is treated specially space=$2 } +/^Kerning [0-9]+$/ { #character separation in pixels + kerning=$2 +} + /^Character '.':$/ { #new character if (state==waitingForChar) { c=ord[substr($2,2,1)] @@ -157,5 +162,6 @@ END { printf("#define TEXT_IMG_SIZE %d\n",img) printf("#define TEXT_IMG_H %d\n",maxSize) printf("#define TEXT_IMG_W %d\n",offset) + printf("#define TEXT_KERNING %d\n",kerning) } diff --git a/FP/src/out/output.c b/FP/src/out/output.c index ee577c4..18cdea2 100644 --- a/FP/src/out/output.c +++ b/FP/src/out/output.c @@ -60,8 +60,6 @@ static SDL_Surface* screen; /* Text functions */ -#define CHAR_SIZE 12 - typedef struct _valid_chars { char is_valid; /* Is character valid ? */ unsigned short x; /* X pos in font image */ @@ -103,13 +101,7 @@ void initText () } /* Load Texture */ -/* font = SDL_LoadBMP (FONT_FILE); - if (!font) { - fprintf (stderr, "CAN'T LOAD " FONT_FILE "!\n"); - exit(1); - }*/ - aux=outputLoadBitmap(fonts,TEXT_IMG_SIZE,pal,TEXT_IMG_W,TEXT_IMG_W,0,1,0,0); - + aux=outputLoadBitmap(fonts,TEXT_IMG_SIZE,pal,TEXT_IMG_H,TEXT_IMG_W,0,1,0,0); font=aux->surface; font_init = 1; @@ -124,6 +116,7 @@ unsigned int outputGetTextWidth (const char *txt) while ((*s) != '\0') { if (valid_chars[*s].is_valid) { l += valid_chars[*s].w; + l += TEXT_KERNING; } s++; } @@ -173,7 +166,7 @@ void outputsDrawText(int x, int y, const char *buffer) from.x = valid_chars[*s].x; from.y = 0; from.w = valid_chars[*s].w; - from.h = CHAR_SIZE; + from.h = TEXT_IMG_H; to.x = current_x; to.y = y; @@ -182,6 +175,7 @@ void outputsDrawText(int x, int y, const char *buffer) SDL_BlitSurface (font, &from, screen, &to); current_x += valid_chars[*s].w; + current_x += TEXT_KERNING; } s++; } @@ -350,7 +344,7 @@ void outputUpdateScreen() /* check out for messages */ if (messageFrames==1) outputClearLastMessage(); if (messageFrames) messageFrames--; - outputsDrawText((DEF_SCREEN_WIDTH-outputGetTextWidth(messageBuffer))/2,DEF_SCREEN_HEIGHT-CHAR_SIZE,messageBuffer); + outputsDrawText((DEF_SCREEN_WIDTH-outputGetTextWidth(messageBuffer))/2,DEF_SCREEN_HEIGHT-1-TEXT_IMG_H,messageBuffer); SDL_Flip(screen); }