Mercurial > hg > dmlib
changeset 634:656332eec724
Add condensed boolean flag to bitmap text rendering functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 15 Apr 2013 06:48:02 +0300 |
parents | 151747a24f57 |
children | 7092cd50bc08 |
files | dmtext.h dmtext_bm.c |
diffstat | 2 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/dmtext.h Mon Apr 15 06:44:13 2013 +0300 +++ b/dmtext.h Mon Apr 15 06:48:02 2013 +0300 @@ -53,9 +53,9 @@ int dmSaveBitmapFont(DMResource *res, DMBitmapFont *font); int dmSetBitmapFontPalette(DMBitmapFont *font, SDL_Color *pal, int start, int size); -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, ...); +void dmDrawBMTextConst(SDL_Surface *screen, DMBitmapFont *font, BOOL condensed, int mode, int xc, int yc, const char *str); +void dmDrawBMTextVA(SDL_Surface *screen, DMBitmapFont *font, BOOL condensed, int mode, int xc, int yc, const char *fmt, va_list ap); +void dmDrawBMText(SDL_Surface *screen, DMBitmapFont *font, BOOL condensed, int mode, int xc, int yc, const char *fmt, ...); static inline SDL_Surface *dmGetBMGlyph(DMBitmapFont *font, int ch)
--- a/dmtext_bm.c Mon Apr 15 06:44:13 2013 +0300 +++ b/dmtext_bm.c Mon Apr 15 06:48:02 2013 +0300 @@ -7,7 +7,7 @@ #include "dmtext.h" -void dmDrawBMTextConst(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt) +void dmDrawBMTextConst(SDL_Surface *screen, DMBitmapFont *font, BOOL condensed, int mode, int xc, int yc, const char *fmt) { const char *ptr = fmt; DMUnscaledBlitFunc blit = NULL; @@ -23,7 +23,8 @@ blit = dmGetUnscaledBlitFunc(glyph->format, screen->format, mode); blit(glyph, xc, yc, screen); - xc += glyph->w; + + xc += condensed ? glyph->w : font->width; } else xc += font->width; @@ -31,21 +32,21 @@ } -void dmDrawBMTextVA(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, va_list ap) +void dmDrawBMTextVA(SDL_Surface *screen, DMBitmapFont *font, BOOL condensed, int mode, int xc, int yc, const char *fmt, va_list ap) { char tmp[512]; vsnprintf(tmp, sizeof(tmp), fmt, ap); - dmDrawBMTextConst(screen, font, mode, xc, yc, tmp); + dmDrawBMTextConst(screen, font, condensed, mode, xc, yc, tmp); dmFree(tmp); } -void dmDrawBMText(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...) +void dmDrawBMText(SDL_Surface *screen, DMBitmapFont *font, BOOL condensed, int mode, int xc, int yc, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - dmDrawBMTextVA(screen, font, mode, xc, yc, fmt, ap); + dmDrawBMTextVA(screen, font, condensed, mode, xc, yc, fmt, ap); va_end(ap); }