# HG changeset patch # User Matti Hamalainen # Date 1349077376 -10800 # Node ID 3d9da937db6984efcc7847ce7a91e1b3f7bec43c # Parent daeb5d4f6badd2beb8beac02d7764254b4bacabb More work on the text support. diff -r daeb5d4f6bad -r 3d9da937db69 config.mak.in --- a/config.mak.in Mon Oct 01 09:50:43 2012 +0300 +++ b/config.mak.in Mon Oct 01 10:42:56 2012 +0300 @@ -18,6 +18,7 @@ DMRES_MEMIO=yes +DM_GFX_BM_TEXT=yes DM_GFX_TTF_TEXT=yes DM_GFX_LINES=no DM_GFX_BLITS=yes diff -r daeb5d4f6bad -r 3d9da937db69 dmtext.c --- a/dmtext.c Mon Oct 01 09:50:43 2012 +0300 +++ b/dmtext.c Mon Oct 01 10:42:56 2012 +0300 @@ -8,14 +8,14 @@ #ifdef DM_GFX_TTF_TEXT -void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt) +void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt) { SDL_Surface *text = TTF_RenderText_Blended(font, fmt, col); if (text) { SDL_Rect rect; - rect.x = x; - rect.y = y; + rect.x = xc; + rect.y = yc; rect.w = text->w; rect.h = text->h; SDL_BlitSurface(text, NULL, screen, &rect); @@ -23,22 +23,22 @@ } } -void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, va_list ap) +void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt, va_list ap) { char *tmp = dm_strdup_vprintf(fmt, ap); if (tmp != NULL) { - dmDrawTTFTextConst(screen, font, col, x, y, tmp); + dmDrawTTFTextConst(screen, font, col, xc, yc, tmp); dmFree(tmp); } } -void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, ...) +void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - dmDrawTTFTextVA(screen, font, col, x, y, fmt, ap); + dmDrawTTFTextVA(screen, font, col, xc, yc, fmt, ap); va_end(ap); } @@ -49,7 +49,7 @@ void dmDrawBMTextConst(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt) { const char *ptr = fmt; - DMScaledBlitFunc *blit = dmGetScaledBlitFunc(screen, font->glyphs[0], mode); + DMScaledBlitFunc blit = dmGetScaledBlitFunc(screen->format, font->glyphs[0]->format, mode); while (*ptr) { char ch = *ptr++; @@ -57,8 +57,8 @@ if (isprint(ch) && ch != ' ' && ch != '\t') { SDL_Surface *glyph = font->glyphs[(unsigned char) ch]; - blit(glyph, xc, yc, glyph->width, glyph->height, screen); - xc += glyph->width; + blit(glyph, xc, yc, glyph->w, glyph->h, screen); + xc += glyph->w; } else xc += font->width; @@ -71,7 +71,7 @@ char *tmp = dm_strdup_vprintf(fmt, ap); if (tmp != NULL) { - dmDrawBMTextConst(screen, font, col, x, y, tmp); + dmDrawBMTextConst(screen, font, mode, xc, yc, tmp); dmFree(tmp); } } @@ -82,7 +82,7 @@ va_list ap; va_start(ap, fmt); - dmDrawBMTextVA(screen, font, col, x, y, fmt, ap); + dmDrawBMTextVA(screen, font, mode, xc, yc, fmt, ap); va_end(ap); } diff -r daeb5d4f6bad -r 3d9da937db69 dmtext.h --- a/dmtext.h Mon Oct 01 09:50:43 2012 +0300 +++ b/dmtext.h Mon Oct 01 10:42:56 2012 +0300 @@ -20,6 +20,7 @@ /* Bitmapped fonts and text */ +#ifdef DM_GFX_BM_TEXT typedef struct { int width, height; @@ -34,6 +35,7 @@ void dmDrawBMTextConst(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *str); void dmDrawBMTextVA(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, va_list ap); void dmDrawBMText(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...); +#endif /* TTF text drawing